diff --git a/.eslintignore b/.eslintignore index 26d6131f..d736e136 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,2 +1,10 @@ /vendor /node_modules +/cloudfunctions/ARDemo/cloud-functions-tools/test/svrkit-utils/example +/cloudfunctions/ARDemo/wx-server-sdk-wxg-service/index.js +/miniprogram/packageSkylineExamples +/miniprogram/_commons/0.js +/miniprogram/packageAPI/pages/ar/3dmarker-ar/protobuf +/miniprogram/packageAPI/components/tdesign-miniprogram +/miniprogram/packageAPI/pages/ar/gaussian-splatting/util/gl-matrix-min.js +/miniprogram/packageChatTool/components/tdesign-miniprogram \ No newline at end of file diff --git a/.eslintrc.js b/.eslintrc.js index 141fa110..9c06dd31 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,32 +1,32 @@ module.exports = { - 'extends': [ + extends: [ 'airbnb-base', 'plugin:promise/recommended' ], - 'parserOptions': { - 'ecmaVersion': 9, - 'ecmaFeatures': { - 'jsx': false + parserOptions: { + ecmaVersion: 9, + ecmaFeatures: { + jsx: false }, - 'sourceType': 'module' + sourceType: 'module' }, - 'env': { - 'es6': true, - 'node': true, - 'jest': true + env: { + es6: true, + node: true, + jest: true }, - 'plugins': [ + plugins: [ 'import', 'node', 'promise' ], - 'rules': { + rules: { 'arrow-parens': 'off', 'comma-dangle': [ 'error', 'only-multiline' ], - 'complexity': ['error', 10], + complexity: ['error', 10], 'func-names': 'off', 'global-require': 'off', 'handle-callback-err': [ @@ -36,9 +36,9 @@ module.exports = { 'import/no-unresolved': [ 'error', { - 'caseSensitive': true, - 'commonjs': true, - 'ignore': ['^[^.]'] + caseSensitive: true, + commonjs: true, + ignore: ['^[^.]'] } ], 'import/prefer-default-export': 'off', @@ -58,13 +58,13 @@ module.exports = { 'node/process-exit-as-throw': 'error', 'object-curly-spacing': [ 'error', - 'never' + 'always' ], 'operator-linebreak': [ 'error', 'after', { - 'overrides': { + overrides: { ':': 'before', '?': 'before' } @@ -77,23 +77,23 @@ module.exports = { 1, 'as-needed', { - 'unnecessary': true + unnecessary: true } ], - 'semi': [ + semi: [ 'error', 'never' ] }, - 'globals': { - 'window': true, - 'document': true, - 'App': true, - 'Page': true, - 'Component': true, - 'Behavior': true, - 'wx': true, - 'worker': true, - 'getApp': true + globals: { + window: true, + document: true, + App: true, + Page: true, + Component: true, + Behavior: true, + wx: true, + worker: true, + getApp: true } } diff --git a/.github/workflows/pr-lint-check.yml b/.github/workflows/pr-lint-check.yml new file mode 100644 index 00000000..ca2096cb --- /dev/null +++ b/.github/workflows/pr-lint-check.yml @@ -0,0 +1,39 @@ +name: PR Lint Check + +on: + pull_request: + branches: [ master ] + +jobs: + eslint-changed: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + + - name: Install dependencies + run: npm install + + - name: Get changed files + id: changed-files + uses: tj-actions/changed-files@v46 + with: + since_last_remote_commit: 'true' + + - name: Filter JavaScript files + id: filter-js + run: | + changed_js_files=$(echo '${{ steps.changed-files.outputs.all_changed_files }}' | grep -E '\.(js|ts|jsx|tsx)$' || true) + echo "changed_js_files=${changed_js_files}" >> $GITHUB_OUTPUT + + - name: Run ESLint on changed JS files + if: ${{ steps.filter-js.outputs.changed_js_files != '' }} + run: | + echo "Changed JS files: ${{ steps.filter-js.outputs.changed_js_files }}" + npx eslint ${{ steps.filter-js.outputs.changed_js_files }} diff --git a/.gitmodules b/.gitmodules index 2f398a69..6ccb8b5f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "miniprogram/packageSkylineExamples"] path = miniprogram/packageSkylineExamples - url = git@github.com:wechat-miniprogram/awesome-skyline.git + url = https://github.com/wechat-miniprogram/awesome-skyline.git diff --git a/build/ci.js b/build/ci.js new file mode 100644 index 00000000..00c2998c --- /dev/null +++ b/build/ci.js @@ -0,0 +1,57 @@ +import path from 'path' +import { fileURLToPath } from 'url' +import fs from 'fs' +import ci from 'miniprogram-ci' +import packageJson from '../package.json' with { type: 'json' } +const __filename = fileURLToPath(import.meta.url) +const __dirname = path.dirname(__filename) +const privateKeyPath = path.resolve(__dirname, './key') + +// 检查私钥文件是否已存在 +if (!fs.existsSync(privateKeyPath)) { + const privateKeyContent = process.env.WX_PRIVATE_KEY + if (!privateKeyContent) { + throw new Error('未找到私钥内容,请确保已正确配置 GitHub Secrets') + } + console.log('>>>>写入私钥文件:', privateKeyPath); + fs.writeFileSync(privateKeyPath, privateKeyContent) +} + +const project = new ci.Project({ + appid: 'wxe5f52902cf4de896', + type: 'miniProgram', + projectPath: path.resolve(__dirname, '../'), + privateKeyPath: path.resolve(__dirname, './key'), + ignores: [path.resolve(__dirname, '../miniprogram/node_modules/**/*')] +}) +const robotNumber = 2 +const params = { + onProgressUpdate: console.log, + robot: robotNumber, + version: packageJson.version, + desc: packageJson.bundleDescription, + setting: { + es7: true, + minifyJS: true, + minifyWXML: true, + minifyWXSS: true, + codeProtect: false, + autoPrefixWXSS: true, + ignoreUploadUnusedFiles: true + }, +} +await ci.packNpm(project, {}) +ci.upload({ + project, + ...params +}).then(res => { + console.debug('>>>>upload res', res) +}).catch(err => { + console.error('>>>>upload error', err) + throw err +}).finally(() => { + // 删除临时私钥文件 + fs.unlinkSync(privateKeyPath) +}) + + diff --git a/cloudfunctions/ARDemo/cloud-functions-tools/cli/svrkit-utils-template.js b/cloudfunctions/ARDemo/cloud-functions-tools/cli/svrkit-utils-template.js index 21a4a144..d1c3ae70 100644 --- a/cloudfunctions/ARDemo/cloud-functions-tools/cli/svrkit-utils-template.js +++ b/cloudfunctions/ARDemo/cloud-functions-tools/cli/svrkit-utils-template.js @@ -1,4 +1,3 @@ - function generate(options) { if (!options) { throw new Error('options must be provided') @@ -6,7 +5,7 @@ function generate(options) { const { serviceName, funcName, data } = options - const serviceConfig = config.find(c => c.serviceName === serviceName) + const serviceConfig = config.find(c => c.serviceName === serviceName) if (!serviceConfig) { throw new Error('service not found') } @@ -38,7 +37,7 @@ function generate(options) { if (!reqProtoJSON.fields[key]) { throw new Error(`'${key}' doesn't exist in '${reqProtoName}' proto, valid keys are ${Object.keys(reqProtoJSON.fields)}`) } - } + } } else { throw new Error('data must be object') } @@ -91,7 +90,7 @@ function generateV2(options) { if (!reqProtoJSON.fields[key]) { throw new Error(`'${key}' doesn't exist in '${reqProtoName}' proto, valid keys are ${Object.keys(reqProtoJSON.fields)}`) } - } + } } else { throw new Error('data must be object') } diff --git a/cloudfunctions/ARDemo/cloud-functions-tools/cli/svrkit-utils.js b/cloudfunctions/ARDemo/cloud-functions-tools/cli/svrkit-utils.js index a1f33a6a..79ed1198 100644 --- a/cloudfunctions/ARDemo/cloud-functions-tools/cli/svrkit-utils.js +++ b/cloudfunctions/ARDemo/cloud-functions-tools/cli/svrkit-utils.js @@ -3,7 +3,7 @@ const path = require('path') const yargs = require('yargs') const chalk = require('chalk') const debug = require('debug')('cli') -const pbjs = require("protobufjs/cli/pbjs") +const pbjs = require('protobufjs/cli/pbjs') const log = (...msg) => { console.log(chalk.blue('svrkit-utils'), ...msg) @@ -50,7 +50,7 @@ function main() { throw err } - let staticModuleContent = fs.readFileSync(staticModuleFilePath, 'utf8') + const staticModuleContent = fs.readFileSync(staticModuleFilePath, 'utf8') fs.writeFileSync(staticModuleFilePath, `// #lizard forgives ${staticModuleContent}`, 'utf8') @@ -95,4 +95,3 @@ ${protoUtils} module.exports = { main, } - diff --git a/cloudfunctions/ARDemo/index.js b/cloudfunctions/ARDemo/index.js index a1c41299..e1acb1df 100644 --- a/cloudfunctions/ARDemo/index.js +++ b/cloudfunctions/ARDemo/index.js @@ -11,13 +11,13 @@ exports.main = async (event, context) => { const wxContext = cloud.getWXContext() const bizuin = wxContext.APPUIN switch (event.type) { - case "GenerateARModel": + case 'GenerateARModel': return await cloud.callWXSvrkit({ pbInstance: svrkitUtils.generate({ - serviceName: "Mmbizwxaintpar", - funcName: "GenerateARModel", + serviceName: 'Mmbizwxaintpar', + funcName: 'GenerateARModel', data: { - bizuin: bizuin, + bizuin, name: event.name, url: event.url, algoType: event.algoType, @@ -26,14 +26,14 @@ exports.main = async (event, context) => { }, }), timeout: 30000, - }); - case "GetARModel": + }) + case 'GetARModel': return await cloud.callWXSvrkit({ pbInstance: svrkitUtils.generate({ - serviceName: "Mmbizwxaintpar", - funcName: "GetARModel", + serviceName: 'Mmbizwxaintpar', + funcName: 'GetARModel', data: { - bizuin: bizuin, + bizuin, cosid: event.cosid, modelType: event.modelType, needData: event.needData, @@ -42,7 +42,7 @@ exports.main = async (event, context) => { }, }), timeout: 30000, - }); + }) // GetARModelList 废弃,完全依赖本地缓存 // case "GetARModelList": // return await cloud.callWXSvrkit({ @@ -58,5 +58,4 @@ exports.main = async (event, context) => { // timeout: 30000, // }); } - -} \ No newline at end of file +} diff --git a/cloudfunctions/ARDemo/svrkit-utils.js b/cloudfunctions/ARDemo/svrkit-utils.js index 941b9848..d50911b6 100644 --- a/cloudfunctions/ARDemo/svrkit-utils.js +++ b/cloudfunctions/ARDemo/svrkit-utils.js @@ -1,23 +1,23 @@ - const config = require('./svrkit.config.js') const proto = require('./svrkit-utils.static.js') const protoJSON = require('./svrkit-utils.static.json') + function getProto(proto, serviceName, protoName) { if (proto[protoName]) { - return proto[protoName]; + return proto[protoName] } if (proto[serviceName] && proto[serviceName][protoName]) { - return proto[serviceName][protoName]; + return proto[serviceName][protoName] } - /** 处理 mmpayolcirclemodel.QueryActivityReq 的形式*/ + /** 处理 mmpayolcirclemodel.QueryActivityReq 的形式 */ const [realServiceName, realProtoName] = protoName.split('.') if (proto[realServiceName]) { return proto[realServiceName][realProtoName] } - return undefined; + return undefined } function generate(options) { @@ -37,14 +37,14 @@ function generate(options) { } const reqProtoName = serviceConfig.functions[funcName].req - const reqProto = getProto(proto, serviceName, reqProtoName); + const reqProto = getProto(proto, serviceName, reqProtoName) if (!reqProto) { throw new Error('request proto not found') } const resProtoName = serviceConfig.functions[funcName].res - const resProto = resProtoName && getProto(proto, serviceName, resProtoName); + const resProto = resProtoName && getProto(proto, serviceName, resProtoName) const reqProtoVerifyErr = reqProto.verify(data) if (reqProtoVerifyErr) { @@ -133,4 +133,3 @@ module.exports = { generate, generateV2, } - diff --git a/cloudfunctions/ARDemo/svrkit.config.js b/cloudfunctions/ARDemo/svrkit.config.js index 962f5499..87aa4070 100644 --- a/cloudfunctions/ARDemo/svrkit.config.js +++ b/cloudfunctions/ARDemo/svrkit.config.js @@ -31,4 +31,4 @@ module.exports = [ } } } -] \ No newline at end of file +] diff --git a/cloudfunctions/ARDemo/wx-server-sdk-wxg-service/README.md b/cloudfunctions/ARDemo/wx-server-sdk-wxg-service/README.md deleted file mode 100644 index 094c39f6..00000000 --- a/cloudfunctions/ARDemo/wx-server-sdk-wxg-service/README.md +++ /dev/null @@ -1,326 +0,0 @@ -# WXG Service for Mini Program Server SDK - -## wx-server-sdk 插件使用方式 - -需同时安装依赖 `wx-server-sdk` 和 `@tencent/wx-server-sdk-wxg-service`,后者必须使用 `tnpm` 安装。 - -注册 SDK 插件的示例代码: - -```js -const cloud = require('wx-server-sdk') -const wxgService = require('@tencent/wx-server-sdk-wxg-service') - -// 将 wxg service 注册到 cloud 上,获得 callWXSvrkit, callTencentInnerAPI 等内部接口 -cloud.registerService(wxgService) - -exports.main = async (event, context) => { - // 现在可以使用 callWXSvrkit 等内部接口了 - cloud.callWXSvrkit({ - // .... - }) -} -``` - -## 兼容性说明 - -从 `0.6.1` 起,需搭配 `wx-server-sdk` `2.0.3` 或以上使用。 - -## 接口 - -WXG Service 包含以下接口 - -### callTencentInnerAPI:调用腾讯内部服务 - -```js -const cloud = require('wx-server-sdk') -const wxgService = require('@tencent/wx-server-sdk-wxg-service') - -// 将 wxg service 注册到 cloud 上,获得 callWXSvrkit 接口 -cloud.registerService(wxgService) - -exports.main = async (event, context) => { - const callResult = await cloud.callTencentInnerAPI({ - cmdid: 12345, // 必填 - modid: 67890, // 必填 - path: '/aaa/bbb?xxx=1', // 必填,除域名外 URL 路径。URL 参数选填 - https: false, // 选填,是否使用 https - method: 'post', // 必填,HTTP Method - // 选填,HTTP 头部 - headers: { - 'Content-Type': 'application/json' - }, - // 选填,body 可以是 string 类型或 Buffer 类型 - body: JSON.stringify({ - x: 1, - y: 2, - }), - /** - * autoParse: - * 是否自动 parse 回包包体,如果是,则: - * 在 content-type 为 application/json 时自动 parse JSON - * 在 content-type 为 text/plain 时自动转为 string - * 其余情况不 parse,返回原始包体 buffer - */ - autoParse: true, - }) - - console.log(callResult) - - /** - * callResult: - * { - * errCode: 0, - * errMsg: 'callTencetnInnerAPI:ok', - * contentType: 'application/json', // 回包 content-type - * body: { x: 1 }, // 回包 http response body - * statusCode: 200, // 回包 http status code - * rawHeaders: [ // 回包 http headers - * { - * key: 'content-type', - * value: 'application' - * }, - * // ... - * ] - * } - */ - return callResult -} -``` - -### callWXSvrkit:调用微信 Svrkit 服务 - -供 WXG 内部小程序通过云函数调用微信 svrkit 模块。 - -因为 svrkit 的数据交换协议是 `protobuf`,且 svrkit 的模块调用需要一些模块信息,因此为了简化前端调用方式、省去接口数据处理和调用信息处理(pb 序列化与反序列化、模块信息传入)、我们也提供了一个 `@tencent/cloud-functions-tools` 工具用于将 svrkit 的调用流程配置化、标准化,开发者只需填写配置文件和放置 `proto` 文件,即可用工具生成辅助模块,实际调用时即可传入 `JSON` 对象获取 `JSON` 返回值。 - - -示例云函数已放置在公开的内部 git 仓库,仓库 `cloudfunctions` 目录下有两个子目录分别是 `svrkit-echo` 和 `svrkit-check-developer`这两个示例云函数,仓库地址 :https://git.code.oa.com/mp-public/cloud-demos - - -### Step 1:安装 `@tencent/cloud-functions-tools` - -首先在需要使用该能力的云函数的目录下安装 `@tencent/cloud-functions-tools`: - -```shell -npm install --save-dev @tencent/cloud-functions-tools@latest -``` - -注意,云函数中同时需安装 `wx-server-sdk` 和 `@tencent/wx-server-sdk-wxg-service` - -```bash -npm install --save wx-server-sdk@latest -npm install --save @tencent/wx-server-sdk-wxg-service@latest -``` - - - -### Step 2:配置 - -在云函数目录下建立 `svrkit.config.js` 文件,用于填写 `svrkit` 调用的配置信息,并放置好相应 proto 文件,示例如下(从后台的原始 pb 文件提取模块调用信息的方法参见底部的[svrkit 调用信息提取](#extract_pb_info)): - -```js -// 模块导出一个数组,每个元素是一个模块配置项 -module.exports = [ - { - // 模块对应的 proto 文件相对于该文件的路径 - proto: './proto/mmbizwxaqbasedemo.proto', - // 模块 service name - serviceName: 'MMBizWxaQbaseDemo', - // 模块 magic 数字 - magic: 18501, - // 模块导出的接口方法 - functions: { - // 接口 EchoTest 的名字及其对应的接口调用信息 - EchoTest: { - // 接口的 cmdid - cmdid: 1, - // 接口的 request 对应的 protobuf message 名字,需在 proto 文件中定义 - req: 'EchoTestRequest', - // 接口的 response 对应的 protobuf message 名字,需在 proto 文件中定义 - res: 'EchoTestResponse', - }, - // 接口 CheckWxaDeveloper 的名字及其对应的接口调用信息 - CheckWxaDeveloper: { - cmdid: 2, - req: 'CheckWxaDeveloperRequest', - } - } - } -] -``` - - - -示例的 `./proto/mmbizwxaqbasedemo.proto` 文件: - -``` -message MessageData -{ - optional string Data = 1; -} - -message EchoTestRequest -{ - required bool OpenTime = 1; // 是否需要服务端返回时间戳,required 必填 - - // 以下 optional 字段如果有填,在Resp中返回对应字段 - optional int32 IntData = 2; - optional string StringData = 3; - repeated uint32 UintListData = 4; - optional MessageData MessageData = 5; -} - -message EchoTestResponse -{ - optional uint32 TimeStamp = 1; - - optional int32 IntRespData = 2; - optional string StringRespData = 3; - repeated uint32 UintListRespData = 4; - optional MessageData MessageRespData = 5; -} - -// 校验是否为小程序开发者, 接口返回:0 是,1 否 -message CheckWxaDeveloperRequest -{ - optional uint32 appuin = 1; - optional uint32 useruin = 2; -} -``` - - - -### Step 3:用工具生成辅助类 - -用 `@tencent/cloud-functions-tools` 提供的工具根据 `svrkit.config.js` 生成辅助的 `svrkit-utils.js` 模块: - -```bash -# 在云函数目录执行以下命令,--config (或 -c) 对应的路径如果不同则替换为自己的路径 -./node_modules/.bin/svrkit-utils --config ./svrkit.config.js -# 如需自定义输出文件的路径,可以传入 --output (或 -o) -./node_modules/.bin/svrkit-utils --config ./svrkit.config.js --output ./svrkit-utils.js -``` - -> 注:可用此命令查看 cloud-functions-tools 的用法:./node_modules/.bin/svrkit-utils -h - -可以在 `package.json` 中添加一个 `script` 命令自动化这个流程: - -```json -{ - "scripts": { - "svrkit": "svrkit-utils --config ./svrkit.config.js --output ./svrkit-utils.js" - } -} -``` - -然后之后就可以用如下命令生成 js 模块了: - -```bash -npm run svrkit -``` - - - -### Step 4:发起调用 - - - -用 `callWXSvrkit` 方法配合生成的 `svrkit-utils.js` 模块发起 svrkit 调用 - - - -**callWXSvrkit 接口参数说明** - -| 参数 | 类型 | 必填 | 说明 | -| ---------- | ---- | ---- | --------------------------------------------------- | -| pbInstance | | 是 | 通过 `svrkit-utils.js` 的 `generate` 方法生成的对象 | -| timeout | number | 否 | 超时失败时间 | - -**callWXSvrkit 接口返回值说明** - -| 参数 | 类型 | 说明 | 最低版本 | -| -------------- | ------ | ------------------------------------------------------------ | -------- | -| errMsg | String | 通用返回结果 | | -| ret | Number | svrkit 模块调用结果,0 表示成功调到了目标模块,-306 表示小程序未在内部小程序登记平台登记,-307 表示小程序没有调用目标模块的权限 | | -| result | Number | 目标模块的调用返回码 | | -| respBody | Object | 目标模块返回的最终 JSON 对象 | | -| respBodyBuffer | Buffer | 目标模块返回的 pb buffer,有 respBody 可不用关注 | | - - - -调用代码示例: - -```js -const cloud = require('wx-server-sdk') -const wxgService = require('@tencent/wx-server-sdk-wxg-service') - -cloud.registerService(wxgService) -cloud.init() - -const svrkitUtils = require('./svrkit-utils.js') - -exports.main = async (event, context) => { - - return await cloud.callWXSvrkit({ - pbInstance: svrkitUtils.generate({ - serviceName: 'MMBizWxaQbaseDemo', - funcName: 'EchoTest', - data: { - OpenTime: event.OpenTime || true, - IntData: event.IntData || 10, - StringData: event.StringData || 'default_string', - UintListData: event.UintListData || [1, 2, 3], - MessageData: event.MessageData || { - Data: 'default_data_string' - }, - } - }) - }) - -} -``` - -预期返回: - -```js -{ - "ret": 0, - "result": 0, - "respBodyBuffer": Buffer, - "respBody": { - "TimeStamp": 1543501760, - "IntRespData": 10, - "StringRespData": "default_string", - "UintListRespData": [ - 1, - 2, - 3 - ], - "MessageRespData": { - "Data": "default_data_string" - } - }, - "errMsg": "callWXSvrkit:ok" -} -``` - -调用数据流如图: - -![svrkit 调用数据流](http://km.oa.com/files/photos/pictures//20181130//1543559018_58.png) - - -从后台原始 svrkit pb 信息中提取模块调用信息: - -1. `message` 定义的是 pb 数据接口体的定义,通常即是请求包与回包的定义 -2. `service` 定义的是 svrkit 模块的 `serviceName` -3. `tlvpickle.Magic` 定义的是模块 `magic` -4. `rpc` 后跟的词即是模块暴露的接口方法名,即 `funcName` -5. `rpc` 定义中包含了请求体结构和返回体结构,如 `EchoTest` 方法的请求体结构为 `EchoTestRequest`,返回体结构为 `EchoTestResponse` -6. `tlvpickle.SKBuiltinEmpty_PB` 是特殊的结构体,表示空结构体 - -![svrkit 模块调用信息](http://km.oa.com/files/photos/captures/201812/1543846169_62_w1668_h2228.png) - - -### callSvrkit: 调用微信 Svrkit 服务 - -> 已废弃,请使用 callWXSvrkit diff --git a/gulpfile.js b/gulpfile.js index ccd846f6..6c41caac 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -13,74 +13,75 @@ gulp.task('transform-css-vars', () => { cssvars({ preserve: false, variables: { - "--weui-BTN-DISABLED-FONT-COLOR": "rgba(0, 0, 0, .2)", - "--weui-BTN-DEFAULT-BG": "#f2f2f2", - "--weui-BTN-DEFAULT-COLOR": "#06ae56", - "--weui-BTN-DEFAULT-ACTIVE-BG": "#e6e6e6", - "--weui-DIALOG-LINE-COLOR": "rgba(0, 0, 0, .1)", - "--weui-BG-0": "#ededed", - "--weui-BG-1": "#f7f7f7", - "--weui-BG-2": "#fff", - "--weui-BG-3": "#f7f7f7", - "--weui-BG-4": "#4c4c4c", - "--weui-BG-5": "#fff", - "--weui-FG-0": "rgba(0, 0, 0, .9)", - "--weui-FG-HALF": "rgba(0, 0, 0, .9)", - "--weui-FG-1": "rgba(0, 0, 0, .5)", - "--weui-FG-2": "rgba(0, 0, 0, .3)", - "--weui-FG-3": "rgba(0, 0, 0, .1)", - "--weui-RED": "#fa5151", - "--weui-ORANGE": "#fa9d3b", - "--weui-YELLOW": "#ffc300", - "--weui-GREEN": "#91d300", - "--weui-LIGHTGREEN": "#95ec69", - "--weui-BRAND": "#07c160", - "--weui-BLUE": "#10aeff", - "--weui-INDIGO": "#1485ee", - "--weui-PURPLE": "#6467f0", - "--weui-WHITE": "#fff", - "--weui-LINK": "#576b95", - "--weui-TEXTGREEN": "#06ae56", - "--weui-FG": "#000", - "--weui-BG": "#fff", - "--weui-TAG-TEXT-ORANGE": "#fa9d3b", - "--weui-TAG-BACKGROUND-ORANGE": "rgba(250, 157, 59, .1)", - "--weui-TAG-TEXT-GREEN": "#06ae56", - "--weui-TAG-BACKGROUND-GREEN": "rgba(6, 174, 86, .1)", - "--weui-TAG-TEXT-BLUE": "#10aeff", - "--weui-TAG-BACKGROUND-BLUE": "rgba(16, 174, 255, .1)", - "--weui-TAG-TEXT-BLACK": "rgba(0, 0, 0, .5)", - "--weui-TAG-BACKGROUND-BLACK": "rgba(0, 0, 0, .05)", - "--weui-BG-COLOR-ACTIVE": "#ececec", - "--height": "44px", - "--right": "95px", + '--weui-BTN-DISABLED-FONT-COLOR': 'rgba(0, 0, 0, .2)', + '--weui-BTN-DEFAULT-BG': '#f2f2f2', + '--weui-BTN-DEFAULT-COLOR': '#06ae56', + '--weui-BTN-DEFAULT-ACTIVE-BG': '#e6e6e6', + '--weui-DIALOG-LINE-COLOR': 'rgba(0, 0, 0, .1)', + '--weui-BG-0': '#ededed', + '--weui-BG-1': '#f7f7f7', + '--weui-BG-2': '#fff', + '--weui-BG-3': '#f7f7f7', + '--weui-BG-4': '#4c4c4c', + '--weui-BG-5': '#fff', + '--weui-FG-0': 'rgba(0, 0, 0, .9)', + '--weui-FG-HALF': 'rgba(0, 0, 0, .9)', + '--weui-FG-1': 'rgba(0, 0, 0, .5)', + '--weui-FG-2': 'rgba(0, 0, 0, .3)', + '--weui-FG-3': 'rgba(0, 0, 0, .1)', + '--weui-RED': '#fa5151', + '--weui-ORANGE': '#fa9d3b', + '--weui-YELLOW': '#ffc300', + '--weui-GREEN': '#91d300', + '--weui-LIGHTGREEN': '#95ec69', + '--weui-BRAND': '#07c160', + '--weui-BLUE': '#10aeff', + '--weui-INDIGO': '#1485ee', + '--weui-PURPLE': '#6467f0', + '--weui-WHITE': '#fff', + '--weui-LINK': '#576b95', + '--weui-TEXTGREEN': '#06ae56', + '--weui-FG': '#000', + '--weui-BG': '#fff', + '--weui-TAG-TEXT-ORANGE': '#fa9d3b', + '--weui-TAG-BACKGROUND-ORANGE': 'rgba(250, 157, 59, .1)', + '--weui-TAG-TEXT-GREEN': '#06ae56', + '--weui-TAG-BACKGROUND-GREEN': 'rgba(6, 174, 86, .1)', + '--weui-TAG-TEXT-BLUE': '#10aeff', + '--weui-TAG-BACKGROUND-BLUE': 'rgba(16, 174, 255, .1)', + '--weui-TAG-TEXT-BLACK': 'rgba(0, 0, 0, .5)', + '--weui-TAG-BACKGROUND-BLACK': 'rgba(0, 0, 0, .05)', + '--weui-BG-COLOR-ACTIVE': '#ececec', + '--height': '44px', + '--right': '95px', }, preserveInjectedVariables: false, }) ] return gulp.src([ - './miniprogram/app.wxss', - './miniprogram/common/common.wxss', - './miniprogram/page/common/common.wxss', - './miniprogram/page/common/index.wxss', - './miniprogram/page/component/index.wxss', - './miniprogram/page/cloud/index.wxss', - './miniprogram/page/API/index.wxss', - './miniprogram/page/extend/index.wxss', - './miniprogram/packageComponent/pages/canvas/canvas-2d/canvas-2d.wxss', - ]) - .pipe(gulpIgnore.exclude( - file => { - try { - fs.accessSync(file.path.replace(/\.wxss$/, '-skyline.wxss')) - } catch(e) { - return false - } - return true - })) - .pipe(postcss(plugins)) - .pipe(replace(/\:root ?{}\n/g, '')) - .pipe(gulpIf(file => file.path.includes('miniprogram/page/common'), rename({suffix: '-skyline'}))) - .pipe(gulpIf(file => file.path.includes('miniprogram/common'), rename({suffix: '-skyline'}))) - .pipe(gulp.dest(file => file.base)) + './miniprogram/app.wxss', + './miniprogram/common/common.wxss', + './miniprogram/page/common/common.wxss', + './miniprogram/page/common/index.wxss', + './miniprogram/page/component/index.wxss', + './miniprogram/page/cloud/index.wxss', + './miniprogram/page/API/index.wxss', + './miniprogram/page/extend/index.wxss', + './miniprogram/packageComponent/pages/canvas/canvas-2d/canvas-2d.wxss', + ]) + .pipe(gulpIgnore.exclude( + file => { + try { + fs.accessSync(file.path.replace(/\.wxss$/, '-skyline.wxss')) + } catch (e) { + return false + } + return true + } + )) + .pipe(postcss(plugins)) + .pipe(replace(/\:root ?{}\n/g, '')) + .pipe(gulpIf(file => file.path.includes('miniprogram/page/common'), rename({ suffix: '-skyline' }))) + .pipe(gulpIf(file => file.path.includes('miniprogram/common'), rename({ suffix: '-skyline' }))) + .pipe(gulp.dest(file => file.base)) }) diff --git a/miniprogram/app-bar/index.js b/miniprogram/app-bar/index.js index 9ee282fd..2000ecc7 100644 --- a/miniprogram/app-bar/index.js +++ b/miniprogram/app-bar/index.js @@ -7,4 +7,4 @@ Component({ data: { showAppbar: false } -}) \ No newline at end of file +}) diff --git a/miniprogram/app.js b/miniprogram/app.js index d9599608..3262bf86 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -45,20 +45,28 @@ App({ traceUser: true, }) } - // skyline - const systemInfo = wx.getSystemInfoSync() - console.log('@@@ systemInfo ', systemInfo) - Object.assign(this.globalData, systemInfo) + const getSystemInfo = [ + 'getSystemSetting', + 'getAppAuthorizeSetting', + 'getDeviceInfo', + 'getAppBaseInfo', + 'getWindowInfo' + ] + + getSystemInfo.forEach(apiName => { + if (wx[apiName]) { + Object.assign(this.globalData, wx[apiName]()) + } + }) // eslint-disable-next-line promise/always-return require.async('./packageSkyline/common/custom-route/index.js').then(utils => { console.log('--------begin installRouteBuilder') utils.installRouteBuilder() // 'common' - }).catch(({mod, errMsg}) => { + }).catch(({ mod, errMsg }) => { console.error(`installRouteBuilder path: ${mod}, ${errMsg}`) }) }, - onShow(opts) { console.log('App Show', opts) console.log('USER_DATA_PATH', wx.env.USER_DATA_PATH) @@ -67,7 +75,7 @@ App({ onHide() { console.log('App Hide') }, - onThemeChange({theme}) { + onThemeChange({ theme }) { this.globalData.theme = theme themeListeners.forEach((listener) => { listener(theme) @@ -85,7 +93,7 @@ App({ } }, globalData: { - theme: wx.getSystemInfoSync().theme, + theme: wx.getAppBaseInfo().theme, hasLogin: false, openid: null, iconTabbar: '/page/extend/images/icon_tabbar.png', diff --git a/miniprogram/app.json b/miniprogram/app.json index 49c73295..9c844e65 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -44,11 +44,14 @@ "pages/view/sticky/sticky-section/sticky-section", "pages/view/movable-view/movable-view", "pages/view/cover-view/cover-view", + "pages/view/match-media/match-media", + "pages/view/page-container/page-container", "pages/view/sticky/sticky", "pages/content/text/text", "pages/content/icon/icon", "pages/content/progress/progress", "pages/content/rich-text/rich-text", + "pages/content/selection/selection", "pages/form/button/button", "pages/form/checkbox/checkbox", "pages/form/form/form", @@ -89,6 +92,7 @@ "pages/api/get-user-info/get-user-info", "pages/api/request-payment/request-payment", "pages/api/jump/jump", + "pages/api/official-account/official-account", "pages/api/share/share", "pages/api/share-button/share-button", "pages/api/custom-message/custom-message", @@ -259,8 +263,7 @@ "pages/adapt/pagination/pagination", "pages/adapt/freelayout/freelayout", "pages/adapt/layeredpresentation/layeredpresentation", - "pages/adapt/horizontalexpansion/horizontalexpansion", - "pages/adapt/customscreenvalidation/customscreenvalidation" + "pages/adapt/horizontalexpansion/horizontalexpansion" ] }, { @@ -294,6 +297,18 @@ "examples/app-bar/pages/detail/index" ] }, + { + "root": "packageSkylineRouter", + "pages": [ + "pages/preset-router/index/index", + "pages/preset-router/list/index", + "pages/open-container/index/index", + "pages/open-container/detail/index", + "pages/open-container/other/index", + "pages/page-return-gesture/index/index" + ], + "renderer": "skyline" + }, { "root": "packageXRFrame", "pages": [ @@ -398,6 +413,12 @@ "packageComponent" ] }, + "page/animation/index": { + "network": "all", + "packages": [ + "packageSkylineRouter" + ] + }, "page/API/index": { "network": "all", "packages": [ @@ -507,7 +528,6 @@ "sdkVersionEnd": "15.255.255" } }, - "renderer": "skyline", "componentFramework": "glass-easel", "appBar": {}, "supportedMaterials": [ @@ -520,7 +540,9 @@ ], "multiSelectSupportedMaterials": [ { - "materialType": ["image/*", "text/message"], + "materialType": [ + "image/*" + ], "desc": "聊天内容长按多选打开", "path": "packageAPI/pages/chattool/material_open/material_open", "scopes": [] diff --git a/miniprogram/component/navigation-bar/navigation-bar.js b/miniprogram/component/navigation-bar/navigation-bar.js index 4335baa6..2408512f 100644 --- a/miniprogram/component/navigation-bar/navigation-bar.js +++ b/miniprogram/component/navigation-bar/navigation-bar.js @@ -1,85 +1,80 @@ +const app = getApp().globalData Component({ options: { - multipleSlots: true // 在组件定义时的选项中启用多slot支持 + styleIsolation: 'apply-shared', // 表示页面 wxss 样式将影响到自定义组件,但自定义组件 wxss 中指定的样式不会影响页面 + multipleSlots: true // 在组件定义时的选项中启用多slot支持 }, /** * 组件的属性列表 */ properties: { - extClass: { - type: String, - value: '' - }, - title: { - type: String, - value: '' - }, - background: { - type: String, - value: '' - }, - color: { - type: String, - value: '' - }, - back: { - type: Boolean, - value: true - }, - loading: { - type: Boolean, - value: false - }, - animated: { - // 显示隐藏的时候opacity动画效果 - type: Boolean, - value: true - }, - show: { - // 显示隐藏导航,隐藏的时候navigation-bar的高度占位还在 - type: Boolean, - value: true, - observer: '_showChange' - }, - // back为true的时候,返回的页面深度 - delta: { - type: Number, - value: 1 - } + extClass: { + type: String, + value: '' + }, + title: { + type: String, + value: '' + }, + background: { + type: String, + value: '' + }, + color: { + type: String, + value: '' + }, + back: { + type: Boolean, + value: true + }, + loading: { + type: Boolean, + value: false + }, + animated: { + // 显示隐藏的时候opacity动画效果 + type: Boolean, + value: true + }, + show: { + // 显示隐藏导航,隐藏的时候navigation-bar的高度占位还在 + type: Boolean, + value: true, + observer: '_showChange' + }, + // back为true的时候,返回的页面深度 + delta: { + type: Number, + value: 1 + } }, /** - * 组件的初始数据 - */ + * 组件的初始数据 + */ data: { - displayStyle: '' + displayStyle: '' }, attached() { const isSupport = !!wx.getMenuButtonBoundingClientRect const rect = wx.getMenuButtonBoundingClientRect - ? wx.getMenuButtonBoundingClientRect() - : null - const isSkyline = this.renderer ==='skyline' - wx.getSystemInfo({ - success: (res) => { - const ios = !!(res.system.toLowerCase().search('ios') + 1) - this.setData({ - ios, - statusBarHeight: res.statusBarHeight, - // skyline defaultContentBox:true ; webview border-box - navBarHeight: rect.bottom - rect.top + 10 + ( isSkyline ? 0 : res.statusBarHeight), - innerWidth: isSupport ? `width:${rect.left}px` : '', - innerPaddingRight: isSupport - ? `padding-right:${res.windowWidth - rect.left}px` - : '', - leftWidth: isSupport ? `width:${res.windowWidth - rect.left}px` : '', - theme: res.theme || 'light', - }) - } + ? wx.getMenuButtonBoundingClientRect() + : null + const isSkyline = this.renderer === 'skyline' + this.setData({ + ios: !!(app.system.toLowerCase().search('ios') + 1), + theme: app.theme || 'light', + statusBarHeight: app.statusBarHeight, + navBarHeight: rect.bottom - rect.top + 10 + (isSkyline ? 0 : app.statusBarHeight), + innerWidth: isSupport ? `width:${rect.left}px` : '', + innerPaddingRight: isSupport + ? `padding-right:${app.windowWidth - rect.left}px` + : '', + leftWidth: isSupport ? `width:${app.windowWidth - rect.left}px` : '', }) - if (wx.onThemeChange) { - wx.onThemeChange(({theme}) => { - this.setData({theme}) + wx.onThemeChange(({ theme }) => { + this.setData({ theme }) }) } }, @@ -89,42 +84,39 @@ Component({ } }, /** - * 组件的方法列表 - */ + * 组件的方法列表 + */ methods: { - _showChange(show) { - const animated = this.data.animated - let displayStyle = '' - if (animated) { - displayStyle = `opacity: ${ - show ? '1' : '0' - };-webkit-transition:opacity 0.5s;transition:opacity 0.5s;` - } else { - displayStyle = `display: ${show ? '' : 'none'}` - } - this.setData({ - displayStyle - }) - }, - back() { - const data = this.data - console.log('---------222',getCurrentPages().length) - if (data.delta) { - wx.navigateBack({ - delta: data.delta - }) - } - // 如果是直接打开的,就默认回首页 - if (getCurrentPages().length == 1) { - console.log('---------333') - wx.switchTab({ - url: '/page/component/index', - complete: (res) => { - console.log(res) - } - }) + _showChange(show) { + const animated = this.data.animated + let displayStyle = '' + if (animated) { + displayStyle = `opacity: ${show ? '1' : '0' + };-webkit-transition:opacity 0.5s;transition:opacity 0.5s;` + } else { + displayStyle = `display: ${show ? '' : 'none'}` + } + this.setData({ + displayStyle + }) + }, + back() { + const data = this.data + if (data.delta) { + wx.navigateBack({ + delta: data.delta + }) + } + // 如果是直接打开的,就默认回首页 + if (getCurrentPages().length == 1) { + wx.switchTab({ + url: '/page/component/index', + complete: (res) => { + console.log(res) } - this.triggerEvent('back', { delta: data.delta }, {}) + }) } + this.triggerEvent('back', { delta: data.delta }, {}) + } } }) diff --git a/miniprogram/component/navigation-bar/navigation-bar.json b/miniprogram/component/navigation-bar/navigation-bar.json index 23109a50..6245cfa7 100644 --- a/miniprogram/component/navigation-bar/navigation-bar.json +++ b/miniprogram/component/navigation-bar/navigation-bar.json @@ -2,6 +2,5 @@ "component": true, "usingComponents": {}, "componentFramework": "glass-easel", - "renderer": "skyline", - "styleIsolation": "apply-shared" + "renderer": "skyline" } diff --git a/miniprogram/component/navigation-bar/navigation-bar.wxml b/miniprogram/component/navigation-bar/navigation-bar.wxml index 69976661..b52e7382 100644 --- a/miniprogram/component/navigation-bar/navigation-bar.wxml +++ b/miniprogram/component/navigation-bar/navigation-bar.wxml @@ -36,7 +36,7 @@ - + diff --git a/miniprogram/components/navigation-bar/index.js b/miniprogram/components/navigation-bar/index.js index 1b86cafe..34aad82b 100644 --- a/miniprogram/components/navigation-bar/index.js +++ b/miniprogram/components/navigation-bar/index.js @@ -1,3 +1,4 @@ +const app = getApp().globalData Component({ options: { multipleSlots: true, // 在组件定义时的选项中启用多slot支持 @@ -38,33 +39,28 @@ Component({ }, attached() { - const isSupport = !!wx.getMenuButtonBoundingClientRect; - const rect = wx.getMenuButtonBoundingClientRect ? wx.getMenuButtonBoundingClientRect() : null; - wx.getSystemInfo({ - success: (res) => { - const ios = !!(res.system.toLowerCase().search('ios') + 1); - const sideWidth = isSupport ? res.windowWidth - rect.left : 0; + const isSupport = !!wx.getMenuButtonBoundingClientRect + const rect = wx.getMenuButtonBoundingClientRect ? wx.getMenuButtonBoundingClientRect() : null + const sideWidth = isSupport ? app.windowWidth - rect.left : 0 - this.setData({ - ios, - sideWidth: this.data.sideWidth || sideWidth, - statusBarHeight: res.statusBarHeight, - }); - }, - }); + this.setData({ + ios: !!(app.system.toLowerCase().search('ios') + 1), + sideWidth: this.data.sideWidth || sideWidth, + statusBarHeight: app.statusBarHeight, + }) }, /** * 组件的方法列表 */ methods: { back() { - const { data } = this; + const { data } = this if (data.delta) { wx.navigateBack({ delta: data.delta, - }); + }) } - this.triggerEvent('back', { delta: data.delta }, {}); + this.triggerEvent('back', { delta: data.delta }, {}) }, }, -}); +}) diff --git a/miniprogram/components/page-scroll/index.js b/miniprogram/components/page-scroll/index.js index a897a256..5f292cf4 100644 --- a/miniprogram/components/page-scroll/index.js +++ b/miniprogram/components/page-scroll/index.js @@ -1,89 +1,86 @@ -var globalThis = this, self = this; +const globalThis = this; const + self = this module.exports = -require("../../_commons/0.js")([ -{ -"ids": [6], -"modules":{ +require('../../_commons/0.js')([ + { + ids: [6], + modules: { -/***/ "./node_modules/@mpflow/webpack-plugin/lib/loaders/page-loader.js?appContext=src&outputPath=components%2Fpage-scroll%2Findex!./src/components/page-scroll/index.ts": -/*!*************************************************************************************************************************************************************************!*\ + /***/ './node_modules/@mpflow/webpack-plugin/lib/loaders/page-loader.js?appContext=src&outputPath=components%2Fpage-scroll%2Findex!./src/components/page-scroll/index.ts': + /*! *************************************************************************************************************************************************************************!*\ !*** ./node_modules/@mpflow/webpack-plugin/lib/loaders/page-loader.js?appContext=src&outputPath=components%2Fpage-scroll%2Findex!./src/components/page-scroll/index.ts ***! - \*************************************************************************************************************************************************************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { + \************************************************************************************************************************************************************************ */ + /*! no static exports found */ + /***/ (function (module, exports, __webpack_require__) { + module.exports = __webpack_require__(/*! ./index.ts */ './src/components/page-scroll/index.ts') + /***/ }), -module.exports = __webpack_require__(/*! ./index.ts */ "./src/components/page-scroll/index.ts") - -/***/ }), - -/***/ "./src/components/page-scroll/index.ts": -/*!*********************************************!*\ + /***/ './src/components/page-scroll/index.ts': + /*! *********************************************!*\ !*** ./src/components/page-scroll/index.ts ***! - \*********************************************/ -/*! no static exports found */ -/***/ (function(module, exports) { + \******************************************** */ + /*! no static exports found */ + /***/ (function (module, exports) { + Component({ + options: { + virtualHost: true + }, + properties: { + refresherEnabled: { + type: Boolean, + value: false + }, + refresherThreshold: { + type: Number, + value: 45 + }, + refresherDefaultStyle: { + type: String, + value: 'black' + }, + refresherBackground: { + type: String, + value: '#FFF' + }, + refresherTriggered: { + type: Boolean, + value: false + }, + lowerThreshold: { + type: Number, + value: 50 + }, + scrollIntoView: { + type: String, + value: '' + } + }, + methods: { + onScroll: function onScroll(e) { + this.triggerEvent('scroll', e.detail) + }, + onScrollToLower: function onScrollToLower(e) { + this.triggerEvent('scrollToLower', e.detail) + }, + onPulling: function onPulling(e) { + this.triggerEvent('pulling', e.detail) + }, + onRefresh: function onRefresh(e) { + this.triggerEvent('refresh', e.detail) + }, + onRestore: function onRestore(e) { + this.triggerEvent('restore', e.detail) + }, + onAbort: function onAbort(e) { + this.triggerEvent('abort', e.detail) + } + } + }) + /***/ }) -Component({ - options: { - virtualHost: true - }, - properties: { - refresherEnabled: { - type: Boolean, - value: false - }, - refresherThreshold: { - type: Number, - value: 45 - }, - refresherDefaultStyle: { - type: String, - value: 'black' - }, - refresherBackground: { - type: String, - value: '#FFF' - }, - refresherTriggered: { - type: Boolean, - value: false - }, - lowerThreshold: { - type: Number, - value: 50 }, - scrollIntoView: { - type: String, - value: '' - } + entries: [['./node_modules/@mpflow/webpack-plugin/lib/loaders/page-loader.js?appContext=src&outputPath=components%2Fpage-scroll%2Findex!./src/components/page-scroll/index.ts', 0]] }, - methods: { - onScroll: function onScroll(e) { - this.triggerEvent('scroll', e.detail); - }, - onScrollToLower: function onScrollToLower(e) { - this.triggerEvent('scrollToLower', e.detail); - }, - onPulling: function onPulling(e) { - this.triggerEvent('pulling', e.detail); - }, - onRefresh: function onRefresh(e) { - this.triggerEvent('refresh', e.detail); - }, - onRestore: function onRestore(e) { - this.triggerEvent('restore', e.detail); - }, - onAbort: function onAbort(e) { - this.triggerEvent('abort', e.detail); - } - } -}); - -/***/ }) - -}, -"entries": [["./node_modules/@mpflow/webpack-plugin/lib/loaders/page-loader.js?appContext=src&outputPath=components%2Fpage-scroll%2Findex!./src/components/page-scroll/index.ts",0]] -}, -]); +]) -// # sourceMappingURL=index.js.map \ No newline at end of file +// # sourceMappingURL=index.js.map diff --git a/miniprogram/components/popup/index.js b/miniprogram/components/popup/index.js index 0c30ad2f..f333b411 100644 --- a/miniprogram/components/popup/index.js +++ b/miniprogram/components/popup/index.js @@ -25,14 +25,14 @@ Component({ }, methods: { close() { - const { data } = this; + const { data } = this console.log('@@@ close', data.maskClosable) - if (!data.maskClosable) return; + if (!data.maskClosable) return this.setData({ enable: !this.data.enable - }); - this.triggerEvent('close', {}, {}); + }) + this.triggerEvent('close', {}, {}) }, // stopEvent() {}, }, -}); +}) diff --git a/miniprogram/components/popup/index.wxss b/miniprogram/components/popup/index.wxss index 2f6824bc..e12d7a62 100644 --- a/miniprogram/components/popup/index.wxss +++ b/miniprogram/components/popup/index.wxss @@ -7,13 +7,14 @@ root-portal { .popup { position: absolute; bottom: 0; + top: 0; z-index: 5000; display: flex; flex-direction: row; justify-content: center; align-items: center; width: 100vw; - height: 200px; + /* height: 200px; */ background: rgba(51, 51, 51, 0.65); opacity: 1; transform: scale3d(1, 1, 1); diff --git a/miniprogram/packageAPI/pages/ai/mobilenet/index.js b/miniprogram/packageAPI/pages/ai/mobilenet/index.js index 89ef3291..e06c7ff3 100644 --- a/miniprogram/packageAPI/pages/ai/mobilenet/index.js +++ b/miniprogram/packageAPI/pages/ai/mobilenet/index.js @@ -4,23 +4,23 @@ import { Classifier } from './classify' import { FpsHelper } from '../../../../util/fps_helper' -const { appWidth, appHeight, benchmarkLevel } = getApp().globalData; +const { appWidth, appHeight, benchmarkLevel } = getApp().globalData Page({ classifier: null, ctx: null, - fpsHelper:null, + fpsHelper: null, predicting: false, // For Speed Test - constBuffer : null, + constBuffer: null, /** * 页面的初始数据 */ data: { - predClass: "None", + predClass: 'None', classifier: null, enableSpeedTest: false, avgTime: 110.0, @@ -31,8 +31,7 @@ Page({ * 生命周期函数--监听页面加载 */ onLoad() { - if (this.data.enableSpeedTest) - { + if (this.data.enableSpeedTest) { this.constBuffer = new Float32Array(3 * 224 * 224) } }, @@ -40,46 +39,45 @@ Page({ /** * 生命周期函数--监听页面初次渲染完成 */ - onReady() { - this.ctx = wx.createCanvasContext('ssd1'); - const context = wx.createCameraContext(this); - this.initClassifier(); - this.fpsHelper = new FpsHelper(); + onReady() { + this.ctx = wx.createCanvasContext('ssd1') + const context = wx.createCameraContext(this) + this.initClassifier() + this.fpsHelper = new FpsHelper() const listener = context.onCameraFrame(frame => { + const fps = this.fpsHelper.getAverageFps() + console.log(`fps=${fps}`) - const fps = this.fpsHelper.getAverageFps(); - console.log(`fps=${fps}`); - - if (this.classifier && this.classifier.isReady() && !this.predicting) { - this.executeClassify(frame); - } - }); - listener.start(); - this.fpsHelper.reset(); + if (this.classifier && this.classifier.isReady() && !this.predicting) { + this.executeClassify(frame) + } + }) + listener.start() + this.fpsHelper.reset() }, /** * 初始化 SSD models */ initClassifier() { - wx.showLoading({ title: '模型正在加载...' }); - this.classifier = new Classifier({ width: appWidth, height: appHeight }); + wx.showLoading({ title: '模型正在加载...' }) + this.classifier = new Classifier({ width: appWidth, height: appHeight }) this.classifier.load().then(() => { - wx.hideLoading(); + wx.hideLoading() }).catch(err => { - console.log('模型加载报错:', err); + console.log('模型加载报错:', err) }) }, - /** + /** * 构建模型 */ -async executeClassify (frame) { - this.predicting = true; + async executeClassify(frame) { + this.predicting = true if (this.classifier && this.classifier.isReady()) { - this.fpsHelper.updateFPS(); + this.fpsHelper.updateFPS() this.setData({ predClass: this.classifier.predClass(), @@ -92,82 +90,75 @@ async executeClassify (frame) { }) }).catch((err) => { console.log(err) - }) + }) - if (this.data.enableSpeedTest) - { - await this.inferSpeedTest(); + if (this.data.enableSpeedTest) { + await this.inferSpeedTest() } } - this.predicting = false; + this.predicting = false }, - async inferSpeedTest() - { - console.log("runInferenceSession speed test start run===============================") + async inferSpeedTest() { + console.log('runInferenceSession speed test start run===============================') - const xinput = { - shape: [1, 3, 224, 224], - data: this.constBuffer.buffer, - type: 'float32', - }; - - this.data.classifier = this.classifier; + const xinput = { + shape: [1, 3, 224, 224], + data: this.constBuffer.buffer, + type: 'float32', + } - // warm up - for (let index = 0; index < 20; index++) { + this.data.classifier = this.classifier - await this.inferOnce(xinput, this.data); - } + // warm up + for (let index = 0; index < 20; index++) { + await this.inferOnce(xinput, this.data) + } - for (var l = 0; l < 5; ++l) - { - var beMs = new Date().getTime() + for (let l = 0; l < 5; ++l) { + const beMs = new Date().getTime() - for (let index = 0; index < 100; index++) { + for (let index = 0; index < 100; index++) { + await this.inferOnce(xinput, this.data) + } - await this.inferOnce(xinput, this.data); - } + const afMs = new Date().getTime() - var afMs = new Date().getTime() - - var avgTime = (afMs - beMs) / 100.0; + const avgTime = (afMs - beMs) / 100.0 - var overall = 0.0; - var minTime = 1000000.0; + let overall = 0.0 + let minTime = 1000000.0 - for (let index = 0; index < 100; index++) { - var beMsTmp = new Date().getTime() - await this.inferOnce(xinput, this.data); - var afMsTmp = new Date().getTime() - var tmpTime = (afMsTmp - beMsTmp) - if (minTime > tmpTime) - { - minTime = tmpTime; - } - overall += (afMsTmp - beMsTmp) - } + for (let index = 0; index < 100; index++) { + const beMsTmp = new Date().getTime() + await this.inferOnce(xinput, this.data) + const afMsTmp = new Date().getTime() + const tmpTime = (afMsTmp - beMsTmp) + if (minTime > tmpTime) { + minTime = tmpTime + } + overall += (afMsTmp - beMsTmp) + } - console.log("Inference min time: ", minTime) - console.log("Inference avg time: ", avgTime) + console.log('Inference min time: ', minTime) + console.log('Inference avg time: ', avgTime) - this.setData({ - predClass: this.classifier.predClass(), - minTime : minTime, - avgTime : avgTime, - }) - } + this.setData({ + predClass: this.classifier.predClass(), + minTime, + avgTime, + }) + } }, inferOnce(xinput, data) { return new Promise(function (resolve, reject) { data.classifier.session.run({ - "input": xinput, + input: xinput, }).then(async function (res) { resolve() }) - }) }, @@ -190,7 +181,7 @@ async executeClassify (frame) { */ onUnload() { if (this.classifier && this.classifier.isReady()) { - this.classifier.dispose(); + this.classifier.dispose() } }, @@ -217,4 +208,4 @@ async executeClassify (frame) { path: 'packageAPI/pages/ai/mobilenet/index', } } -}) \ No newline at end of file +}) diff --git a/miniprogram/packageAPI/pages/ai/mobilenet_int8/index.js b/miniprogram/packageAPI/pages/ai/mobilenet_int8/index.js index a403af68..4fcf22a2 100644 --- a/miniprogram/packageAPI/pages/ai/mobilenet_int8/index.js +++ b/miniprogram/packageAPI/pages/ai/mobilenet_int8/index.js @@ -4,23 +4,23 @@ import { Classifier } from './classify' import { FpsHelper } from '../../../../util/fps_helper' -const { appWidth, appHeight, benchmarkLevel } = getApp().globalData; +const { appWidth, appHeight, benchmarkLevel } = getApp().globalData Page({ classifier: null, ctx: null, - fpsHelper:null, + fpsHelper: null, predicting: false, // For Speed Test - constBuffer : null, + constBuffer: null, /** * 页面的初始数据 */ data: { - predClass: "None", + predClass: 'None', classifier: null, enableSpeedTest: false, avgTime: 110.0, @@ -31,8 +31,7 @@ Page({ * 生命周期函数--监听页面加载 */ onLoad() { - if (this.data.enableSpeedTest) - { + if (this.data.enableSpeedTest) { this.constBuffer = new Float32Array(3 * 224 * 224) } }, @@ -40,46 +39,45 @@ Page({ /** * 生命周期函数--监听页面初次渲染完成 */ - onReady() { - this.ctx = wx.createCanvasContext('ssd'); - const context = wx.createCameraContext(this); - this.initClassifier(); - this.fpsHelper = new FpsHelper(); + onReady() { + this.ctx = wx.createCanvasContext('ssd') + const context = wx.createCameraContext(this) + this.initClassifier() + this.fpsHelper = new FpsHelper() const listener = context.onCameraFrame(frame => { + const fps = this.fpsHelper.getAverageFps() + console.log(`fps=${fps}`) - const fps = this.fpsHelper.getAverageFps(); - console.log(`fps=${fps}`); - - if (this.classifier && this.classifier.isReady() && !this.predicting) { - this.executeClassify(frame); - } - }); - listener.start(); - this.fpsHelper.reset(); + if (this.classifier && this.classifier.isReady() && !this.predicting) { + this.executeClassify(frame) + } + }) + listener.start() + this.fpsHelper.reset() }, /** * 初始化 SSD models */ initClassifier() { - wx.showLoading({ title: '模型正在加载...' }); - this.classifier = new Classifier({ width: appWidth, height: appHeight }); + wx.showLoading({ title: '模型正在加载...' }) + this.classifier = new Classifier({ width: appWidth, height: appHeight }) this.classifier.load().then(() => { - wx.hideLoading(); + wx.hideLoading() }).catch(err => { - console.log('模型加载报错:', err); + console.log('模型加载报错:', err) }) }, - /** + /** * 构建模型 */ -async executeClassify (frame) { - this.predicting = true; + async executeClassify(frame) { + this.predicting = true if (this.classifier && this.classifier.isReady()) { - this.fpsHelper.updateFPS(); + this.fpsHelper.updateFPS() this.setData({ predClass: this.classifier.predClass(), @@ -92,81 +90,75 @@ async executeClassify (frame) { }) }).catch((err) => { console.log(err) - }) + }) - if (this.data.enableSpeedTest) - { - await this.inferSpeedTest(); + if (this.data.enableSpeedTest) { + await this.inferSpeedTest() } } - this.predicting = false; + this.predicting = false }, - async inferSpeedTest() - { - console.log("runInferenceSession speed test start run===============================") - - const xinput = { - shape: [1, 3, 224, 224], - data: this.constBuffer.buffer, - type: 'float32', - }; - - this.data.classifier = this.classifier; - - // warm up - for (let index = 0; index < 20; index++) { - await this.inferOnce(xinput, this.data); - } + async inferSpeedTest() { + console.log('runInferenceSession speed test start run===============================') - for (var l = 0; l < 5; ++l) - { - var beMs = new Date().getTime() + const xinput = { + shape: [1, 3, 224, 224], + data: this.constBuffer.buffer, + type: 'float32', + } - for (let index = 0; index < 100; index++) { + this.data.classifier = this.classifier - await this.inferOnce(xinput, this.data); - } + // warm up + for (let index = 0; index < 20; index++) { + await this.inferOnce(xinput, this.data) + } + + for (let l = 0; l < 5; ++l) { + const beMs = new Date().getTime() - var afMs = new Date().getTime() - - var avgTime = (afMs - beMs) / 100.0; + for (let index = 0; index < 100; index++) { + await this.inferOnce(xinput, this.data) + } - var overall = 0.0; - var minTime = 1000000.0; + const afMs = new Date().getTime() - for (let index = 0; index < 100; index++) { - var beMsTmp = new Date().getTime() - await this.inferOnce(xinput, this.data); - var afMsTmp = new Date().getTime() - var tmpTime = (afMsTmp - beMsTmp) - if (minTime > tmpTime) - { - minTime = tmpTime; - } - overall += (afMsTmp - beMsTmp) - } + const avgTime = (afMs - beMs) / 100.0 - console.log("Inference min time: ", minTime) - console.log("Inference avg time: ", avgTime) + let overall = 0.0 + let minTime = 1000000.0 - this.setData({ - predClass: this.classifier.predClass(), - minTime : minTime, - avgTime : avgTime, - }) + for (let index = 0; index < 100; index++) { + const beMsTmp = new Date().getTime() + await this.inferOnce(xinput, this.data) + const afMsTmp = new Date().getTime() + const tmpTime = (afMsTmp - beMsTmp) + if (minTime > tmpTime) { + minTime = tmpTime + } + overall += (afMsTmp - beMsTmp) } + + console.log('Inference min time: ', minTime) + console.log('Inference avg time: ', avgTime) + + this.setData({ + predClass: this.classifier.predClass(), + minTime, + avgTime, + }) + } }, inferOnce(xinput, data) { return new Promise(function (resolve, reject) { data.classifier.session.run({ - "onnx::QuantizeLinear_0": xinput, + 'onnx::QuantizeLinear_0': xinput, }).then(async function (res) { resolve() }) - }) }, @@ -189,7 +181,7 @@ async executeClassify (frame) { */ onUnload() { if (this.classifier && this.classifier.isReady()) { - this.classifier.dispose(); + this.classifier.dispose() } }, @@ -216,4 +208,4 @@ async executeClassify (frame) { path: 'packageAPI/pages/ai/mobilenet_int8/index', } } -}) \ No newline at end of file +}) diff --git a/miniprogram/packageAPI/pages/ai/style-trans/index.js b/miniprogram/packageAPI/pages/ai/style-trans/index.js index b1bafefc..f896ec13 100644 --- a/miniprogram/packageAPI/pages/ai/style-trans/index.js +++ b/miniprogram/packageAPI/pages/ai/style-trans/index.js @@ -1,4 +1,3 @@ - // pages/stype-trans/index.js.ts Page({ session: null, @@ -8,10 +7,10 @@ Page({ * 页面的初始数据 */ data: { - src : '', - imageWidth : 224, - imageHeight : 224, - imageChannel : 3, + src: '', + imageWidth: 224, + imageHeight: 224, + imageChannel: 3, }, /** @@ -70,7 +69,7 @@ Page({ }, - takePhoto() { + takePhoto() { const camera = wx.createCameraContext() camera.takePhoto({ quality: 'normal', @@ -79,7 +78,7 @@ Page({ src: res.tempImagePath }) - const canvas = wx.createOffscreenCanvas({type: '2d', width: this.data.imageWidth, height: this.data.imageHeight}) + const canvas = wx.createOffscreenCanvas({ type: '2d', width: this.data.imageWidth, height: this.data.imageHeight }) const ctx = canvas.getContext('2d') @@ -105,58 +104,53 @@ Page({ }) } }) - }, - InitSession() - { + InitSession() { return new Promise((resolve, reject) => { - const modelPath = `${wx.env.USER_DATA_PATH}/mosaic-8.onnx`; + const modelPath = `${wx.env.USER_DATA_PATH}/mosaic-8.onnx` // 判断之前是否已经下载过onnx模型 wx.getFileSystemManager().access({ - path: modelPath, - success: (res) => - { - console.log("file already exist at: " + modelPath) - this.createInferenceSession(modelPath).then(() => - { - resolve(); - }) - }, - fail: (res) => { - console.error(res) + path: modelPath, + success: (res) => { + console.log('file already exist at: ' + modelPath) + this.createInferenceSession(modelPath).then(() => { + resolve() + }) + }, + fail: (res) => { + console.error(res) - wx.cloud.init(); - console.log("begin download model"); + wx.cloud.init() + console.log('begin download model') - const cloudPath = 'cloud://containertest-0gmw3ulnd8d9bc7b.636f-containertest-0gmw3ulnd8d9bc7b-1258211818/mosaic-8.onnx' + const cloudPath = 'cloud://containertest-0gmw3ulnd8d9bc7b.636f-containertest-0gmw3ulnd8d9bc7b-1258211818/mosaic-8.onnx' - this.downloadFile(cloudPath, function(r) { - console.log(`下载进度:${r.progress}%,已下载${r.totalBytesWritten}B,共${r.totalBytesExpectedToWrite}B`) - }).then(result => { + this.downloadFile(cloudPath, function (r) { + console.log(`下载进度:${r.progress}%,已下载${r.totalBytesWritten}B,共${r.totalBytesExpectedToWrite}B`) + }).then(result => { wx.getFileSystemManager().saveFile({ - tempFilePath:result.tempFilePath, + tempFilePath: result.tempFilePath, filePath: modelPath, success: (res) => { // 注册回调函数 console.log(res) - - const modelPath = res.savedFilePath; - console.log("save onnx model at path: " + modelPath) + + const modelPath = res.savedFilePath + console.log('save onnx model at path: ' + modelPath) this.createInferenceSession(modelPath).then(() => { - resolve(); + resolve() }) }, fail(res) { console.error(res) - return } }) - }); + }) } }) - }) + }) }, createInferenceSession(modelPath) { @@ -171,23 +165,23 @@ Page({ Higher precision always require longer time to run session */ - precisionLevel : 4, - allowNPU : false, // wheather use NPU for inference, only useful for IOS + precisionLevel: 4, + allowNPU: false, // wheather use NPU for inference, only useful for IOS allowQuantize: false, // wheather generate quantize model - }); + }) // 监听error事件 this.session.onError((error) => { - console.error(error); - reject(error); - }); + console.error(error) + reject(error) + }) this.session.onLoad(() => { - resolve(); - }); + resolve() + }) }) }, -downloadFile(fileID, onCall = () => {}) { + downloadFile(fileID, onCall = () => {}) { return new Promise((resolve, reject) => { const task = wx.cloud.downloadFile({ fileID, @@ -209,83 +203,76 @@ downloadFile(fileID, onCall = () => {}) { }) }, - detect(imgData) - { - return new Promise((resolve, reject) => - { + detect(imgData) { + return new Promise((resolve, reject) => { const uint8Data = new Uint8Array(imgData.data) - var floatData = new Float32Array(this.data.imageChannel * this.data.imageHeight * this.data.imageWidth); + const floatData = new Float32Array(this.data.imageChannel * this.data.imageHeight * this.data.imageWidth) // nhwc uint8 data to nchw float32 data, and ignore the alpha channel const modelChannel = this.data.imageChannel - - const imageWH = this.data.imageHeight * this.data.imageWidth; - - var idx = 0; - for (var c = 0; c < modelChannel; ++c) - { - for (var wh = 0; wh < imageWH; ++wh) - { - var inputIdx = wh * 4 + c; - floatData[idx] = uint8Data[inputIdx]; - idx++; + + const imageWH = this.data.imageHeight * this.data.imageWidth + + let idx = 0 + for (let c = 0; c < modelChannel; ++c) { + for (let wh = 0; wh < imageWH; ++wh) { + const inputIdx = wh * 4 + c + floatData[idx] = uint8Data[inputIdx] + idx++ } - } + } const xinput = { - shape: [1, 3, 224, 224], // Input data shape in NCHW + shape: [1, 3, 224, 224], // Input data shape in NCHW data: floatData.buffer, - type: 'float32', // Input data type - }; + type: 'float32', // Input data type + } this.session.run({ - // Here string "input1" Should be the same with the input name in onnx file - "input1" : xinput, + // Here string "input1" Should be the same with the input name in onnx file + input1: xinput, }).then((res) => { - // Here use res.outputname.data, outputname + // Here use res.outputname.data, outputname // Should be the same with the output name in onnx file - let output = new Float32Array(res.output1.data) + const output = new Float32Array(res.output1.data) - const hwSize = imgData.height * imgData.width; + const hwSize = imgData.height * imgData.width - var finalout = new Uint8ClampedArray(4 * hwSize); + const finalout = new Uint8ClampedArray(4 * hwSize) // fill the alpha channel - finalout.fill(255); + finalout.fill(255) // convert from nchw to nhwc - idx = 0; - for (var c = 0; c < modelChannel; ++c) - { - for (var hw = 0; hw < hwSize; ++hw) - { - var dstIdx = hw * 4 + c; - finalout[dstIdx] = Math.max(0, Math.min(Math.round(output[idx]), 255)); - idx++; + idx = 0 + for (let c = 0; c < modelChannel; ++c) { + for (let hw = 0; hw < hwSize; ++hw) { + const dstIdx = hw * 4 + c + finalout[dstIdx] = Math.max(0, Math.min(Math.round(output[idx]), 255)) + idx++ } } this.canvasCtx = wx.createCanvasContext('trans') - wx.canvasPutImageData - ({ + wx.canvasPutImageData({ canvasId: 'trans', data: finalout, height: 224, width: 224, x: 0, y: 0, - }).then((res) =>{ + }).then((res) => { console.log(res) }) }) - resolve(); + resolve() }) }, error(e) { console.log(e.detail) } -}) \ No newline at end of file +}) diff --git a/miniprogram/packageAPI/pages/api/choose-address/choose-address.js b/miniprogram/packageAPI/pages/api/choose-address/choose-address.js index c7e67c1d..8234545f 100644 --- a/miniprogram/packageAPI/pages/api/choose-address/choose-address.js +++ b/miniprogram/packageAPI/pages/api/choose-address/choose-address.js @@ -29,12 +29,12 @@ Page({ }, onLoad() { this.setData({ - theme: wx.getSystemInfoSync().theme || 'light' + theme: getApp().globalData.theme || 'light' }) if (wx.onThemeChange) { - wx.onThemeChange(({theme}) => { - this.setData({theme}) + wx.onThemeChange(({ theme }) => { + this.setData({ theme }) }) } } diff --git a/miniprogram/packageAPI/pages/api/choose-invoice-title/choose-invoice-title.js b/miniprogram/packageAPI/pages/api/choose-invoice-title/choose-invoice-title.js index ba976ab0..5878845a 100644 --- a/miniprogram/packageAPI/pages/api/choose-invoice-title/choose-invoice-title.js +++ b/miniprogram/packageAPI/pages/api/choose-invoice-title/choose-invoice-title.js @@ -41,12 +41,12 @@ Page({ }, onLoad() { this.setData({ - theme: wx.getSystemInfoSync().theme || 'light' + theme: getApp().globalData.theme || 'light' }) if (wx.onThemeChange) { - wx.onThemeChange(({theme}) => { - this.setData({theme}) + wx.onThemeChange(({ theme }) => { + this.setData({ theme }) }) } } diff --git a/miniprogram/packageAPI/pages/api/custom-message/custom-message.js b/miniprogram/packageAPI/pages/api/custom-message/custom-message.js index d4e307ac..b5361819 100644 --- a/miniprogram/packageAPI/pages/api/custom-message/custom-message.js +++ b/miniprogram/packageAPI/pages/api/custom-message/custom-message.js @@ -5,7 +5,7 @@ Page({ path: 'packageAPI/pages/api/custom-message/custom-message' } }, - handleContact (e) { + handleContact(e) { console.log(e.detail.path) console.log(e.detail.query) }, @@ -16,12 +16,12 @@ Page({ }, onLoad() { this.setData({ - theme: wx.getSystemInfoSync().theme || 'light' + theme: getApp().globalData.theme || 'light' }) if (wx.onThemeChange) { - wx.onThemeChange(({theme}) => { - this.setData({theme}) + wx.onThemeChange(({ theme }) => { + this.setData({ theme }) }) } } diff --git a/miniprogram/packageAPI/pages/api/get-user-info/get-user-info.js b/miniprogram/packageAPI/pages/api/get-user-info/get-user-info.js index 272ea109..aade5ce3 100644 --- a/miniprogram/packageAPI/pages/api/get-user-info/get-user-info.js +++ b/miniprogram/packageAPI/pages/api/get-user-info/get-user-info.js @@ -45,12 +45,12 @@ Page({ }, onLoad() { this.setData({ - theme: wx.getSystemInfoSync().theme || 'light' + theme: getApp().globalData.theme || 'light' }) if (wx.onThemeChange) { - wx.onThemeChange(({theme}) => { - this.setData({theme}) + wx.onThemeChange(({ theme }) => { + this.setData({ theme }) }) } if (wx.getUserProfile) { diff --git a/miniprogram/packageAPI/pages/api/jump/jump.js b/miniprogram/packageAPI/pages/api/jump/jump.js index 70c62018..3da1fbde 100644 --- a/miniprogram/packageAPI/pages/api/jump/jump.js +++ b/miniprogram/packageAPI/pages/api/jump/jump.js @@ -10,49 +10,49 @@ Page({ theme: 'light', setting: {} }, - //打开半屏小程序 - openhalfscreenminiprogram(){ + // 打开半屏小程序 + openhalfscreenminiprogram() { wx.openEmbeddedMiniProgram({ - appId: 'wxfdcee92a299bcaf1', // 腾讯公益 - extraData: { - foo: 'bar' - }, - // envVersion: 'develop', - success(res) { - // 打开成功 - } + appId: 'wxfdcee92a299bcaf1', // 腾讯公益 + extraData: { + foo: 'bar' + }, + // envVersion: 'develop', + success(res) { + // 打开成功 + } }) }, - //打开另一个小程序 - openanotherminiprogram(){ + // 打开另一个小程序 + openanotherminiprogram() { wx.navigateToMiniProgram({ - appId: 'wxfdcee92a299bcaf1', // 腾讯公益 - // extraData: { - // foo: 'bar' - // }, - // envVersion: 'develop', - success(res) { - // 打开成功 - } + appId: 'wxfdcee92a299bcaf1', // 腾讯公益 + // extraData: { + // foo: 'bar' + // }, + // envVersion: 'develop', + success(res) { + // 打开成功 + } }) }, - //退出当前小程序 - exitminiprogram(){ + // 退出当前小程序 + exitminiprogram() { wx.exitMiniProgram({ - success(){ - wx.showToast({ - title: '退出成功', - icon: 'none', - duration: 2000 - }) - }, - fail(){ - wx.showToast({ - title: '退出失败', - icon: 'none', - duration: 2000 - }) - } + success() { + wx.showToast({ + title: '退出成功', + icon: 'none', + duration: 2000 + }) + }, + fail() { + wx.showToast({ + title: '退出失败', + icon: 'none', + duration: 2000 + }) + } }) }, onUnload() { @@ -62,12 +62,12 @@ Page({ }, onLoad() { this.setData({ - theme: wx.getSystemInfoSync().theme || 'light' + theme: getApp().globalData.theme || 'light' }) if (wx.onThemeChange) { - wx.onThemeChange(({theme}) => { - this.setData({theme}) + wx.onThemeChange(({ theme }) => { + this.setData({ theme }) }) } } diff --git a/miniprogram/packageAPI/pages/api/jump/jump.wxml b/miniprogram/packageAPI/pages/api/jump/jump.wxml index ea65f72a..d9deab59 100644 --- a/miniprogram/packageAPI/pages/api/jump/jump.wxml +++ b/miniprogram/packageAPI/pages/api/jump/jump.wxml @@ -1,8 +1,7 @@ - -