diff --git a/packages/uni-app-plus/dist/index.js b/packages/uni-app-plus/dist/index.js index 9410878f9fae7683bec37189dac43e680fb60e37..51e4127fec0dd3a592b60b2791df8b479c7011dd 100644 --- a/packages/uni-app-plus/dist/index.js +++ b/packages/uni-app-plus/dist/index.js @@ -1434,15 +1434,10 @@ function getEventChannel (id) { function createApp (vm) { Vue.prototype.getOpenerEventChannel = function () { - switch ("app-plus") { - case 'mp-weixin': - return this.$scope.getOpenerEventChannel() - default : - if (!this.__eventChannel__) { - this.__eventChannel__ = new EventChannel(); - } - return this.__eventChannel__ + if (!this.__eventChannel__) { + this.__eventChannel__ = new EventChannel(); } + return this.__eventChannel__ }; const callHook = Vue.prototype.__call_hook; Vue.prototype.__call_hook = function (hook, args) { diff --git a/packages/uni-mp-alipay/dist/index.js b/packages/uni-mp-alipay/dist/index.js index d4dd282bd3352ae2bf57eee877f156502bd95241..1eee42a53fd4fe54cb884b2f9fb7190a7e9befab 100644 --- a/packages/uni-mp-alipay/dist/index.js +++ b/packages/uni-mp-alipay/dist/index.js @@ -2281,15 +2281,10 @@ function parseApp (vm) { function createApp (vm) { Vue.prototype.getOpenerEventChannel = function () { - switch ("mp-alipay") { - case 'mp-weixin': - return this.$scope.getOpenerEventChannel() - default : - if (!this.__eventChannel__) { - this.__eventChannel__ = new EventChannel(); - } - return this.__eventChannel__ + if (!this.__eventChannel__) { + this.__eventChannel__ = new EventChannel(); } + return this.__eventChannel__ }; const callHook = Vue.prototype.__call_hook; Vue.prototype.__call_hook = function (hook, args) { diff --git a/packages/uni-mp-baidu/dist/index.js b/packages/uni-mp-baidu/dist/index.js index 86ec293a44264d4d73f5db9133fe9eeeaa966da1..aa1ad7e7c767289f3adee64a46e0f334ffe20db6 100644 --- a/packages/uni-mp-baidu/dist/index.js +++ b/packages/uni-mp-baidu/dist/index.js @@ -1728,15 +1728,10 @@ function parseApp (vm) { function createApp (vm) { Vue.prototype.getOpenerEventChannel = function () { - switch ("mp-baidu") { - case 'mp-weixin': - return this.$scope.getOpenerEventChannel() - default : - if (!this.__eventChannel__) { - this.__eventChannel__ = new EventChannel(); - } - return this.__eventChannel__ + if (!this.__eventChannel__) { + this.__eventChannel__ = new EventChannel(); } + return this.__eventChannel__ }; const callHook = Vue.prototype.__call_hook; Vue.prototype.__call_hook = function (hook, args) { diff --git a/packages/uni-mp-kuaishou/dist/index.js b/packages/uni-mp-kuaishou/dist/index.js index 5d59ac5d2b94e3b7e041ce2cd9ee3a604e47a02a..08ecf75716031db22e21870360a361181dd91fff 100644 --- a/packages/uni-mp-kuaishou/dist/index.js +++ b/packages/uni-mp-kuaishou/dist/index.js @@ -1474,15 +1474,10 @@ function parseApp$1 (vm) { function createApp (vm) { Vue.prototype.getOpenerEventChannel = function () { - switch ("mp-kuaishou") { - case 'mp-weixin': - return this.$scope.getOpenerEventChannel() - default : - if (!this.__eventChannel__) { - this.__eventChannel__ = new EventChannel(); - } - return this.__eventChannel__ + if (!this.__eventChannel__) { + this.__eventChannel__ = new EventChannel(); } + return this.__eventChannel__ }; const callHook = Vue.prototype.__call_hook; Vue.prototype.__call_hook = function (hook, args) { diff --git a/packages/uni-mp-qq/dist/index.js b/packages/uni-mp-qq/dist/index.js index 09bb1c2105c6f52ce7ce7690519cc2fe037165ff..fc948a64f437091f4b5cdd09fbe13300e7d2b211 100644 --- a/packages/uni-mp-qq/dist/index.js +++ b/packages/uni-mp-qq/dist/index.js @@ -1640,15 +1640,10 @@ function parseApp$1 (vm) { function createApp (vm) { Vue.prototype.getOpenerEventChannel = function () { - switch ("mp-qq") { - case 'mp-weixin': - return this.$scope.getOpenerEventChannel() - default : - if (!this.__eventChannel__) { - this.__eventChannel__ = new EventChannel(); - } - return this.__eventChannel__ + if (!this.__eventChannel__) { + this.__eventChannel__ = new EventChannel(); } + return this.__eventChannel__ }; const callHook = Vue.prototype.__call_hook; Vue.prototype.__call_hook = function (hook, args) { diff --git a/packages/uni-mp-toutiao/dist/index.js b/packages/uni-mp-toutiao/dist/index.js index 4ca29f08b39f7e75b7d2fa08a18e84f7f1d0b651..f17e4e9d5fe8b932dc38c9fa5ec5b1308cfd6b46 100644 --- a/packages/uni-mp-toutiao/dist/index.js +++ b/packages/uni-mp-toutiao/dist/index.js @@ -1807,15 +1807,10 @@ function parseApp (vm) { function createApp (vm) { Vue.prototype.getOpenerEventChannel = function () { - switch ("mp-toutiao") { - case 'mp-weixin': - return this.$scope.getOpenerEventChannel() - default : - if (!this.__eventChannel__) { - this.__eventChannel__ = new EventChannel(); - } - return this.__eventChannel__ + if (!this.__eventChannel__) { + this.__eventChannel__ = new EventChannel(); } + return this.__eventChannel__ }; const callHook = Vue.prototype.__call_hook; Vue.prototype.__call_hook = function (hook, args) { diff --git a/packages/uni-mp-weixin/dist/index.js b/packages/uni-mp-weixin/dist/index.js index 706caac10e3239834c23f09fbce9d6ff4b589104..e17f348b5e8e1b634619b5cb97acc02d9b9bf74f 100644 --- a/packages/uni-mp-weixin/dist/index.js +++ b/packages/uni-mp-weixin/dist/index.js @@ -687,74 +687,6 @@ Component = function (options = {}) { return MPComponent(options) }; -class EventChannel { - constructor (id, events) { - this.id = id; - this.listener = {}; - this.emitCache = {}; - if (events) { - Object.keys(events).forEach(name => { - this.on(name, events[name]); - }); - } - } - - emit (eventName, ...args) { - const fns = this.listener[eventName]; - if (!fns) { - return (this.emitCache[eventName] || (this.emitCache[eventName] = [])).push(args) - } - fns.forEach(opt => { - opt.fn.apply(opt.fn, args); - }); - this.listener[eventName] = fns.filter(opt => opt.type !== 'once'); - } - - on (eventName, fn) { - this._addListener(eventName, 'on', fn); - this._clearCache(eventName); - } - - once (eventName, fn) { - this._addListener(eventName, 'once', fn); - this._clearCache(eventName); - } - - off (eventName, fn) { - const fns = this.listener[eventName]; - if (!fns) { - return - } - if (fn) { - for (let i = 0; i < fns.length;) { - if (fns[i].fn === fn) { - fns.splice(i, 1); - i--; - } - i++; - } - } else { - delete this.listener[eventName]; - } - } - - _clearCache (eventName) { - const cacheArgs = this.emitCache[eventName]; - if (cacheArgs) { - for (; cacheArgs.length > 0;) { - this.emit.apply(this, [eventName].concat(cacheArgs.shift())); - } - } - } - - _addListener (eventName, type, fn) { - (this.listener[eventName] || (this.listener[eventName] = [])).push({ - fn, - type - }); - } -} - const PAGE_EVENT_HOOKS = [ 'onPullDownRefresh', 'onReachBottom', @@ -1485,14 +1417,9 @@ function getEventChannel (id) { function createApp (vm) { Vue.prototype.getOpenerEventChannel = function () { - switch ("mp-weixin") { - case 'mp-weixin': - return this.$scope.getOpenerEventChannel() - default : - if (!this.__eventChannel__) { - this.__eventChannel__ = new EventChannel(); - } - return this.__eventChannel__ + // 微信小程序使用自身getOpenerEventChannel + { + return this.$scope.getOpenerEventChannel() } }; const callHook = Vue.prototype.__call_hook; diff --git a/packages/uni-quickapp-webview/dist/index.js b/packages/uni-quickapp-webview/dist/index.js index 8678f1b0649ed658683793b9a9cd8b86076d11fe..8bfa6f0bf259105cd004d2cf3bb4c309e6bdf13a 100644 --- a/packages/uni-quickapp-webview/dist/index.js +++ b/packages/uni-quickapp-webview/dist/index.js @@ -1552,15 +1552,10 @@ function parseApp (vm) { function createApp (vm) { Vue.prototype.getOpenerEventChannel = function () { - switch ("quickapp-webview") { - case 'mp-weixin': - return this.$scope.getOpenerEventChannel() - default : - if (!this.__eventChannel__) { - this.__eventChannel__ = new EventChannel(); - } - return this.__eventChannel__ + if (!this.__eventChannel__) { + this.__eventChannel__ = new EventChannel(); } + return this.__eventChannel__ }; const callHook = Vue.prototype.__call_hook; Vue.prototype.__call_hook = function (hook, args) {