From e5c3df14894ae145bf3694bf0f6c6a80c708874f Mon Sep 17 00:00:00 2001 From: fxy060608 Date: Wed, 14 Aug 2019 16:28:30 +0800 Subject: [PATCH] =?UTF-8?q?feat(runtime):=20uni=20=E5=AF=B9=E8=B1=A1?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E8=B5=8B=E5=80=BC=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintignore | 1 + packages/uni-app-plus/dist/index.js | 8 +++++++- packages/uni-app-plus/package.json | 2 +- packages/uni-mp-alipay/dist/index.js | 8 +++++++- packages/uni-mp-alipay/package.json | 2 +- packages/uni-mp-baidu/dist/index.js | 8 +++++++- packages/uni-mp-baidu/package.json | 2 +- packages/uni-mp-qq/dist/index.js | 8 +++++++- packages/uni-mp-qq/package.json | 2 +- packages/uni-mp-toutiao/dist/index.js | 8 +++++++- packages/uni-mp-toutiao/package.json | 2 +- packages/uni-mp-weixin/dist/index.js | 8 +++++++- packages/uni-mp-weixin/package.json | 2 +- src/core/runtime/index.js | 8 +++++++- src/platforms/app-plus-nvue/services/api/legacy/index.js | 8 +++++++- 15 files changed, 63 insertions(+), 14 deletions(-) diff --git a/.eslintignore b/.eslintignore index 4ac17f85..69aec5f6 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,2 +1,3 @@ src/core/helpers/html-parser.js +src/platforms/app-plus-nvue/runtime build/rollup-plugin-require-context diff --git a/packages/uni-app-plus/dist/index.js b/packages/uni-app-plus/dist/index.js index 58500876..b5c9f32b 100644 --- a/packages/uni-app-plus/dist/index.js +++ b/packages/uni-app-plus/dist/index.js @@ -1434,6 +1434,9 @@ let uni = {}; if (typeof Proxy !== 'undefined' && "app-plus" !== 'app-plus') { uni = new Proxy({}, { get (target, name) { + if (target[name]) { + return target[name] + } if (baseApi[name]) { return baseApi[name] } @@ -1447,9 +1450,12 @@ if (typeof Proxy !== 'undefined' && "app-plus" !== 'app-plus') { return } return promisify(name, wrapper(name, wx[name])) + }, + set (target, name, value) { + target[name] = value; } }); -} else { +} else { Object.keys(baseApi).forEach(name => { uni[name] = baseApi[name]; }); diff --git a/packages/uni-app-plus/package.json b/packages/uni-app-plus/package.json index ffa3c1a8..e9367626 100644 --- a/packages/uni-app-plus/package.json +++ b/packages/uni-app-plus/package.json @@ -1,6 +1,6 @@ { "name": "@dcloudio/uni-app-plus", - "version": "0.0.249", + "version": "0.0.250", "description": "uni-app app-plus", "main": "dist/index.js", "scripts": { diff --git a/packages/uni-mp-alipay/dist/index.js b/packages/uni-mp-alipay/dist/index.js index 655d85fd..8e5c2867 100644 --- a/packages/uni-mp-alipay/dist/index.js +++ b/packages/uni-mp-alipay/dist/index.js @@ -2009,6 +2009,9 @@ let uni = {}; if (typeof Proxy !== 'undefined' && "mp-alipay" !== 'app-plus') { uni = new Proxy({}, { get (target, name) { + if (target[name]) { + return target[name] + } if (baseApi[name]) { return baseApi[name] } @@ -2030,9 +2033,12 @@ if (typeof Proxy !== 'undefined' && "mp-alipay" !== 'app-plus') { return } return promisify(name, wrapper(name, my[name])) + }, + set (target, name, value) { + target[name] = value; } }); -} else { +} else { Object.keys(baseApi).forEach(name => { uni[name] = baseApi[name]; }); diff --git a/packages/uni-mp-alipay/package.json b/packages/uni-mp-alipay/package.json index 9d0d4b81..d964ac1a 100644 --- a/packages/uni-mp-alipay/package.json +++ b/packages/uni-mp-alipay/package.json @@ -1,6 +1,6 @@ { "name": "@dcloudio/uni-mp-alipay", - "version": "0.0.823", + "version": "0.0.824", "description": "uni-app mp-alipay", "main": "dist/index.js", "scripts": { diff --git a/packages/uni-mp-baidu/dist/index.js b/packages/uni-mp-baidu/dist/index.js index 4c468290..f0f11e74 100644 --- a/packages/uni-mp-baidu/dist/index.js +++ b/packages/uni-mp-baidu/dist/index.js @@ -1592,6 +1592,9 @@ let uni = {}; if (typeof Proxy !== 'undefined' && "mp-baidu" !== 'app-plus') { uni = new Proxy({}, { get (target, name) { + if (target[name]) { + return target[name] + } if (baseApi[name]) { return baseApi[name] } @@ -1613,9 +1616,12 @@ if (typeof Proxy !== 'undefined' && "mp-baidu" !== 'app-plus') { return } return promisify(name, wrapper(name, swan[name])) + }, + set (target, name, value) { + target[name] = value; } }); -} else { +} else { Object.keys(baseApi).forEach(name => { uni[name] = baseApi[name]; }); diff --git a/packages/uni-mp-baidu/package.json b/packages/uni-mp-baidu/package.json index a083e489..bfd30584 100644 --- a/packages/uni-mp-baidu/package.json +++ b/packages/uni-mp-baidu/package.json @@ -1,6 +1,6 @@ { "name": "@dcloudio/uni-mp-baidu", - "version": "0.0.853", + "version": "0.0.854", "description": "uni-app mp-baidu", "main": "dist/index.js", "scripts": { diff --git a/packages/uni-mp-qq/dist/index.js b/packages/uni-mp-qq/dist/index.js index ec95ae0a..63a22e2d 100644 --- a/packages/uni-mp-qq/dist/index.js +++ b/packages/uni-mp-qq/dist/index.js @@ -1473,6 +1473,9 @@ let uni = {}; if (typeof Proxy !== 'undefined' && "mp-qq" !== 'app-plus') { uni = new Proxy({}, { get (target, name) { + if (target[name]) { + return target[name] + } if (baseApi[name]) { return baseApi[name] } @@ -1494,9 +1497,12 @@ if (typeof Proxy !== 'undefined' && "mp-qq" !== 'app-plus') { return } return promisify(name, wrapper(name, wx[name])) + }, + set (target, name, value) { + target[name] = value; } }); -} else { +} else { Object.keys(baseApi).forEach(name => { uni[name] = baseApi[name]; }); diff --git a/packages/uni-mp-qq/package.json b/packages/uni-mp-qq/package.json index 5079bfb3..d19816f0 100644 --- a/packages/uni-mp-qq/package.json +++ b/packages/uni-mp-qq/package.json @@ -1,6 +1,6 @@ { "name": "@dcloudio/uni-mp-qq", - "version": "0.0.107", + "version": "0.0.108", "description": "uni-app mp-qq", "main": "dist/index.js", "scripts": { diff --git a/packages/uni-mp-toutiao/dist/index.js b/packages/uni-mp-toutiao/dist/index.js index 1a0b2712..425f7a00 100644 --- a/packages/uni-mp-toutiao/dist/index.js +++ b/packages/uni-mp-toutiao/dist/index.js @@ -1652,6 +1652,9 @@ let uni = {}; if (typeof Proxy !== 'undefined' && "mp-toutiao" !== 'app-plus') { uni = new Proxy({}, { get (target, name) { + if (target[name]) { + return target[name] + } if (baseApi[name]) { return baseApi[name] } @@ -1673,9 +1676,12 @@ if (typeof Proxy !== 'undefined' && "mp-toutiao" !== 'app-plus') { return } return promisify(name, wrapper(name, tt[name])) + }, + set (target, name, value) { + target[name] = value; } }); -} else { +} else { Object.keys(baseApi).forEach(name => { uni[name] = baseApi[name]; }); diff --git a/packages/uni-mp-toutiao/package.json b/packages/uni-mp-toutiao/package.json index 704f4762..793f9afe 100644 --- a/packages/uni-mp-toutiao/package.json +++ b/packages/uni-mp-toutiao/package.json @@ -1,6 +1,6 @@ { "name": "@dcloudio/uni-mp-toutiao", - "version": "0.0.347", + "version": "0.0.348", "description": "uni-app mp-toutiao", "main": "dist/index.js", "scripts": { diff --git a/packages/uni-mp-weixin/dist/index.js b/packages/uni-mp-weixin/dist/index.js index bbbe2d6b..fc59732e 100644 --- a/packages/uni-mp-weixin/dist/index.js +++ b/packages/uni-mp-weixin/dist/index.js @@ -1404,6 +1404,9 @@ let uni = {}; if (typeof Proxy !== 'undefined' && "mp-weixin" !== 'app-plus') { uni = new Proxy({}, { get (target, name) { + if (target[name]) { + return target[name] + } if (baseApi[name]) { return baseApi[name] } @@ -1425,9 +1428,12 @@ if (typeof Proxy !== 'undefined' && "mp-weixin" !== 'app-plus') { return } return promisify(name, wrapper(name, wx[name])) + }, + set (target, name, value) { + target[name] = value; } }); -} else { +} else { Object.keys(baseApi).forEach(name => { uni[name] = baseApi[name]; }); diff --git a/packages/uni-mp-weixin/package.json b/packages/uni-mp-weixin/package.json index 41934167..79a7153c 100644 --- a/packages/uni-mp-weixin/package.json +++ b/packages/uni-mp-weixin/package.json @@ -1,6 +1,6 @@ { "name": "@dcloudio/uni-mp-weixin", - "version": "0.0.969", + "version": "0.0.970", "description": "uni-app mp-weixin", "main": "dist/index.js", "scripts": { diff --git a/src/core/runtime/index.js b/src/core/runtime/index.js index fbe22958..0904c180 100644 --- a/src/core/runtime/index.js +++ b/src/core/runtime/index.js @@ -45,6 +45,9 @@ let uni = {} if (typeof Proxy !== 'undefined' && __PLATFORM__ !== 'app-plus') { uni = new Proxy({}, { get (target, name) { + if (target[name]) { + return target[name] + } if (baseApi[name]) { return baseApi[name] } @@ -66,9 +69,12 @@ if (typeof Proxy !== 'undefined' && __PLATFORM__ !== 'app-plus') { return } return promisify(name, wrapper(name, __GLOBAL__[name])) + }, + set (target, name, value) { + target[name] = value } }) -} else { +} else { Object.keys(baseApi).forEach(name => { uni[name] = baseApi[name] }) diff --git a/src/platforms/app-plus-nvue/services/api/legacy/index.js b/src/platforms/app-plus-nvue/services/api/legacy/index.js index 9bae2c68..09a7ae67 100644 --- a/src/platforms/app-plus-nvue/services/api/legacy/index.js +++ b/src/platforms/app-plus-nvue/services/api/legacy/index.js @@ -7,7 +7,7 @@ import { } from 'uni-core/helpers/promise' import { - initSubNVue, + initSubNVue, initPostMessage } from '../sub-nvue' @@ -32,6 +32,9 @@ export default function initUni (uni, nvue, plus, BroadcastChannel) { if (typeof Proxy !== 'undefined') { return new Proxy({}, { get (target, name) { + if (target[name]) { + return target[name] + } if (apis[name]) { return apis[name] } @@ -42,6 +45,9 @@ export default function initUni (uni, nvue, plus, BroadcastChannel) { return } return promisify(name, uni[name]) + }, + set (target, name, value) { + target[name] = value } }) } -- GitLab