2025-01-07 18:11:07 +08:00

58 lines
1.9 KiB
Markdown
Raw Permalink 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. 执行想要调试的平台命令
```shell
npm run web-build
npm run uni-build
```
2. 将项目与调试项目放在同级目录下在调试项目中执行npm命令
```shell
npm install ../[项目名称]
```
3. 即可在调试项目中用调用正式版npm包方法进行调试