2024-12-23 11:44:48 +08:00

60 lines
2.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 星云SDK
## 介绍
星云SDK是一款为开发者打造的智能锁SDK旨在简化与智能锁与星云平台的交互。通过封装底层操作使接入者无需关注锁的操作逻辑能够将更多精力集中在业务开发中。
星云SDK项目可根据不同的打包命令生成用于不同平台的npm包目前支持的平台有uniweb。
## 文件说明
- `star-cloud`星云SDK支持的对外暴露的功能根据功能模块拆分成多个文件
- `uni`星云SDK需要的uniapp平台的底层功能如请求、缓存等。index.js为uni平台npm包的入口文件可选择暴露哪些功能到uni平台
- `web`星云SDK需要的web平台的底层功能如请求、缓存等。index.js为web平台npm包的入口文件可选择暴露哪些功能到web平台
- `api`: 星云内部接口请求地址
- `common`: 公共方法
- `constant`: 常量
- `env`: 环境配置,打包版本设置
- `export.js`: 根据不同平台暴露平台支持的功能
- `format.js`: 格式化数据相关公共方法
- `log.js`: 不同平台的日志上报方法
- `obfuscation.js`: 不同平台的混淆打包方法
- `star-cloud.js`: StarCloud类
## 使用方法
1. 安装npm包
```shell
npm install
```
2. 打包uni平台npm包
```shell
npm run uni-build
```
打包web平台npm包
```shell
npm run web-build
```
3. 发布npm包
进入dist目录执行npm publish命令
```shell
cd dist
npm publish
```
若未登录npm账号需先登录
```shell
npm login
```
## 调试方法
1. 在测试项目中执行以下命令将星云SDK项目作为子项目添加到测试项目中直接调用对应平台的index.js文件中的方法
```
git subtree add --prefix=starCloud git@code.star-lock.cn:StarlockTeam/starcloud-sdk-uniapp.git master
```
2. 更新子项目
```
git subtree pull --prefix=starCloud git@code.star-lock.cn:StarlockTeam/starcloud-sdk-uniapp.git master
```
3. 推送子项目
```
git subtree push --prefix=starCloud git@code.star-lock.cn:StarlockTeam/starcloud-sdk-uniapp.git master
```