17 Star 10 Fork 8

DCloud / native-docs

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

简介

uni小程序SDK,是为原生App打造的可运行基于 uni-app 开发的小程序前端项目的框架,从而帮助原生App快速获取小程序的能力,效果如下:

基本概念

uni-app

首先您需要了解什么是uni-appuni-app 是一个使用 Vue.js 开发所有前端应用的框架,开发者编写一套代码,可发布到 H5、以及各种小程序(微信/支付宝/百度/头条/QQ/钉钉/淘宝)、快应用等多个平台,并且在 HBuilderX 中可直接打包生成 Android、iOS App。了解更多关于 uni-app 请点击查看 uni-app 官网

uni小程序SDK

uni小程序SDK是原生SDK,提供 Android 版本 和 iOS 版本,需要在原生工程中集成,然后即可运行用uni-app框架开发的小程序前端项目,一套代码两端运行

名词解释

  • 宿主:想要构建小程序的原生App,集成uni小程序SDK的宿主
  • 小程序:运行在宿主中的前端代码编写的小程序项目,使用 uni-app 框架开发
  • wgt:小程序应用资源包,即使用 uni-app 框架开发的项目,导出的小程序应用资源包
  • HBuilderX:开发 uni-app 的 IDE 工具

注意

  1. uni小程序SDK 仅支持使用 uni-app 开发的小程序,不支持纯 wxml 微信小程序运行。但 uni-app 支持使用 wxml 格式的小程序组件。
  2. uni小程序SDK 仅支持 uni-app 的 v3 编译器。使用老版的开发者,需首先保障应用可以运行在 v3 编译模式下。

特色

uni-app 在 app 端是双渲染引擎,可以像微信那样使用webview渲染,也可以使用改造版的weex进行原生渲染。其中 webview 渲染在 Android 上也同时支持系统webview渲染和x5渲染。

  • 性能 uni小程序sdk的性能,与uni-app的app端v3编译器相同,性能超过市面其他小程序引擎。在启动速度、页面加载速度、逻辑层与视图层通信优化等方面均优有更优秀的表现。
  • 功能 uni小程序sdk的功能,与uni-app的app端功能相同,所有原生能力均可调用。不同于小程序的限制和有限API,uni小程序sdk的功能更加强大。
  • 插件生态 uni-app插件市场有大量丰富的插件。

应用场景

  1. 宿主App构建自己的应用生态,可以面向广泛开发者,也可以定向部分开发者
  2. 原生App利用小程序模式对模块解耦,让不同模块的开发团队各自独立发版,灵活更新
  3. 原生App中部分功能使用uni-app实现,降低开发成本、提升发布效率

集成流程

  1. 宿主开发者下载uni小程序sdk,根据文档集成到宿主App中
  2. 小程序开发者使用 HBuilderX 创建 uni-app 项目并开发功能,开发阶段可以直接在 HBuilderX 内置基座进行测试,开发完毕后在发行菜单导出wgt包
  3. 宿主开发者将 wgt 集成到宿主App中,可离线集成直接打包进去,也可以在线下载wgt
  4. 通过 uni小程序sdk 的 api 将 wgt 资源部署到运行路径,然后即可跳转到该资源对应的小程序应用中
  5. uni小程序支持 wgt升级,可以在小程序中直接调用 api 在线更新 wgt 资源,即热更新 参考文档

注意

  • uni小程序sdk 仅支持在原生App中集成使用,不支持 HBuilderX 打包生成的App中集成。如需在uni-app项目中使用,请加QQ群984388064申请
  • uni小程序sdk 支持同时运行多个小程序实例,但android平台最多打开三个
  • uni 小程序 sdk 无法使用插件市场中付费的原生插件

案例

  • CSDN App: Appstore新闻类榜单前十。App内部众多栏目做成小程序形式。App下载
  • 顺丰速运: 顺丰速运官方提供查、寄快递,网点查询、邮费查询等相关服务的一站式快递物流服务软件。App下载AppStore下载
  • 驿收发: 驿收发快递驿站App。AppStore下载
  • 我i科大: 河南科技大学移动App。官方下载AppStore下载
  • 郑州大学移动校园: 郑州大学官方校园生活工具App。官方下载AppStore下载
  • 多彩洛职: 洛阳职业技术学院移动App。官方下载AppStore下载
  • 大参林百科: 大参林医药集团股份有限公司智能零售App。App下载AppStore下载
  • 网易藏宝阁: 网易官方游戏交易平台。 App下载
  • 咪咕视频爱看版: 咪咕视频爱看版App。App下载AppStore下载
  • 剧豆星光: 帮助线下门店更好的进行积分营销App。App下载
  • 国家医保服务平台: 国家统一的医保服务平台App,为百姓提供参保缴费、信息查询、待遇申请、业务经办等多种使用功能服务。 App下载AppStore下载
  • 乐健体育: 一款智能云端健身App。App下载
  • 海康威视: 海康互联App。官方下载
  • 伴玩: 比心陪玩交友平台App。App下载

FAQ

Q:uni小程序sdk 与 App离线sdk 的差别是什么? A:解决两种不同的需求场景,前者的使用场景是你已经有原生App,在此基础上扩展宿主App的小程序能力,或者用小程序替换原生App的部分功能模块,仅支持uni-app并使用v3编译器;后者的使用场景是你没有原生App,用DCloud的工具来开发App,又不想使用云打包,则可以使用App离线sdk打包发布为原生App,App离线sdk支持5+ App、uni-app,不支持wap2app。虽然App离线sdk也可以集成到已有原生App中,但自从uni小程序sdk推出后,将不再推荐这种用法。

Q:想了解 uni小程序sdk 都有哪些js api,和微信小程序相比如何? A:uni小程序sdk的js api比微信小程序更多,不同于微信小程序的“小”的限制,uni小程序sdk的功能更接近于正常的app,没有包体积限制,并且提供了更丰富的api,以支持完整app的开发。文档和演示demo见:https://uniapp.dcloud.io/

Q: uni小程序不需要集成分享、支付等第三方的功能。集成到我的Android项目中APK的体积会增加多少? A: 如果排除视频、地图、分享、支付、登录、直播pusher等sdk,只集成基础模块。占用APK体积大小如下:

cpu型号.so选择 apk占用大小
armeabi-v7a 约7MB左右
'armeabi-v7a'、'x86'、'arm64-v8a' 约16MB左右

Q:支持uni小程序的基座与标准的HX基座权限方面有什么变化? A:两者权限基本一致,除了uni小程序的基座会增加下列权限,用于支持创建小程序桌面快捷方式

权限
com.android.launcher.permission.INSTALL_SHORTCUT
com.android.launcher.permission.UNINSTALL_SHORTCUT
com.android.launcher.permission.READ_SETTINGS
com.android.launcher2.permission.READ_SETTINGS
com.android.launcher3.permission.READ_SETTINGS

文档编写注意事项

  1. 右侧导航仅支持二级、三级、四级

  2. 文档如有标题,必须从一级或二级开始,不允许只有三级,没有二级的情况;也不允许先有三级、后有二级的情况;

  3. FAQ、注意事项、常见问题,要放在文档最下方,不要穿插在文档中间位置

  4. 容器书写方式,支持:infotipwarningdangerdetails(在 IE / Edge 中不生效) 详情

    ::: warning 注意
    - 认证凭证有效期为`30分钟`
    - 当余额全部被冻结时,会出现有余额但无法调用服务的情况
    :::

  5. 代码语法高亮支持:jsjavascripttstypescriptobjc(Objective-C)kt(Kotlin)cs(C#)cpp(C++)等。详情

  6. 支持流程图:

     ```mermaid
     sequenceDiagram
     actor user as 用户端
     participant cf as 云函数/云对象
     participant service as 认证服务
     activate user
     user->>+user: 获取设备信息metaInfo
     user->>+cf: 提交姓名、身份证号、metaInfo获取certifyId
     cf->>+service: 提交姓名、身份证号、metaInfo获取certifyId
     service-->>-cf: 返回certifyId
     cf-->>-user: 返回certifyId
     user->>+service: 调用sdk进行刷脸认证
     service-->>-user: 返回认证结果
     user->>+cf: 请求校验认证结果
     cf->>+service: 请求认证结果
     service-->>-cf: 返回认证结果
     cf-->>-user: 返回最终实人认证结果
     deactivate user
     ```

  7. 代码支持行高亮 详情

  8. 标题(Badge)组件 详情

  9. 可使用模板语法 详情

  10. 图片点击放大 img.class="zooming"

    <img class="zooming" src="xxx">
  11. md 支持书写属性。#{:左定界符,与 markdown 语法之间不能有空格;} 右定界符

    ![](https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/uni-app-multiport.jpg)#{.zooming data=abc width=100 height=100}

    渲染为:

    <img src="https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/uni-app-multiport.jpg" class="zooming" data="abc" width="100" height="100" />
  12. 路径注意

    • _sidebar.md是左侧导航,其中路径写https路径,可打开新页签。如左侧导航里引用了本产品目录之外的文档,需写成这种方式
    • 每个产品目录下均有一个static目录,在其中提交图片视频等静态资源。引用static下的静态资源时,路径可以是"../static"、"./static",不能写"static/"。
    • 书写文档时应注意特殊符号的编写与换行:
      • ### 下应有空行
      • 内容 **加粗** 内容 两边需要有空格
      • 在书写方括号 [] 时要注意使用转义字符 \,或者使用 \`` 包裹,否则会被识别为链接,导致链接失效
  13. md 表格支持行、列合并

    • 行列合并
      |资源分类		|资源细项				|售价(元)	|
      |:-:			|:-:					|:-:		|
      |云函数 #{rowspan=3}|资源使用量(GBs)		|0.000110592|
      |调用次数(万次)		|0.0133		|
      |出网流量(GB)			|0.8		|
      |云数据库 #{rowspan=3}|容量(GB/天)			|0.07		|
      |读操作使用量(万RU)	|0.015		|
      |写操作使用量(万RU)	|0.05		|
      |云存储 #{rowspan=4}|容量(GB/天)			|0.0043		|
      |下载操作次数(万次)	|0.01		|
      |上传操作次数(万次)	|0.01		|
      |CDN 流量(GB)			|0.18		|
      |前端网站托管 #{rowspan=2}|容量(GB/天)			|0.0043		|
      |流量(GB)|0.18		|
      |售价(元/月)#{colspan=2}	|5		|
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

简介

暂无描述 展开 收起
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/dcloud/native-docs.git
git@gitee.com:dcloud/native-docs.git
dcloud
native-docs
native-docs
master

搜索帮助