UNPKG

websdk-test

Version:

efox-websdk适用不同版本工具调用api组件

93 lines (79 loc) 1.6 kB
## efox-websdk ## 概述 ``` efox-websdk统一调用sdk工具 ``` ## 安装 ``` npm install @efox/efox-websdk ``` ## 引入 ``` import WebSDk from 'websdk-test' const local = {} if (window.YY) { local.sdk = require('./cef').default local.env = 'isCef' } else { local.sdk = require('./web').default local.env = 'web' } const sdk = new WebSDk(local.sdk, local.env) const method = sdk.get export { method as default, sdk } export const WebSDKPlugin = { install (Vue) { Vue.prototype.$WebSDK = method } } ``` ## 使用 ``` WebSDK('sayHello', id, { name: 'input Name' }).then(res => {}); // => sayHello(id, object) WebSDK('os.versions[0].date.catch').then(res => {}).catch(err => {}); // => { os = { versions: [{ }]} }; process catch method ``` ## api 错误码 ``` { code: 1, error: 'key not found', env: local.env, key: keyName } ``` #### 其它关于jest ts #### 配置ts jest * 1 npm install --save-dev jest ts-jest @types/jest * 2 Modify your project's package.json ``` "jest": { "transform": { "^.+\\.tsx?$": "ts-jest" }, "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$", "moduleFileExtensions": [ "ts", "tsx", "js", "jsx", "json", "node" ] } ``` jest ts: https://github.com/kulshekhar/ts-jest #### test用例 ``` /root/__test__ 文件名: xxx.test.ts 执行: npm run test -> jest --verbose --colors --bail ``` ## 发布 ``` npm adduser 输入账号密码 更新package.json的版本 npm publish ```