1.43.4 • Published 2 years ago

@dcbfe/jssdk v1.43.4

Weekly downloads
52
License
MIT
Repository
-
Last release
2 years ago

多彩宝 JSSDK

封装思路

  • 尽量对齐微信小程序 API 的名称和入参,减少记忆成本

  • 模块化,一个文件就是一个接口,方便维护

  • 采用 TypeScript 编写,编译为 JavaScript 发包,附带类型定义,让 IDE 可自动提示,免去手动翻找文档的麻烦

  • 注释即文档,解析源码自动生成文档

  • 导出 dcb 对象提供服务(类比小程序的 wx、my、tt 等挂载 API 的方式),如:

    import { dcb } from '@dcb/jssdk';
    
    dcb.setClipboardData({
      data: '复制文本',
    });
  • 接口全部异步化,采用 Promise 封装,避免回调地狱:

    import { dcb } from '@dcb/jssdk';
    
    const tempImages = await dcb.chooseImage({
      count: 1,
    });

完成情况

客户端 API 名称 -> JSSDK 封装后的名称(尽量对齐微信小程序的名称,若微信小程序没有类似接口,则对齐其命名风格: 动词+名词)

  • getAppInfo -> getAppInfo
  • getDCBUserInfo -> getUserInfo
  • getDCBUserInfoAuth -> getUserInfo
  • copyString -> setClipboardData
  • callPhone -> makePhoneCall
  • callPhoneNoUI -> makePhoneCall
  • screenOrientation -> setScreenOrientation
  • removeWebCache -> clearCache
  • registerService -> config
  • didClickSubcribe -> refreshSubscriptionData
  • showKeyBoard -> showKeyboard
  • hiddeKeyBoard -> hideKeyboard
  • pictureOrVideoSelect -> chooseImage, chooseVideo
  • saveWebImage -> saveImageToPhotosAlbum
  • saveBase64Image -> saveImageToPhotosAlbum
  • photoBrowser -> previewImage
  • takePhoto -> chooseImage
  • singlePhotoSelect -> chooseImage
  • voiceRecord -> recordAudio
  • openDuoGirl -> openVoiceSearch
  • playVideo -> playVideo
  • shareManageControl -> share, shareImage
  • openRouter -> navigateTo
  • routerServiceWithID -> navigateTo
  • closeWebview -> closeWindow
  • reloadWebview -> reloadWindow
  • backButtonOpera -> hideBackButton, showBackButton
  • operateCloseButton -> hideCloseButton, showCloseButton
  • setWebTitle -> setNavigationBarTitle
  • toast -> showToast
  • openScanQRCode -> scanCode
  • getLocationInfo -> getLocation
  • realNameCheck -> requestRealNameAuthentication
  • dcbAlive -> requestFaceAuthentication
  • overseaPeopleAuth -> requestForeignerAuthentication
  • sendWxReq -> requestAuthorize
  • sendAlipayAuth -> requestAuthorize
  • openThirdApp -> navigateToApp
  • openMiniProgram -> navigateToMiniProgram
  • clientPayment -> requestPayment
  • nativePayment -> requestPayment
  • companyAuthVideo -> recordVideo
  • fileBrowse -> openDocument
  • getContacts
  • openTabIndex -> switchTab
  • makeCustomerServicePhoneCall
  • compareAppVersion
  • getEnv

参与开发

克隆项目

git clone ssh://git@git.gogpay.cn:7999/dcbfron/dcb-jssdk.git

安装依赖

若你未安装 node.js,请先安装:https://nodejs.org/zh-cn/

npm i

# 或者
yarn

# 或者
pnpm i

创建特性分支

比如你这次要新建个 openDocument 的 API,那就创建个 api/openDocument 的分支:

git checkout -b api/openDocument

开始开发

首先使用命令 npm run docs:dev 开始文档服务,接着使用 npm run api:new 创建新的 API,然后打开新 API 的文件编写代码,其间可以打开 docs/demo/demo.vue 编写新 API 的演示代码并用多彩宝 App 扫码测试是否正确。

最后,若测试正常,使用命令 npm run docs:gen 重新生成 API 文档,并查看生成的文档是否正常。

附所有命令的说明:

命令说明
npm run build编译代码
npm run api:new引导创建新的 API
npm run api:index生成 API 索引
npm run docs:dev文档开发
npm run docs:build文档构建
npm run docs:gen生成 API 的文档
npm run release发布(非负责 Review 的同事请勿执行)

发布流程

在你创建的分支上完成开发并提交,然后发起 Pull Request,由指定的前端同事 Review 并进行后续的发包等流程。

若主分支有更新,请这样同步代码:

# 检出 master
git checkout master

# rebase
git pull --rebase origin master

# 检出你的分支
git checkout 你的分支名

# rebase
git rebase master

注意:一个分支只做一件事(或一类事),分支合并后就不应该再继续在该分支进行开发,新的事项请新建分支开发。

git commit 信息格式规范

为了自动生成更新日志(实质上就是自动提取 git 提交记录生成更新日志),请遵循以下规范:

# 特性(feature)增加以 feat: 开头
git commit -m "feat: 新增 openDocument"
git commit -m "feat: openDocument 支持打开 docx"

# bug 修复以 fix: 开头
git commit -m "fix: 解决 openDocument 不能打开 ppt 的问题"

# 其他不必加入更新日志的记录以 chore: 开头
git commit -m "chore: 更新代码风格"

有问题

有任何问题,钉钉联系:方剑成

1.43.4

2 years ago

1.42.0

2 years ago

1.43.1

2 years ago

1.43.0

2 years ago

1.41.0

3 years ago

1.40.0

3 years ago

1.39.0

3 years ago

1.38.0

3 years ago

1.37.0

3 years ago

1.36.1

3 years ago

1.36.2

3 years ago

1.35.1

3 years ago

1.33.1

3 years ago

1.35.0

3 years ago

1.36.0

3 years ago

1.34.0

3 years ago

1.33.0

3 years ago

1.32.0

3 years ago

1.32.1

3 years ago

1.31.1

3 years ago

1.31.0

3 years ago

1.29.0

3 years ago

1.30.0

3 years ago

1.28.0

3 years ago

1.27.1

3 years ago

1.27.0

3 years ago

1.26.0

3 years ago

1.25.0

3 years ago

1.24.1

3 years ago

1.24.0

3 years ago

1.23.0

3 years ago

1.22.0

3 years ago

1.21.0

3 years ago

1.21.1

3 years ago

1.20.1

3 years ago

1.20.0

3 years ago

1.19.1

3 years ago

1.19.0

3 years ago

1.18.1

3 years ago

1.18.0

3 years ago

1.17.0

3 years ago

1.16.1

3 years ago

1.16.0

3 years ago

1.15.2

3 years ago

1.15.1

3 years ago

1.15.0

3 years ago

1.14.1

3 years ago

1.14.0

3 years ago

1.13.0

3 years ago

1.12.1

3 years ago

1.12.0

3 years ago

1.11.0

3 years ago

1.10.0

3 years ago

1.9.1

3 years ago

1.9.0

3 years ago

1.8.0

3 years ago

1.7.1

3 years ago

1.7.0

3 years ago

1.6.0

4 years ago

1.5.1

4 years ago

1.5.0

4 years ago

1.4.0

4 years ago

1.3.2

4 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago

0.1.4

4 years ago

0.1.2

4 years ago

0.1.3

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago

0.0.12

4 years ago

0.0.13

4 years ago

0.0.11

4 years ago

0.0.10

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago