From 7678d1b558894abcbc673e3c8c44347941a32fb3 Mon Sep 17 00:00:00 2001 From: fxy060608 Date: Mon, 2 Sep 2019 17:36:02 +0800 Subject: [PATCH] fix(mp): vuex store --- packages/uni-app-plus/dist/index.js | 6 ++++- packages/uni-mp-alipay/dist/index.js | 26 ++++++++++++++++--- packages/uni-mp-baidu/dist/index.js | 6 ++++- packages/uni-mp-qq/dist/index.js | 6 ++++- packages/uni-mp-toutiao/dist/index.js | 6 ++++- packages/uni-mp-weixin/dist/index.js | 6 ++++- .../runtime/wrapper/app-base-parser.js | 4 +++ 7 files changed, 51 insertions(+), 9 deletions(-) diff --git a/packages/uni-app-plus/dist/index.js b/packages/uni-app-plus/dist/index.js index c499196b9..5d14111e9 100644 --- a/packages/uni-app-plus/dist/index.js +++ b/packages/uni-app-plus/dist/index.js @@ -231,7 +231,7 @@ const promiseInterceptor = { }; const SYNC_API_RE = - /^\$|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/; + /^\$|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/; const CONTEXT_API_RE = /^create|Manager$/; @@ -1136,6 +1136,10 @@ function parseBaseApp (vm, { if (this.mpType !== 'app') { initRefs(this); initMocks(this, mocks); + } else { + if (this.$options.store) { // vuex store + Vue.prototype.$store = this.$options.store; + } } } }); diff --git a/packages/uni-mp-alipay/dist/index.js b/packages/uni-mp-alipay/dist/index.js index 7848bc284..741537389 100644 --- a/packages/uni-mp-alipay/dist/index.js +++ b/packages/uni-mp-alipay/dist/index.js @@ -231,7 +231,7 @@ const promiseInterceptor = { }; const SYNC_API_RE = - /^\$|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/; + /^\$|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/; const CONTEXT_API_RE = /^create|Manager$/; @@ -639,9 +639,23 @@ const protocols = { // 需要做转换的 API 列表 }, scanCode: { name: 'scan', - args: { - onlyFromCamera: 'hideAlbum', - scanType: false + args (fromArgs) { + if (fromArgs.scanType === 'qrCode') { + fromArgs.type = 'qr'; + return { + onlyFromCamera: 'hideAlbum' + } + } else if (fromArgs.scanType === 'barCode') { + fromArgs.type = 'bar'; + return { + onlyFromCamera: 'hideAlbum' + } + } else { + return { + scanType: false, + onlyFromCamera: 'hideAlbum' + } + } }, returnValue: { code: 'result' @@ -1523,6 +1537,10 @@ function parseBaseApp (vm, { if (this.mpType !== 'app') { initRefs(this); initMocks(this, mocks); + } else { + if (this.$options.store) { // vuex store + Vue.prototype.$store = this.$options.store; + } } } }); diff --git a/packages/uni-mp-baidu/dist/index.js b/packages/uni-mp-baidu/dist/index.js index dfc074423..ad818b630 100644 --- a/packages/uni-mp-baidu/dist/index.js +++ b/packages/uni-mp-baidu/dist/index.js @@ -231,7 +231,7 @@ const promiseInterceptor = { }; const SYNC_API_RE = - /^\$|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/; + /^\$|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/; const CONTEXT_API_RE = /^create|Manager$/; @@ -1282,6 +1282,10 @@ function parseBaseApp (vm, { if (this.mpType !== 'app') { initRefs(this); initMocks(this, mocks); + } else { + if (this.$options.store) { // vuex store + Vue.prototype.$store = this.$options.store; + } } } }); diff --git a/packages/uni-mp-qq/dist/index.js b/packages/uni-mp-qq/dist/index.js index c652f30d6..34ae0d814 100644 --- a/packages/uni-mp-qq/dist/index.js +++ b/packages/uni-mp-qq/dist/index.js @@ -231,7 +231,7 @@ const promiseInterceptor = { }; const SYNC_API_RE = - /^\$|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/; + /^\$|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/; const CONTEXT_API_RE = /^create|Manager$/; @@ -1200,6 +1200,10 @@ function parseBaseApp (vm, { if (this.mpType !== 'app') { initRefs(this); initMocks(this, mocks); + } else { + if (this.$options.store) { // vuex store + Vue.prototype.$store = this.$options.store; + } } } }); diff --git a/packages/uni-mp-toutiao/dist/index.js b/packages/uni-mp-toutiao/dist/index.js index 3b05a63ea..c3e299538 100644 --- a/packages/uni-mp-toutiao/dist/index.js +++ b/packages/uni-mp-toutiao/dist/index.js @@ -231,7 +231,7 @@ const promiseInterceptor = { }; const SYNC_API_RE = - /^\$|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/; + /^\$|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/; const CONTEXT_API_RE = /^create|Manager$/; @@ -1292,6 +1292,10 @@ function parseBaseApp (vm, { if (this.mpType !== 'app') { initRefs(this); initMocks(this, mocks); + } else { + if (this.$options.store) { // vuex store + Vue.prototype.$store = this.$options.store; + } } } }); diff --git a/packages/uni-mp-weixin/dist/index.js b/packages/uni-mp-weixin/dist/index.js index edf833772..8225c9260 100644 --- a/packages/uni-mp-weixin/dist/index.js +++ b/packages/uni-mp-weixin/dist/index.js @@ -231,7 +231,7 @@ const promiseInterceptor = { }; const SYNC_API_RE = - /^\$|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/; + /^\$|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/; const CONTEXT_API_RE = /^create|Manager$/; @@ -1140,6 +1140,10 @@ function parseBaseApp (vm, { if (this.mpType !== 'app') { initRefs(this); initMocks(this, mocks); + } else { + if (this.$options.store) { // vuex store + Vue.prototype.$store = this.$options.store; + } } } }); diff --git a/src/platforms/mp-weixin/runtime/wrapper/app-base-parser.js b/src/platforms/mp-weixin/runtime/wrapper/app-base-parser.js index 2f001597c..8a0b759cd 100644 --- a/src/platforms/mp-weixin/runtime/wrapper/app-base-parser.js +++ b/src/platforms/mp-weixin/runtime/wrapper/app-base-parser.js @@ -39,6 +39,10 @@ export default function parseBaseApp (vm, { if (this.mpType !== 'app') { initRefs(this) initMocks(this, mocks) + } else { + if (this.$options.store) { // vuex store + Vue.prototype.$store = this.$options.store + } } } }) -- GitLab