提交 296da01b 编写于 作者: Q qiang

build runtime

上级 9120bfb0
......@@ -1434,10 +1434,15 @@ function getEventChannel (id) {
function createApp (vm) {
Vue.prototype.getOpenerEventChannel = function () {
if (!this.__eventChannel__) {
this.__eventChannel__ = new EventChannel();
switch ("app-plus") {
case 'mp-weixin':
return this.$scope.getOpenerEventChannel()
default :
if (!this.__eventChannel__) {
this.__eventChannel__ = new EventChannel();
}
return this.__eventChannel__
}
return this.__eventChannel__
};
const callHook = Vue.prototype.__call_hook;
Vue.prototype.__call_hook = function (hook, args) {
......
......@@ -2281,10 +2281,15 @@ function parseApp (vm) {
function createApp (vm) {
Vue.prototype.getOpenerEventChannel = function () {
if (!this.__eventChannel__) {
this.__eventChannel__ = new EventChannel();
switch ("mp-alipay") {
case 'mp-weixin':
return this.$scope.getOpenerEventChannel()
default :
if (!this.__eventChannel__) {
this.__eventChannel__ = new EventChannel();
}
return this.__eventChannel__
}
return this.__eventChannel__
};
const callHook = Vue.prototype.__call_hook;
Vue.prototype.__call_hook = function (hook, args) {
......
......@@ -1728,10 +1728,15 @@ function parseApp (vm) {
function createApp (vm) {
Vue.prototype.getOpenerEventChannel = function () {
if (!this.__eventChannel__) {
this.__eventChannel__ = new EventChannel();
switch ("mp-baidu") {
case 'mp-weixin':
return this.$scope.getOpenerEventChannel()
default :
if (!this.__eventChannel__) {
this.__eventChannel__ = new EventChannel();
}
return this.__eventChannel__
}
return this.__eventChannel__
};
const callHook = Vue.prototype.__call_hook;
Vue.prototype.__call_hook = function (hook, args) {
......
......@@ -1474,10 +1474,15 @@ function parseApp$1 (vm) {
function createApp (vm) {
Vue.prototype.getOpenerEventChannel = function () {
if (!this.__eventChannel__) {
this.__eventChannel__ = new EventChannel();
switch ("mp-kuaishou") {
case 'mp-weixin':
return this.$scope.getOpenerEventChannel()
default :
if (!this.__eventChannel__) {
this.__eventChannel__ = new EventChannel();
}
return this.__eventChannel__
}
return this.__eventChannel__
};
const callHook = Vue.prototype.__call_hook;
Vue.prototype.__call_hook = function (hook, args) {
......
......@@ -1640,10 +1640,15 @@ function parseApp$1 (vm) {
function createApp (vm) {
Vue.prototype.getOpenerEventChannel = function () {
if (!this.__eventChannel__) {
this.__eventChannel__ = new EventChannel();
switch ("mp-qq") {
case 'mp-weixin':
return this.$scope.getOpenerEventChannel()
default :
if (!this.__eventChannel__) {
this.__eventChannel__ = new EventChannel();
}
return this.__eventChannel__
}
return this.__eventChannel__
};
const callHook = Vue.prototype.__call_hook;
Vue.prototype.__call_hook = function (hook, args) {
......
......@@ -1807,10 +1807,15 @@ function parseApp (vm) {
function createApp (vm) {
Vue.prototype.getOpenerEventChannel = function () {
if (!this.__eventChannel__) {
this.__eventChannel__ = new EventChannel();
switch ("mp-toutiao") {
case 'mp-weixin':
return this.$scope.getOpenerEventChannel()
default :
if (!this.__eventChannel__) {
this.__eventChannel__ = new EventChannel();
}
return this.__eventChannel__
}
return this.__eventChannel__
};
const callHook = Vue.prototype.__call_hook;
Vue.prototype.__call_hook = function (hook, args) {
......
......@@ -356,111 +356,6 @@ var baseApi = /*#__PURE__*/Object.freeze({
interceptors: interceptors
});
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 eventChannels = {};
const eventChannelStack = [];
let id = 0;
function initEventChannel (events, cache = true) {
id++;
const eventChannel = new EventChannel(id, events);
if (cache) {
eventChannels[id] = eventChannel;
eventChannelStack.push(eventChannel);
}
return eventChannel
}
function getEventChannel (id) {
if (id) {
const eventChannel = eventChannels[id];
delete eventChannels[id];
return eventChannel
}
return eventChannelStack.shift()
}
var navigateTo = {
args (fromArgs, toArgs) {
const id = initEventChannel(fromArgs.events).id;
if (fromArgs.url) {
fromArgs.url = fromArgs.url + (fromArgs.url.indexOf('?') === -1 ? '?' : '&') + '__id__=' + id;
}
},
returnValue (fromRes, toRes) {
fromRes.eventChannel = getEventChannel();
}
};
function findExistsPageIndex (url) {
const pages = getCurrentPages();
let len = pages.length;
......@@ -527,6 +422,8 @@ var previewImage = {
}
};
// import navigateTo from 'uni-helpers/navigate-to'
function addSafeAreaInsets (result) {
if (result.safeArea) {
const safeArea = result.safeArea;
......@@ -540,7 +437,7 @@ function addSafeAreaInsets (result) {
}
const protocols = {
redirectTo,
navigateTo,
// navigateTo, // 由于在微信开发者工具的页面参数,会显示__id__参数,因此暂时关闭mp-weixin对于navigateTo的AOP
previewImage,
getSystemInfo: {
returnValue: addSafeAreaInsets
......@@ -790,6 +687,74 @@ 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',
......@@ -1505,12 +1470,30 @@ function parseApp (vm) {
})
}
const eventChannels = {};
const eventChannelStack = [];
function getEventChannel (id) {
if (id) {
const eventChannel = eventChannels[id];
delete eventChannels[id];
return eventChannel
}
return eventChannelStack.shift()
}
function createApp (vm) {
Vue.prototype.getOpenerEventChannel = function () {
if (!this.__eventChannel__) {
this.__eventChannel__ = new EventChannel();
switch ("mp-weixin") {
case 'mp-weixin':
return this.$scope.getOpenerEventChannel()
default :
if (!this.__eventChannel__) {
this.__eventChannel__ = new EventChannel();
}
return this.__eventChannel__
}
return this.__eventChannel__
};
const callHook = Vue.prototype.__call_hook;
Vue.prototype.__call_hook = function (hook, args) {
......
......@@ -1552,10 +1552,15 @@ function parseApp (vm) {
function createApp (vm) {
Vue.prototype.getOpenerEventChannel = function () {
if (!this.__eventChannel__) {
this.__eventChannel__ = new EventChannel();
switch ("quickapp-webview") {
case 'mp-weixin':
return this.$scope.getOpenerEventChannel()
default :
if (!this.__eventChannel__) {
this.__eventChannel__ = new EventChannel();
}
return this.__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.
先完成此消息的编辑!
想要评论请 注册