

English
DCloud有活跃的插件市场,https://ext.dcloud.net.cn/,并提供了计价销售、广告解锁、赞助、评价等机制。
很多优秀的插件作者,可以做到每月销售数万元的插件。(只有uniCloud插件和App原生或uts插件支持付费,其他类型插件不能设价格)
了解插件变现的详细信息,另见文档插件变现
uni插件其实是uni-app项目下一部分代码,但提交时注意:
插件ID命名规范:
Since HBuilderX 3.1, uni_modules
has been added, which is an important modular solution for the uni ecosystem. For details, see: https://uniapp.dcloud.net.cn/uni_modules
自uni_modules
发布后,建议插件作者首先在自己的项目下建一个uni_modules
,在本地开发调试没问题后,对uni_modules
下你的插件目录点右键,提交发布到插件市场。
插件市场分多种插件,分类介绍如下:
前端组件指uni-app前端使用vue/nvue/wxml等技术开发的、用于页面内嵌的组件。它又进一步细分为vue组件、uvue组件、nvue组件、小程序自定义组件。这个分类不包含uts原生组件。
Let's take the tag component developed by Xiaoming (plugin ID: xiaoming-tag) as an example, when uploading the plugin market, the directory structure requirements are as follows:
In order to keep the code concise, only the necessary files and directories need to be included when uploading the plugin.
If the component depends on the third-party components, the three-party components need to be packaged and uploaded together; if "xiaoming-tag" depends on the icon component (xiaohong-icon) developed by Xiaohong, when publishing the "xiaoming-tag" plugin, the directory structure requirements are as follows:
Tips:
插件市场很早就支持原生插件和uniCloud云插件的加密保护。但前端插件,比如ui库,尤其是可编译到web和小程序的插件,由于其载体的特殊开放性,很难做知识产权保护。
HBuilderX 4.19起,DCloud提供了一种云编译的手段来解决前端插件的知识产权保护问题。
插件作者设置加密后,插件使用者下载到的插件是加密后的版本。在运行、发行对前端代码编译时,uni-app x的编译器会将加密插件发送到DCloud的云编译服务器进行编译,将编译结果混入本地编译工程。从而实现插件使用者可以使用插件但无法获取插件源码的效果。这种云编译仅在第一次进行,云编译一次后会有缓存。
当然插件使用者可以获取到编译后的代码,但就像uni-app (x)编译后的代码非常难懂,更不会有人去改一样,这种方式虽然不严谨但大体上还是有效保护的了前端插件作者的知识产权。
这个过程不会把插件使用者的项目源码整体发送到DCloud服务器,云编译和解密的仅包括加密插件。
插件市场所有加密付费的插件,均有普通授权和源码授权两种版本。如果购买了源码授权,插件作者可以得到插件的完整源码,此时不再发送插件源码到云编译服务器。
不管是普通授权版
还是源码授权版
,都是绑定唯一的appid和包名。如购买者更换了这2个信息中的一个,需要重新购买授权。注意参考插件购买协议。
通过开发工具、编译器、运行时的整体配合,DCloud给前端插件作者提供了以往不存在的、更为优秀的知识产权保护方案。包括源码授权版,DCloud也会检查盗版行为。
目前前端插件加密,仅支持uni-app x下uni_modules形式的、符合 easycom 规范的组件。插件可在全平台加密,包括web端、app端。
如需发布付费插件,可对插件设置普通授权版
及源码授权版
的价格。DCloud插件市场会自动加密付费插件中所有vue、uvue、uts、js、ts文件(除pages、hybrid、static目录外)。
HBuilderX发布插件界面暂未支持前端组件价格设置,插件作者可在插件package.json中手动配置价格后提交发布,后续ui上将支持前端组件价格设置。
配置方式参考uni_modules配置,在package.jsondcloudext
下添加sale
销售信息。
前端组件付费插件支持试用,当插件用户试用插件时,无法查阅这些加密的源码。插件试用只能用于本地运行或打包自定义基座,不能用于正式发布。
如果插件用户购买了普通授权版,也看不到这些加密文件的源码,运行或打包时,会提交到云端进行验证、解密及编译。
前端组件付费插件开发注意事项:
uni-app x
项目,不支持uni-app
项目,且最低需要HBuilderX 4.19+utssdk
目录、不支持页面加密、仅支持符合 easycom 规范的组件。可通过依赖的方式配置其他插件(目前仅支持依赖同样加密的插件)。前端组件付费插件使用注意事项:
当项目包含前端付费插件时,首次运行或发行到指定平台时,会触发付费插件在该平台的云端编译,此时需要您的电脑处于联网状态,且您登录的HBuilderX账号需要具备使用该插件的权限(购买、试用、协作等),一旦云端编译成功,后续将使用本地缓存,如果更新了的插件版本、HBuilderX版本或运行时勾选了清除缓存,会再次触发云端编译。
不支持直接引入插件内部的文件,仅支持导入插件根目录
import { test } from '@/uni_modules/test-components' // 需要插件作者在 index.uts 中 导出 test
import { test } from '@/uni_modules/test-components/test.uts'
Let's take the setting template (xiaoming-setting) developed by Xiaoming as an example. When uploading the plugin market, the directory structure requirements are as follows:
当然依赖管理,可以使用uni_modules
,在你的uni_modules
目录下的package.json中配置依赖另一个uni_modules
,此时就不用再包含其他插件的源码,但这种做法无法锁定版本,会在使用者下载你的插件时自动安装最新的依赖。
如果你的页面,需要在下载时被注册到使用者的项目的pages.json中,从HBuilderX 3.5.0+ 插件导入工程时,支持合并页面路由到项目的 pages.json。详见
Tips:
Tips:
unpackage
directory does not need to be included when the project template is packaged;When developing the JS SDK, there is no special requirement for the directory structure, just name the js file as the plugin ID, for example: xiaoming-md5.js
Tips:
如果是非uni_modules
的js sdk,使用者下载后会被下载到使用者项目根目录下的js_sdk
目录
uts插件开发详见插件开发文档,这里主要说明uts付费插件发布的注意事项。
uts付费插件分为普通授权版
及源码授权版
,两种付费方式区别详见说明文档。
如需发布付费插件,可对插件设置普通授权版
及源码授权版
的价格。DCloud插件市场会对付费插件自动加密,付费插件加密规则:
当插件用户试用插件时,无法查阅这些加密的源码。uts插件试用只能用于打包自定义基座,不能用于正式发布。
如果插件用户购买了普通授权版
,也看不到这些加密文件的源码,提交云打包时,会在云端验证并解密文件进行打包。
如果插件作者上传插件时,设置了提供源码授权版,且插件使用者购买了源码授权版,才能下载到插件的源码。
不管是普通授权版
还是源码授权版
,都是绑定唯一的appid和包名。如购买者更换了这2个信息中的一个,需要重新购买授权。
Tips:
uts插件和App原生插件在功能上是重叠的,都是原生扩展uni-app的能力。
从uts插件发布后,DCloud建议插件作者开发uts插件,替代老的原生插件。
它们之间有如下具体差别:
目前uni-app的ext api全部基于uts实现,一些内置api如弹框也已经改成uts实现。虽然对于开发者而言这些并非需要下载的插件,但其实本质是内置于runtime的uts插件。未来uni-app的所有官方api都会改为uts实现。uts的开发体验会优化到最佳。而原生语言插件只会修改较严重的bug。
在未来,uts插件将同时支持下一代的uni-app的uvue,以及现有的vue、nvue。而app原生语言插件只支持这一代的uni-app,无法支持uvue。
包括uts组件,也将支持vue页面。而原生语言插件的组件模式不会支持vue页面,只支持nvue页面。
注意uts插件目前还不支持离线打包,不过插件市场销售的原生语言插件也不支持离线打包。建议有个性化打包需求的开发者使用HBuilderX的cli来处理自动化打包。
FAQ:
App原生语言插件,需使用Andorid/iOS原生环境开发实现,请参考以下教程:
Compressed package format requirements: After opening the zip, the root directory must be the plugin id directory, and the secondary directory is the ios, android subdirectory and package.json. For details, refer to [uni native plugin package format](https://nativesupport.dcloud.net. cn/NativePlugin/course/package)
从uts插件发布后,DCloud建议插件作者开发uts插件,替代老的原生插件。原因见上。
The HBuilderX plugin is installed in the HBuilderX tool. It is a plug-in for the editor, not a plug-in for the mobile app. For detailed development tutorials, see: http://hx.dcloud.net.cn/
Cloud function templates have no special requirements for file naming, but when creating a plug-in zip package, you need to pay attention to the following points:
If you upload a paid cloud function plugin, you must select the cloud function you want to encrypt, otherwise plugin trial users can use your plugin indefinitely through the trial process without paying.
Define the encrypted cloud function. In order to unify the standard with uni_modules and discard the original encryptlist.json, you need to add package.json to the root directory of the plugin, and configure the files to be encrypted in uni_modules->encrypt, such as:
{
"uni_modules": {
"uniCloud-aliyun/cloudfunctions/function/index.js"
],
}
}
The js files of cloud functions and public modules under uniCloud/cloudfunctions can be flexibly configured in the encrypt array, which is more flexible than configuring the entire cloud function or public module in the original encryptlist.json file.
After defining the cloud function content to be encrypted, upload the plug-in, and the DCloud plug-in market will automatically encrypt these cloud functions. When the plug-in user tries the plug-in, he cannot view the source code of these cloud functions, and only during the trial period (usually 7 days), these encrypted cloud functions can be run on the service space he deployed. After the trial period, these cloud functions will be Automatically lapse.
Even if the plug-in user purchases the normal authorized version of the plug-in, he cannot see the source code of these encrypted cloud functions, but these cloud functions can run normally on the service space bound when he purchased them. and cannot be uploaded to other service spaces.
If the author of the plug-in uploads the plug-in, and the authorized version of the source code is provided at the same time, and the user of the plug-in has purchased the authorized version of the source code, all the source code of the plug-in can be obtained.
For the difference between the ordinary authorized version and the source code authorized version, please refer to: https://ask.dcloud.net.cn/article/38040
Starting from HBuilderX 3.2.0, when a paid plug-in for cloud-integrated project template or cloud-integrated page template is released, the front-end js file also supports encryption. The setting method is similar to the cloud function. Define the file path in uni_modules->encrypt, like:
{
"uni_modules": {
"encrypt": [
"js_sdk/index.js",
"components/demo/demo.js"
],
}
}
目前只支持付费插件的js文件加密,vue及nvue文件无法加密,业务核心逻辑建议写到js中。 如果发布云端一体项目且包含uni_modules
时,则不会加密uni_modules
目录下的文件,uni_modules
下应该做为独立插件发布,分别进行加密配置。
If your plugin configuration contains confidential information, you want to protect these configurations from uploading. Reference: uni_modules plugin upload auxiliary script example
Cloud integrated page template, if not uni_modules
, it is a single-page template, and only one page can be placed. In the case of uni_modules
, any number of pages can be placed.
In order to prevent conflicts with the existing code of the project when importing, pay attention to the following naming conventions:
It is basically the same as the uni-app front-end project template directory structure, but must include uniCloud related directories (uniCloud-aliyun, uniCloud-tcb)
After using the uniCloud admin basic framework, you can further integrate the admin plugin written by the plugin author to enrich the functions of your own admin system.
Plugin authors can also submit plugins according to this document, and select Admin Plugins
in the uniCloud
category on the upload and release page of the Plugin Marketplace.
因文档较长,请单独参阅:uniCloud admin插件开发指南
It is mainly used to submit data table schema and verification function, so it must include uniCloud-aliyun/database or uniCloud-tcb/database directory
Documentation migrated to uni_modules documentation
如果是非uni_modules插件,那么自己压缩的压缩包注意为标准zip格式,不要使用非主流的压缩软件、不要把rar等其他格式文件的后缀名改名为zip