提交 af2cdf51 编写于 作者: Q qiang

build runtime

上级 8fc4c312
......@@ -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) {
......
......@@ -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) {
......
......@@ -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) {
......
......@@ -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) {
......
......@@ -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) {
......
......@@ -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) {
......
......@@ -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;
......
......@@ -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) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册