提交 df9fc217 编写于 作者: fxy060608's avatar fxy060608

fix(mp): i18n

上级 ce314ac1
import Vue from 'vue';
import { initVueI18n } from '@dcloudio/uni-i18n';
let realAtob;
const b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
const b64re = /^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;
if (typeof atob !== 'function') {
realAtob = function (str) {
str = String(str).replace(/[\t\n\f\r ]+/g, '');
if (!b64re.test(str)) { throw new Error("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.") }
// Adding the padding if missing, for semplicity
str += '=='.slice(2 - (str.length & 3));
var bitmap; var result = ''; var r1; var r2; var i = 0;
for (; i < str.length;) {
bitmap = b64.indexOf(str.charAt(i++)) << 18 | b64.indexOf(str.charAt(i++)) << 12 |
(r1 = b64.indexOf(str.charAt(i++))) << 6 | (r2 = b64.indexOf(str.charAt(i++)));
result += r1 === 64 ? String.fromCharCode(bitmap >> 16 & 255)
: r2 === 64 ? String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255)
: String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255, bitmap & 255);
}
return result
};
} else {
// 注意atob只能在全局对象上调用,例如:`const Base64 = {atob};Base64.atob('xxxx')`是错误的用法
realAtob = atob;
}
function b64DecodeUnicode (str) {
return decodeURIComponent(atob(str).split('').map(function (c) {
return decodeURIComponent(realAtob(str).split('').map(function (c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2)
}).join(''))
}
......@@ -431,6 +459,10 @@ function onLocaleChange (fn) {
if (onLocaleChangeCallbacks.indexOf(fn) === -1) {
onLocaleChangeCallbacks.push(fn);
}
}
if (typeof global !== 'undefined') {
global.getLocale = getLocale;
}
const interceptors = {
......@@ -1304,7 +1336,9 @@ var en = {
"uni.video.danmu": "Danmu",
"uni.video.volume": "Volume",
"uni.button.feedback.title": "feedback",
"uni.button.feedback.send": "send"
"uni.button.feedback.send": "send",
"uni.chooseLocation.search": "Find Place",
"uni.chooseLocation.cancel": "Cancel"
};
var es = {
......@@ -1337,7 +1371,9 @@ var es = {
"uni.video.danmu": "Danmu",
"uni.video.volume": "Volumen",
"uni.button.feedback.title": "realimentación",
"uni.button.feedback.send": "enviar"
"uni.button.feedback.send": "enviar",
"uni.chooseLocation.search": "Encontrar",
"uni.chooseLocation.cancel": "Cancelar"
};
var fr = {
......@@ -1370,7 +1406,9 @@ var fr = {
"uni.video.danmu": "Danmu",
"uni.video.volume": "Le Volume",
"uni.button.feedback.title": "retour d'information",
"uni.button.feedback.send": "envoyer"
"uni.button.feedback.send": "envoyer",
"uni.chooseLocation.search": "Trouve",
"uni.chooseLocation.cancel": "Annuler"
};
var zhHans = {
......@@ -1403,7 +1441,9 @@ var zhHans = {
"uni.video.danmu": "弹幕",
"uni.video.volume": "音量",
"uni.button.feedback.title": "问题反馈",
"uni.button.feedback.send": "发送"
"uni.button.feedback.send": "发送",
"uni.chooseLocation.search": "搜索地点",
"uni.chooseLocation.cancel": "取消"
};
var zhHant = {
......@@ -1436,7 +1476,9 @@ var zhHant = {
"uni.video.danmu": "彈幕",
"uni.video.volume": "音量",
"uni.button.feedback.title": "問題反饋",
"uni.button.feedback.send": "發送"
"uni.button.feedback.send": "發送",
"uni.chooseLocation.search": "搜索地點",
"uni.chooseLocation.cancel": "取消"
};
const messages = {
......@@ -1452,12 +1494,17 @@ let locale;
{
if (typeof weex === 'object') {
locale = weex.requireModule('plus').getLanguage();
} else {
locale = '';
}
}
const i18n = initVueI18n(locale, messages );
const i18n = initVueI18n(
locale,
messages
);
const t = i18n.t;
const i18nMixin = i18n.mixin = {
const i18nMixin = (i18n.mixin = {
beforeCreate () {
const unwatch = i18n.i18n.watchLocale(() => {
this.$forceUpdate();
......@@ -1471,7 +1518,7 @@ const i18nMixin = i18n.mixin = {
return t(key, values)
}
}
};
});
const setLocale$1 = i18n.setLocale;
const getLocale$1 = i18n.getLocale;
......@@ -1480,7 +1527,7 @@ function initAppLocale (Vue, appVm, locale) {
locale: locale || i18n.getLocale()
});
const localeWatchers = [];
appVm.$watchLocale = (fn) => {
appVm.$watchLocale = fn => {
localeWatchers.push(fn);
};
Object.defineProperty(appVm, '$locale', {
......@@ -1575,112 +1622,112 @@ function getEventChannel (id) {
return eventChannelStack.shift()
}
const hooks = [
'onShow',
'onHide',
'onError',
'onPageNotFound',
'onThemeChange',
'onUnhandledRejection'
];
function initEventChannel () {
Vue.prototype.getOpenerEventChannel = function () {
if (!this.__eventChannel__) {
this.__eventChannel__ = new EventChannel();
}
return this.__eventChannel__
};
const callHook = Vue.prototype.__call_hook;
Vue.prototype.__call_hook = function (hook, args) {
if (hook === 'onLoad' && args && args.__id__) {
this.__eventChannel__ = getEventChannel(args.__id__);
delete args.__id__;
}
return callHook.call(this, hook, args)
};
}
function parseBaseApp (vm, {
mocks,
initRefs
}) {
initEventChannel();
if (vm.$options.store) {
Vue.prototype.$store = vm.$options.store;
}
uniIdMixin(Vue);
Vue.prototype.mpHost = "app-plus";
Vue.mixin({
beforeCreate () {
if (!this.$options.mpType) {
return
}
this.mpType = this.$options.mpType;
this.$mp = {
data: {},
[this.mpType]: this.$options.mpInstance
};
this.$scope = this.$options.mpInstance;
delete this.$options.mpType;
delete this.$options.mpInstance;
if (this.mpType === 'page' && typeof getApp === 'function') { // hack vue-i18n
const app = getApp();
if (app.$vm && app.$vm.$i18n) {
this._i18n = app.$vm.$i18n;
}
}
if (this.mpType !== 'app') {
initRefs(this);
initMocks(this, mocks);
}
}
});
const appOptions = {
onLaunch (args) {
if (this.$vm) { // 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return
}
this.$vm = vm;
this.$vm.$mp = {
app: this
};
this.$vm.$scope = this;
// vm 上也挂载 globalData
this.$vm.globalData = this.globalData;
this.$vm._isMounted = true;
this.$vm.__call_hook('mounted', args);
this.$vm.__call_hook('onLaunch', args);
}
};
// 兼容旧版本 globalData
appOptions.globalData = vm.$options.globalData || {};
// 将 methods 中的方法挂在 getApp() 中
const methods = vm.$options.methods;
if (methods) {
Object.keys(methods).forEach(name => {
appOptions[name] = methods[name];
});
}
initAppLocale(Vue, vm, wx.getSystemInfoSync().language || 'zh-Hans');
initHooks(appOptions, hooks);
return appOptions
const hooks = [
'onShow',
'onHide',
'onError',
'onPageNotFound',
'onThemeChange',
'onUnhandledRejection'
];
function initEventChannel () {
Vue.prototype.getOpenerEventChannel = function () {
if (!this.__eventChannel__) {
this.__eventChannel__ = new EventChannel();
}
return this.__eventChannel__
};
const callHook = Vue.prototype.__call_hook;
Vue.prototype.__call_hook = function (hook, args) {
if (hook === 'onLoad' && args && args.__id__) {
this.__eventChannel__ = getEventChannel(args.__id__);
delete args.__id__;
}
return callHook.call(this, hook, args)
};
}
function parseBaseApp (vm, {
mocks,
initRefs
}) {
initEventChannel();
if (vm.$options.store) {
Vue.prototype.$store = vm.$options.store;
}
uniIdMixin(Vue);
Vue.prototype.mpHost = "app-plus";
Vue.mixin({
beforeCreate () {
if (!this.$options.mpType) {
return
}
this.mpType = this.$options.mpType;
this.$mp = {
data: {},
[this.mpType]: this.$options.mpInstance
};
this.$scope = this.$options.mpInstance;
delete this.$options.mpType;
delete this.$options.mpInstance;
if (this.mpType === 'page' && typeof getApp === 'function') { // hack vue-i18n
const app = getApp();
if (app.$vm && app.$vm.$i18n) {
this._i18n = app.$vm.$i18n;
}
}
if (this.mpType !== 'app') {
initRefs(this);
initMocks(this, mocks);
}
}
});
const appOptions = {
onLaunch (args) {
if (this.$vm) { // 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return
}
this.$vm = vm;
this.$vm.$mp = {
app: this
};
this.$vm.$scope = this;
// vm 上也挂载 globalData
this.$vm.globalData = this.globalData;
this.$vm._isMounted = true;
this.$vm.__call_hook('mounted', args);
this.$vm.__call_hook('onLaunch', args);
}
};
// 兼容旧版本 globalData
appOptions.globalData = vm.$options.globalData || {};
// 将 methods 中的方法挂在 getApp() 中
const methods = vm.$options.methods;
if (methods) {
Object.keys(methods).forEach(name => {
appOptions[name] = methods[name];
});
}
initAppLocale(Vue, vm, wx.getSystemInfoSync().language || 'zh-Hans');
initHooks(appOptions, hooks);
return appOptions
}
const mocks = ['__route__', '__wxExparserNodeId__', '__wxWebviewId__'];
......
......@@ -126,10 +126,10 @@ function normalizeLocale(locale, messages) {
}
locale = locale.toLowerCase();
if (locale.indexOf('zh') === 0) {
if (locale.indexOf('-hans') !== -1) {
if (locale.indexOf('-hans') > -1) {
return LOCALE_ZH_HANS;
}
if (locale.indexOf('-hant') !== -1) {
if (locale.indexOf('-hant') > -1) {
return LOCALE_ZH_HANT;
}
if (include(locale, ['-tw', '-hk', '-mo', '-cht'])) {
......@@ -221,11 +221,29 @@ class I18n {
}
}
const ignoreVueI18n = true;
function watchAppLocale(appVm, i18n) {
appVm.$watch(() => appVm.$locale, (newLocale) => {
i18n.setLocale(newLocale);
});
// 需要保证 watch 的触发在组件渲染之前
if (appVm.$watchLocale) {
// vue2
appVm.$watchLocale((newLocale) => {
i18n.setLocale(newLocale);
});
}
else {
appVm.$watch(() => appVm.$locale, (newLocale) => {
i18n.setLocale(newLocale);
});
}
}
function getDefaultLocale() {
if (typeof uni !== 'undefined' && uni.getLocale) {
return uni.getLocale();
}
// 小程序平台,uni 和 uni-i18n 互相引用,导致访问不到 uni,故在 global 上挂了 getLocale
if (typeof global !== 'undefined' && global.getLocale) {
return global.getLocale();
}
return LOCALE_EN;
}
function initVueI18n(locale, messages = {}, fallbackLocale, watcher) {
// 兼容旧版本入参
......@@ -236,9 +254,8 @@ function initVueI18n(locale, messages = {}, fallbackLocale, watcher) {
];
}
if (typeof locale !== 'string') {
locale =
(typeof uni !== 'undefined' && uni.getLocale && uni.getLocale()) ||
LOCALE_EN;
// 因为小程序平台,uni-i18n 和 uni 互相引用,导致此时访问 uni 时,为 undefined
locale = getDefaultLocale();
}
if (typeof fallbackLocale !== 'string') {
fallbackLocale =
......@@ -260,33 +277,32 @@ function initVueI18n(locale, messages = {}, fallbackLocale, watcher) {
};
}
else {
const appVm = getApp().$vm;
watchAppLocale(appVm, i18n);
if (!appVm.$t || !appVm.$i18n || ignoreVueI18n) {
// if (!locale) {
// i18n.setLocale(getDefaultLocale())
// }
/* eslint-disable no-func-assign */
t = function (key, values) {
let isWatchedAppLocale = false;
t = function (key, values) {
const appVm = getApp().$vm;
// 可能$vm还不存在,比如在支付宝小程序中,组件定义较早,在props的default里使用了t()函数(如uni-goods-nav),此时app还未初始化
// options: {
// type: Array,
// default () {
// return [{
// icon: 'shop',
// text: t("uni-goods-nav.options.shop"),
// }, {
// icon: 'cart',
// text: t("uni-goods-nav.options.cart")
// }]
// }
// },
if (appVm) {
// 触发响应式
appVm.$locale;
return i18n.t(key, values);
};
}
else {
/* eslint-disable no-func-assign */
t = function (key, values) {
const $i18n = appVm.$i18n;
const silentTranslationWarn = $i18n.silentTranslationWarn;
$i18n.silentTranslationWarn = true;
const msg = appVm.$t(key, values);
$i18n.silentTranslationWarn = silentTranslationWarn;
if (msg !== key) {
return msg;
if (!isWatchedAppLocale) {
isWatchedAppLocale = true;
watchAppLocale(appVm, i18n);
}
return i18n.t(key, $i18n.locale, values);
};
}
}
return i18n.t(key, values);
};
}
return t(key, values);
};
......@@ -420,6 +436,25 @@ function walkJsonObj(jsonObj, walk) {
return false;
}
function resolveLocale(locales) {
return (locale) => {
if (!locale) {
return locale;
}
locale = normalizeLocale(locale) || locale;
return resolveLocaleChain(locale).find((locale) => locales.indexOf(locale) > -1);
};
}
function resolveLocaleChain(locale) {
const chain = [];
const tokens = locale.split('-');
while (tokens.length) {
chain.push(tokens.join('-'));
tokens.pop();
}
return chain;
}
exports.Formatter = BaseFormatter;
exports.I18n = I18n;
exports.LOCALE_EN = LOCALE_EN;
......@@ -434,3 +469,4 @@ exports.isI18nStr = isI18nStr;
exports.isString = isString;
exports.normalizeLocale = normalizeLocale;
exports.parseI18nJson = parseI18nJson;
exports.resolveLocale = resolveLocale;
......@@ -59,6 +59,8 @@ export declare function isI18nStr(value: string, delimiters: [string, string]):
export declare const isString: (val: unknown) => val is string;
declare type Locale = string;
export declare const LOCALE_EN = "en";
export declare const LOCALE_ES = "es";
......@@ -77,6 +79,8 @@ export declare function normalizeLocale(locale: string, messages?: LocaleMessage
export declare function parseI18nJson(jsonObj: unknown, values: Record<string, string>, delimiters: [string, string]): unknown;
export declare function resolveLocale(locales: Locale[]): (locale: Locale) => string | undefined;
declare type Token = {
type: 'text' | 'named' | 'list' | 'unknown';
value: string;
......
......@@ -122,10 +122,10 @@ function normalizeLocale(locale, messages) {
}
locale = locale.toLowerCase();
if (locale.indexOf('zh') === 0) {
if (locale.indexOf('-hans') !== -1) {
if (locale.indexOf('-hans') > -1) {
return LOCALE_ZH_HANS;
}
if (locale.indexOf('-hant') !== -1) {
if (locale.indexOf('-hant') > -1) {
return LOCALE_ZH_HANT;
}
if (include(locale, ['-tw', '-hk', '-mo', '-cht'])) {
......@@ -217,11 +217,29 @@ class I18n {
}
}
const ignoreVueI18n = true;
function watchAppLocale(appVm, i18n) {
appVm.$watch(() => appVm.$locale, (newLocale) => {
i18n.setLocale(newLocale);
});
// 需要保证 watch 的触发在组件渲染之前
if (appVm.$watchLocale) {
// vue2
appVm.$watchLocale((newLocale) => {
i18n.setLocale(newLocale);
});
}
else {
appVm.$watch(() => appVm.$locale, (newLocale) => {
i18n.setLocale(newLocale);
});
}
}
function getDefaultLocale() {
if (typeof uni !== 'undefined' && uni.getLocale) {
return uni.getLocale();
}
// 小程序平台,uni 和 uni-i18n 互相引用,导致访问不到 uni,故在 global 上挂了 getLocale
if (typeof global !== 'undefined' && global.getLocale) {
return global.getLocale();
}
return LOCALE_EN;
}
function initVueI18n(locale, messages = {}, fallbackLocale, watcher) {
// 兼容旧版本入参
......@@ -232,9 +250,8 @@ function initVueI18n(locale, messages = {}, fallbackLocale, watcher) {
];
}
if (typeof locale !== 'string') {
locale =
(typeof uni !== 'undefined' && uni.getLocale && uni.getLocale()) ||
LOCALE_EN;
// 因为小程序平台,uni-i18n 和 uni 互相引用,导致此时访问 uni 时,为 undefined
locale = getDefaultLocale();
}
if (typeof fallbackLocale !== 'string') {
fallbackLocale =
......@@ -256,33 +273,32 @@ function initVueI18n(locale, messages = {}, fallbackLocale, watcher) {
};
}
else {
const appVm = getApp().$vm;
watchAppLocale(appVm, i18n);
if (!appVm.$t || !appVm.$i18n || ignoreVueI18n) {
// if (!locale) {
// i18n.setLocale(getDefaultLocale())
// }
/* eslint-disable no-func-assign */
t = function (key, values) {
let isWatchedAppLocale = false;
t = function (key, values) {
const appVm = getApp().$vm;
// 可能$vm还不存在,比如在支付宝小程序中,组件定义较早,在props的default里使用了t()函数(如uni-goods-nav),此时app还未初始化
// options: {
// type: Array,
// default () {
// return [{
// icon: 'shop',
// text: t("uni-goods-nav.options.shop"),
// }, {
// icon: 'cart',
// text: t("uni-goods-nav.options.cart")
// }]
// }
// },
if (appVm) {
// 触发响应式
appVm.$locale;
return i18n.t(key, values);
};
}
else {
/* eslint-disable no-func-assign */
t = function (key, values) {
const $i18n = appVm.$i18n;
const silentTranslationWarn = $i18n.silentTranslationWarn;
$i18n.silentTranslationWarn = true;
const msg = appVm.$t(key, values);
$i18n.silentTranslationWarn = silentTranslationWarn;
if (msg !== key) {
return msg;
if (!isWatchedAppLocale) {
isWatchedAppLocale = true;
watchAppLocale(appVm, i18n);
}
return i18n.t(key, $i18n.locale, values);
};
}
}
return i18n.t(key, values);
};
}
return t(key, values);
};
......@@ -416,4 +432,23 @@ function walkJsonObj(jsonObj, walk) {
return false;
}
export { BaseFormatter as Formatter, I18n, LOCALE_EN, LOCALE_ES, LOCALE_FR, LOCALE_ZH_HANS, LOCALE_ZH_HANT, compileI18nJsonStr, hasI18nJson, initVueI18n, isI18nStr, isString, normalizeLocale, parseI18nJson };
function resolveLocale(locales) {
return (locale) => {
if (!locale) {
return locale;
}
locale = normalizeLocale(locale) || locale;
return resolveLocaleChain(locale).find((locale) => locales.indexOf(locale) > -1);
};
}
function resolveLocaleChain(locale) {
const chain = [];
const tokens = locale.split('-');
while (tokens.length) {
chain.push(tokens.join('-'));
tokens.pop();
}
return chain;
}
export { BaseFormatter as Formatter, I18n, LOCALE_EN, LOCALE_ES, LOCALE_FR, LOCALE_ZH_HANS, LOCALE_ZH_HANT, compileI18nJsonStr, hasI18nJson, initVueI18n, isI18nStr, isString, normalizeLocale, parseI18nJson, resolveLocale };
import Vue from 'vue';
import { initVueI18n } from '@dcloudio/uni-i18n';
let realAtob;
const b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
const b64re = /^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;
if (typeof atob !== 'function') {
realAtob = function (str) {
str = String(str).replace(/[\t\n\f\r ]+/g, '');
if (!b64re.test(str)) { throw new Error("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.") }
// Adding the padding if missing, for semplicity
str += '=='.slice(2 - (str.length & 3));
var bitmap; var result = ''; var r1; var r2; var i = 0;
for (; i < str.length;) {
bitmap = b64.indexOf(str.charAt(i++)) << 18 | b64.indexOf(str.charAt(i++)) << 12 |
(r1 = b64.indexOf(str.charAt(i++))) << 6 | (r2 = b64.indexOf(str.charAt(i++)));
result += r1 === 64 ? String.fromCharCode(bitmap >> 16 & 255)
: r2 === 64 ? String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255)
: String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255, bitmap & 255);
}
return result
};
} else {
// 注意atob只能在全局对象上调用,例如:`const Base64 = {atob};Base64.atob('xxxx')`是错误的用法
realAtob = atob;
}
function b64DecodeUnicode (str) {
return decodeURIComponent(atob(str).split('').map(function (c) {
return decodeURIComponent(realAtob(str).split('').map(function (c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2)
}).join(''))
}
......@@ -431,6 +459,10 @@ function onLocaleChange (fn) {
if (onLocaleChangeCallbacks.indexOf(fn) === -1) {
onLocaleChangeCallbacks.push(fn);
}
}
if (typeof global !== 'undefined') {
global.getLocale = getLocale;
}
const interceptors = {
......@@ -2025,9 +2057,12 @@ let locale;
locale = my.getSystemInfoSync().language;
}
const i18n = initVueI18n(locale, {});
const i18n = initVueI18n(
locale,
{}
);
const t = i18n.t;
const i18nMixin = i18n.mixin = {
const i18nMixin = (i18n.mixin = {
beforeCreate () {
const unwatch = i18n.i18n.watchLocale(() => {
this.$forceUpdate();
......@@ -2041,7 +2076,7 @@ const i18nMixin = i18n.mixin = {
return t(key, values)
}
}
};
});
const setLocale$1 = i18n.setLocale;
const getLocale$1 = i18n.getLocale;
......@@ -2050,7 +2085,7 @@ function initAppLocale (Vue, appVm, locale) {
locale: locale || i18n.getLocale()
});
const localeWatchers = [];
appVm.$watchLocale = (fn) => {
appVm.$watchLocale = fn => {
localeWatchers.push(fn);
};
Object.defineProperty(appVm, '$locale', {
......@@ -2064,167 +2099,171 @@ function initAppLocale (Vue, appVm, locale) {
});
}
const hooks = [
'onShow',
'onHide',
'onError',
'onPageNotFound',
'onThemeChange',
'onUnhandledRejection'
];
function initEventChannel$1 () {
Vue.prototype.getOpenerEventChannel = function () {
if (!this.__eventChannel__) {
this.__eventChannel__ = new EventChannel();
}
return this.__eventChannel__
};
const callHook = Vue.prototype.__call_hook;
Vue.prototype.__call_hook = function (hook, args) {
if (hook === 'onLoad' && args && args.__id__) {
this.__eventChannel__ = getEventChannel(args.__id__);
delete args.__id__;
}
return callHook.call(this, hook, args)
};
}
function initScopedSlotsParams () {
const center = {};
const parents = {};
Vue.prototype.$hasScopedSlotsParams = function (vueId) {
const has = center[vueId];
if (!has) {
parents[vueId] = this;
this.$on('hook:destory', () => {
delete parents[vueId];
});
}
return has
};
Vue.prototype.$getScopedSlotsParams = function (vueId, name, key) {
const data = center[vueId];
if (data) {
const object = data[name] || {};
return key ? object[key] : object
} else {
parents[vueId] = this;
this.$on('hook:destory', () => {
delete parents[vueId];
});
}
};
Vue.prototype.$setScopedSlotsParams = function (name, value) {
const vueIds = this.$options.propsData.vueId;
if (vueIds) {
const vueId = vueIds.split(',')[0];
const object = center[vueId] = center[vueId] || {};
object[name] = value;
if (parents[vueId]) {
parents[vueId].$forceUpdate();
}
}
};
Vue.mixin({
destroyed () {
const propsData = this.$options.propsData;
const vueId = propsData && propsData.vueId;
if (vueId) {
delete center[vueId];
delete parents[vueId];
}
}
});
}
function parseBaseApp (vm, {
mocks,
initRefs
}) {
initEventChannel$1();
{
initScopedSlotsParams();
}
if (vm.$options.store) {
Vue.prototype.$store = vm.$options.store;
}
uniIdMixin(Vue);
Vue.prototype.mpHost = "mp-alipay";
Vue.mixin({
beforeCreate () {
if (!this.$options.mpType) {
return
}
this.mpType = this.$options.mpType;
this.$mp = {
data: {},
[this.mpType]: this.$options.mpInstance
};
this.$scope = this.$options.mpInstance;
delete this.$options.mpType;
delete this.$options.mpInstance;
if (this.mpType === 'page' && typeof getApp === 'function') { // hack vue-i18n
const app = getApp();
if (app.$vm && app.$vm.$i18n) {
this._i18n = app.$vm.$i18n;
}
}
if (this.mpType !== 'app') {
initRefs(this);
initMocks(this, mocks);
}
}
});
const appOptions = {
onLaunch (args) {
if (this.$vm) { // 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return
}
this.$vm = vm;
this.$vm.$mp = {
app: this
};
this.$vm.$scope = this;
// vm 上也挂载 globalData
this.$vm.globalData = this.globalData;
this.$vm._isMounted = true;
this.$vm.__call_hook('mounted', args);
this.$vm.__call_hook('onLaunch', args);
}
};
// 兼容旧版本 globalData
appOptions.globalData = vm.$options.globalData || {};
// 将 methods 中的方法挂在 getApp() 中
const methods = vm.$options.methods;
if (methods) {
Object.keys(methods).forEach(name => {
appOptions[name] = methods[name];
});
}
initAppLocale(Vue, vm, my.getSystemInfoSync().language || 'zh-Hans');
initHooks(appOptions, hooks);
return appOptions
const hooks = [
'onShow',
'onHide',
'onError',
'onPageNotFound',
'onThemeChange',
'onUnhandledRejection'
];
{
hooks.push('onShareAppMessage');
}
function initEventChannel$1 () {
Vue.prototype.getOpenerEventChannel = function () {
if (!this.__eventChannel__) {
this.__eventChannel__ = new EventChannel();
}
return this.__eventChannel__
};
const callHook = Vue.prototype.__call_hook;
Vue.prototype.__call_hook = function (hook, args) {
if (hook === 'onLoad' && args && args.__id__) {
this.__eventChannel__ = getEventChannel(args.__id__);
delete args.__id__;
}
return callHook.call(this, hook, args)
};
}
function initScopedSlotsParams () {
const center = {};
const parents = {};
Vue.prototype.$hasScopedSlotsParams = function (vueId) {
const has = center[vueId];
if (!has) {
parents[vueId] = this;
this.$on('hook:destory', () => {
delete parents[vueId];
});
}
return has
};
Vue.prototype.$getScopedSlotsParams = function (vueId, name, key) {
const data = center[vueId];
if (data) {
const object = data[name] || {};
return key ? object[key] : object
} else {
parents[vueId] = this;
this.$on('hook:destory', () => {
delete parents[vueId];
});
}
};
Vue.prototype.$setScopedSlotsParams = function (name, value) {
const vueIds = this.$options.propsData.vueId;
if (vueIds) {
const vueId = vueIds.split(',')[0];
const object = center[vueId] = center[vueId] || {};
object[name] = value;
if (parents[vueId]) {
parents[vueId].$forceUpdate();
}
}
};
Vue.mixin({
destroyed () {
const propsData = this.$options.propsData;
const vueId = propsData && propsData.vueId;
if (vueId) {
delete center[vueId];
delete parents[vueId];
}
}
});
}
function parseBaseApp (vm, {
mocks,
initRefs
}) {
initEventChannel$1();
{
initScopedSlotsParams();
}
if (vm.$options.store) {
Vue.prototype.$store = vm.$options.store;
}
uniIdMixin(Vue);
Vue.prototype.mpHost = "mp-alipay";
Vue.mixin({
beforeCreate () {
if (!this.$options.mpType) {
return
}
this.mpType = this.$options.mpType;
this.$mp = {
data: {},
[this.mpType]: this.$options.mpInstance
};
this.$scope = this.$options.mpInstance;
delete this.$options.mpType;
delete this.$options.mpInstance;
if (this.mpType === 'page' && typeof getApp === 'function') { // hack vue-i18n
const app = getApp();
if (app.$vm && app.$vm.$i18n) {
this._i18n = app.$vm.$i18n;
}
}
if (this.mpType !== 'app') {
initRefs(this);
initMocks(this, mocks);
}
}
});
const appOptions = {
onLaunch (args) {
if (this.$vm) { // 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return
}
this.$vm = vm;
this.$vm.$mp = {
app: this
};
this.$vm.$scope = this;
// vm 上也挂载 globalData
this.$vm.globalData = this.globalData;
this.$vm._isMounted = true;
this.$vm.__call_hook('mounted', args);
this.$vm.__call_hook('onLaunch', args);
}
};
// 兼容旧版本 globalData
appOptions.globalData = vm.$options.globalData || {};
// 将 methods 中的方法挂在 getApp() 中
const methods = vm.$options.methods;
if (methods) {
Object.keys(methods).forEach(name => {
appOptions[name] = methods[name];
});
}
initAppLocale(Vue, vm, my.getSystemInfoSync().language || 'zh-Hans');
initHooks(appOptions, hooks);
return appOptions
}
function findVmByVueId (vm, vuePid) {
......
......@@ -473,7 +473,8 @@ const removeInterceptor = defineSyncApi(API_REMOVE_INTERCEPTOR, (method, interce
else if (isPlainObject(method)) {
removeInterceptorHook(globalInterceptors, method);
}
}, RemoveInterceptorProtocol);
}, RemoveInterceptorProtocol);
const interceptors = {};
const API_ON = '$on';
const OnProtocol = [
......@@ -753,7 +754,10 @@ const onLocaleChange = (fn) => {
if (onLocaleChangeCallbacks.indexOf(fn) === -1) {
onLocaleChangeCallbacks.push(fn);
}
};
};
if (typeof global !== 'undefined') {
global.getLocale = getLocale;
}
const baseApis = {
$on,
......@@ -761,6 +765,7 @@ const baseApis = {
$once,
$emit,
upx2px,
interceptors,
addInterceptor,
removeInterceptor,
onAppLaunch,
......
......@@ -55,6 +55,7 @@ const ON_TAB_ITEM_TAP = 'onTabItemTap';
const ON_REACH_BOTTOM = 'onReachBottom';
const ON_PULL_DOWN_REFRESH = 'onPullDownRefresh';
const ON_ADD_TO_FAVORITES = 'onAddToFavorites';
const ON_SHARE_APP_MESSAGE = 'onShareAppMessage';
class EventChannel {
constructor(id, events) {
......@@ -557,6 +558,9 @@ const HOOKS = [
ON_PAGE_NOT_FOUND,
ON_UNHANDLE_REJECTION,
];
{
HOOKS.push(ON_SHARE_APP_MESSAGE);
}
function parseApp(instance, parseAppOptions) {
const internalInstance = instance.$;
const appOptions = {
......
import Vue from 'vue';
import { initVueI18n } from '@dcloudio/uni-i18n';
let realAtob;
const b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
const b64re = /^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;
if (typeof atob !== 'function') {
realAtob = function (str) {
str = String(str).replace(/[\t\n\f\r ]+/g, '');
if (!b64re.test(str)) { throw new Error("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.") }
// Adding the padding if missing, for semplicity
str += '=='.slice(2 - (str.length & 3));
var bitmap; var result = ''; var r1; var r2; var i = 0;
for (; i < str.length;) {
bitmap = b64.indexOf(str.charAt(i++)) << 18 | b64.indexOf(str.charAt(i++)) << 12 |
(r1 = b64.indexOf(str.charAt(i++))) << 6 | (r2 = b64.indexOf(str.charAt(i++)));
result += r1 === 64 ? String.fromCharCode(bitmap >> 16 & 255)
: r2 === 64 ? String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255)
: String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255, bitmap & 255);
}
return result
};
} else {
// 注意atob只能在全局对象上调用,例如:`const Base64 = {atob};Base64.atob('xxxx')`是错误的用法
realAtob = atob;
}
function b64DecodeUnicode (str) {
return decodeURIComponent(atob(str).split('').map(function (c) {
return decodeURIComponent(realAtob(str).split('').map(function (c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2)
}).join(''))
}
......@@ -431,6 +459,10 @@ function onLocaleChange (fn) {
if (onLocaleChangeCallbacks.indexOf(fn) === -1) {
onLocaleChangeCallbacks.push(fn);
}
}
if (typeof global !== 'undefined') {
global.getLocale = getLocale;
}
const interceptors = {
......@@ -1703,9 +1735,12 @@ let locale;
locale = swan.getSystemInfoSync().language;
}
const i18n = initVueI18n(locale, {});
const i18n = initVueI18n(
locale,
{}
);
const t = i18n.t;
const i18nMixin = i18n.mixin = {
const i18nMixin = (i18n.mixin = {
beforeCreate () {
const unwatch = i18n.i18n.watchLocale(() => {
this.$forceUpdate();
......@@ -1719,7 +1754,7 @@ const i18nMixin = i18n.mixin = {
return t(key, values)
}
}
};
});
const setLocale$1 = i18n.setLocale;
const getLocale$1 = i18n.getLocale;
......@@ -1728,7 +1763,7 @@ function initAppLocale (Vue, appVm, locale) {
locale: locale || i18n.getLocale()
});
const localeWatchers = [];
appVm.$watchLocale = (fn) => {
appVm.$watchLocale = fn => {
localeWatchers.push(fn);
};
Object.defineProperty(appVm, '$locale', {
......@@ -1742,167 +1777,167 @@ function initAppLocale (Vue, appVm, locale) {
});
}
const hooks = [
'onShow',
'onHide',
'onError',
'onPageNotFound',
'onThemeChange',
'onUnhandledRejection'
];
function initEventChannel$1 () {
Vue.prototype.getOpenerEventChannel = function () {
if (!this.__eventChannel__) {
this.__eventChannel__ = new EventChannel();
}
return this.__eventChannel__
};
const callHook = Vue.prototype.__call_hook;
Vue.prototype.__call_hook = function (hook, args) {
if (hook === 'onLoad' && args && args.__id__) {
this.__eventChannel__ = getEventChannel(args.__id__);
delete args.__id__;
}
return callHook.call(this, hook, args)
};
}
function initScopedSlotsParams () {
const center = {};
const parents = {};
Vue.prototype.$hasScopedSlotsParams = function (vueId) {
const has = center[vueId];
if (!has) {
parents[vueId] = this;
this.$on('hook:destory', () => {
delete parents[vueId];
});
}
return has
};
Vue.prototype.$getScopedSlotsParams = function (vueId, name, key) {
const data = center[vueId];
if (data) {
const object = data[name] || {};
return key ? object[key] : object
} else {
parents[vueId] = this;
this.$on('hook:destory', () => {
delete parents[vueId];
});
}
};
Vue.prototype.$setScopedSlotsParams = function (name, value) {
const vueIds = this.$options.propsData.vueId;
if (vueIds) {
const vueId = vueIds.split(',')[0];
const object = center[vueId] = center[vueId] || {};
object[name] = value;
if (parents[vueId]) {
parents[vueId].$forceUpdate();
}
}
};
Vue.mixin({
destroyed () {
const propsData = this.$options.propsData;
const vueId = propsData && propsData.vueId;
if (vueId) {
delete center[vueId];
delete parents[vueId];
}
}
});
}
function parseBaseApp (vm, {
mocks,
initRefs
}) {
initEventChannel$1();
{
initScopedSlotsParams();
}
if (vm.$options.store) {
Vue.prototype.$store = vm.$options.store;
}
uniIdMixin(Vue);
Vue.prototype.mpHost = "mp-baidu";
Vue.mixin({
beforeCreate () {
if (!this.$options.mpType) {
return
}
this.mpType = this.$options.mpType;
this.$mp = {
data: {},
[this.mpType]: this.$options.mpInstance
};
this.$scope = this.$options.mpInstance;
delete this.$options.mpType;
delete this.$options.mpInstance;
if (this.mpType === 'page' && typeof getApp === 'function') { // hack vue-i18n
const app = getApp();
if (app.$vm && app.$vm.$i18n) {
this._i18n = app.$vm.$i18n;
}
}
if (this.mpType !== 'app') {
initRefs(this);
initMocks(this, mocks);
}
}
});
const appOptions = {
onLaunch (args) {
if (this.$vm) { // 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return
}
this.$vm = vm;
this.$vm.$mp = {
app: this
};
this.$vm.$scope = this;
// vm 上也挂载 globalData
this.$vm.globalData = this.globalData;
this.$vm._isMounted = true;
this.$vm.__call_hook('mounted', args);
this.$vm.__call_hook('onLaunch', args);
}
};
// 兼容旧版本 globalData
appOptions.globalData = vm.$options.globalData || {};
// 将 methods 中的方法挂在 getApp() 中
const methods = vm.$options.methods;
if (methods) {
Object.keys(methods).forEach(name => {
appOptions[name] = methods[name];
});
}
initAppLocale(Vue, vm, swan.getSystemInfoSync().language || 'zh-Hans');
initHooks(appOptions, hooks);
return appOptions
const hooks = [
'onShow',
'onHide',
'onError',
'onPageNotFound',
'onThemeChange',
'onUnhandledRejection'
];
function initEventChannel$1 () {
Vue.prototype.getOpenerEventChannel = function () {
if (!this.__eventChannel__) {
this.__eventChannel__ = new EventChannel();
}
return this.__eventChannel__
};
const callHook = Vue.prototype.__call_hook;
Vue.prototype.__call_hook = function (hook, args) {
if (hook === 'onLoad' && args && args.__id__) {
this.__eventChannel__ = getEventChannel(args.__id__);
delete args.__id__;
}
return callHook.call(this, hook, args)
};
}
function initScopedSlotsParams () {
const center = {};
const parents = {};
Vue.prototype.$hasScopedSlotsParams = function (vueId) {
const has = center[vueId];
if (!has) {
parents[vueId] = this;
this.$on('hook:destory', () => {
delete parents[vueId];
});
}
return has
};
Vue.prototype.$getScopedSlotsParams = function (vueId, name, key) {
const data = center[vueId];
if (data) {
const object = data[name] || {};
return key ? object[key] : object
} else {
parents[vueId] = this;
this.$on('hook:destory', () => {
delete parents[vueId];
});
}
};
Vue.prototype.$setScopedSlotsParams = function (name, value) {
const vueIds = this.$options.propsData.vueId;
if (vueIds) {
const vueId = vueIds.split(',')[0];
const object = center[vueId] = center[vueId] || {};
object[name] = value;
if (parents[vueId]) {
parents[vueId].$forceUpdate();
}
}
};
Vue.mixin({
destroyed () {
const propsData = this.$options.propsData;
const vueId = propsData && propsData.vueId;
if (vueId) {
delete center[vueId];
delete parents[vueId];
}
}
});
}
function parseBaseApp (vm, {
mocks,
initRefs
}) {
initEventChannel$1();
{
initScopedSlotsParams();
}
if (vm.$options.store) {
Vue.prototype.$store = vm.$options.store;
}
uniIdMixin(Vue);
Vue.prototype.mpHost = "mp-baidu";
Vue.mixin({
beforeCreate () {
if (!this.$options.mpType) {
return
}
this.mpType = this.$options.mpType;
this.$mp = {
data: {},
[this.mpType]: this.$options.mpInstance
};
this.$scope = this.$options.mpInstance;
delete this.$options.mpType;
delete this.$options.mpInstance;
if (this.mpType === 'page' && typeof getApp === 'function') { // hack vue-i18n
const app = getApp();
if (app.$vm && app.$vm.$i18n) {
this._i18n = app.$vm.$i18n;
}
}
if (this.mpType !== 'app') {
initRefs(this);
initMocks(this, mocks);
}
}
});
const appOptions = {
onLaunch (args) {
if (this.$vm) { // 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return
}
this.$vm = vm;
this.$vm.$mp = {
app: this
};
this.$vm.$scope = this;
// vm 上也挂载 globalData
this.$vm.globalData = this.globalData;
this.$vm._isMounted = true;
this.$vm.__call_hook('mounted', args);
this.$vm.__call_hook('onLaunch', args);
}
};
// 兼容旧版本 globalData
appOptions.globalData = vm.$options.globalData || {};
// 将 methods 中的方法挂在 getApp() 中
const methods = vm.$options.methods;
if (methods) {
Object.keys(methods).forEach(name => {
appOptions[name] = methods[name];
});
}
initAppLocale(Vue, vm, swan.getSystemInfoSync().language || 'zh-Hans');
initHooks(appOptions, hooks);
return appOptions
}
function findVmByVueId (vm, vuePid) {
......
......@@ -473,7 +473,8 @@ const removeInterceptor = defineSyncApi(API_REMOVE_INTERCEPTOR, (method, interce
else if (isPlainObject(method)) {
removeInterceptorHook(globalInterceptors, method);
}
}, RemoveInterceptorProtocol);
}, RemoveInterceptorProtocol);
const interceptors = {};
const API_ON = '$on';
const OnProtocol = [
......@@ -753,7 +754,10 @@ const onLocaleChange = (fn) => {
if (onLocaleChangeCallbacks.indexOf(fn) === -1) {
onLocaleChangeCallbacks.push(fn);
}
};
};
if (typeof global !== 'undefined') {
global.getLocale = getLocale;
}
const baseApis = {
$on,
......@@ -761,6 +765,7 @@ const baseApis = {
$once,
$emit,
upx2px,
interceptors,
addInterceptor,
removeInterceptor,
onAppLaunch,
......
import Vue from 'vue';
import { initVueI18n } from '@dcloudio/uni-i18n';
let realAtob;
const b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
const b64re = /^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;
if (typeof atob !== 'function') {
realAtob = function (str) {
str = String(str).replace(/[\t\n\f\r ]+/g, '');
if (!b64re.test(str)) { throw new Error("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.") }
// Adding the padding if missing, for semplicity
str += '=='.slice(2 - (str.length & 3));
var bitmap; var result = ''; var r1; var r2; var i = 0;
for (; i < str.length;) {
bitmap = b64.indexOf(str.charAt(i++)) << 18 | b64.indexOf(str.charAt(i++)) << 12 |
(r1 = b64.indexOf(str.charAt(i++))) << 6 | (r2 = b64.indexOf(str.charAt(i++)));
result += r1 === 64 ? String.fromCharCode(bitmap >> 16 & 255)
: r2 === 64 ? String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255)
: String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255, bitmap & 255);
}
return result
};
} else {
// 注意atob只能在全局对象上调用,例如:`const Base64 = {atob};Base64.atob('xxxx')`是错误的用法
realAtob = atob;
}
function b64DecodeUnicode (str) {
return decodeURIComponent(atob(str).split('').map(function (c) {
return decodeURIComponent(realAtob(str).split('').map(function (c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2)
}).join(''))
}
......@@ -431,6 +459,10 @@ function onLocaleChange (fn) {
if (onLocaleChangeCallbacks.indexOf(fn) === -1) {
onLocaleChangeCallbacks.push(fn);
}
}
if (typeof global !== 'undefined') {
global.getLocale = getLocale;
}
const interceptors = {
......@@ -1452,9 +1484,12 @@ let locale;
locale = ks.getSystemInfoSync().language;
}
const i18n = initVueI18n(locale, {});
const i18n = initVueI18n(
locale,
{}
);
const t = i18n.t;
const i18nMixin = i18n.mixin = {
const i18nMixin = (i18n.mixin = {
beforeCreate () {
const unwatch = i18n.i18n.watchLocale(() => {
this.$forceUpdate();
......@@ -1468,7 +1503,7 @@ const i18nMixin = i18n.mixin = {
return t(key, values)
}
}
};
});
const setLocale$1 = i18n.setLocale;
const getLocale$1 = i18n.getLocale;
......@@ -1477,7 +1512,7 @@ function initAppLocale (Vue, appVm, locale) {
locale: locale || i18n.getLocale()
});
const localeWatchers = [];
appVm.$watchLocale = (fn) => {
appVm.$watchLocale = fn => {
localeWatchers.push(fn);
};
Object.defineProperty(appVm, '$locale', {
......@@ -1491,167 +1526,167 @@ function initAppLocale (Vue, appVm, locale) {
});
}
const hooks = [
'onShow',
'onHide',
'onError',
'onPageNotFound',
'onThemeChange',
'onUnhandledRejection'
];
function initEventChannel$1 () {
Vue.prototype.getOpenerEventChannel = function () {
if (!this.__eventChannel__) {
this.__eventChannel__ = new EventChannel();
}
return this.__eventChannel__
};
const callHook = Vue.prototype.__call_hook;
Vue.prototype.__call_hook = function (hook, args) {
if (hook === 'onLoad' && args && args.__id__) {
this.__eventChannel__ = getEventChannel(args.__id__);
delete args.__id__;
}
return callHook.call(this, hook, args)
};
}
function initScopedSlotsParams () {
const center = {};
const parents = {};
Vue.prototype.$hasScopedSlotsParams = function (vueId) {
const has = center[vueId];
if (!has) {
parents[vueId] = this;
this.$on('hook:destory', () => {
delete parents[vueId];
});
}
return has
};
Vue.prototype.$getScopedSlotsParams = function (vueId, name, key) {
const data = center[vueId];
if (data) {
const object = data[name] || {};
return key ? object[key] : object
} else {
parents[vueId] = this;
this.$on('hook:destory', () => {
delete parents[vueId];
});
}
};
Vue.prototype.$setScopedSlotsParams = function (name, value) {
const vueIds = this.$options.propsData.vueId;
if (vueIds) {
const vueId = vueIds.split(',')[0];
const object = center[vueId] = center[vueId] || {};
object[name] = value;
if (parents[vueId]) {
parents[vueId].$forceUpdate();
}
}
};
Vue.mixin({
destroyed () {
const propsData = this.$options.propsData;
const vueId = propsData && propsData.vueId;
if (vueId) {
delete center[vueId];
delete parents[vueId];
}
}
});
}
function parseBaseApp (vm, {
mocks,
initRefs
}) {
initEventChannel$1();
{
initScopedSlotsParams();
}
if (vm.$options.store) {
Vue.prototype.$store = vm.$options.store;
}
uniIdMixin(Vue);
Vue.prototype.mpHost = "mp-kuaishou";
Vue.mixin({
beforeCreate () {
if (!this.$options.mpType) {
return
}
this.mpType = this.$options.mpType;
this.$mp = {
data: {},
[this.mpType]: this.$options.mpInstance
};
this.$scope = this.$options.mpInstance;
delete this.$options.mpType;
delete this.$options.mpInstance;
if (this.mpType === 'page' && typeof getApp === 'function') { // hack vue-i18n
const app = getApp();
if (app.$vm && app.$vm.$i18n) {
this._i18n = app.$vm.$i18n;
}
}
if (this.mpType !== 'app') {
initRefs(this);
initMocks(this, mocks);
}
}
});
const appOptions = {
onLaunch (args) {
if (this.$vm) { // 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return
}
this.$vm = vm;
this.$vm.$mp = {
app: this
};
this.$vm.$scope = this;
// vm 上也挂载 globalData
this.$vm.globalData = this.globalData;
this.$vm._isMounted = true;
this.$vm.__call_hook('mounted', args);
this.$vm.__call_hook('onLaunch', args);
}
};
// 兼容旧版本 globalData
appOptions.globalData = vm.$options.globalData || {};
// 将 methods 中的方法挂在 getApp() 中
const methods = vm.$options.methods;
if (methods) {
Object.keys(methods).forEach(name => {
appOptions[name] = methods[name];
});
}
initAppLocale(Vue, vm, ks.getSystemInfoSync().language || 'zh-Hans');
initHooks(appOptions, hooks);
return appOptions
const hooks = [
'onShow',
'onHide',
'onError',
'onPageNotFound',
'onThemeChange',
'onUnhandledRejection'
];
function initEventChannel$1 () {
Vue.prototype.getOpenerEventChannel = function () {
if (!this.__eventChannel__) {
this.__eventChannel__ = new EventChannel();
}
return this.__eventChannel__
};
const callHook = Vue.prototype.__call_hook;
Vue.prototype.__call_hook = function (hook, args) {
if (hook === 'onLoad' && args && args.__id__) {
this.__eventChannel__ = getEventChannel(args.__id__);
delete args.__id__;
}
return callHook.call(this, hook, args)
};
}
function initScopedSlotsParams () {
const center = {};
const parents = {};
Vue.prototype.$hasScopedSlotsParams = function (vueId) {
const has = center[vueId];
if (!has) {
parents[vueId] = this;
this.$on('hook:destory', () => {
delete parents[vueId];
});
}
return has
};
Vue.prototype.$getScopedSlotsParams = function (vueId, name, key) {
const data = center[vueId];
if (data) {
const object = data[name] || {};
return key ? object[key] : object
} else {
parents[vueId] = this;
this.$on('hook:destory', () => {
delete parents[vueId];
});
}
};
Vue.prototype.$setScopedSlotsParams = function (name, value) {
const vueIds = this.$options.propsData.vueId;
if (vueIds) {
const vueId = vueIds.split(',')[0];
const object = center[vueId] = center[vueId] || {};
object[name] = value;
if (parents[vueId]) {
parents[vueId].$forceUpdate();
}
}
};
Vue.mixin({
destroyed () {
const propsData = this.$options.propsData;
const vueId = propsData && propsData.vueId;
if (vueId) {
delete center[vueId];
delete parents[vueId];
}
}
});
}
function parseBaseApp (vm, {
mocks,
initRefs
}) {
initEventChannel$1();
{
initScopedSlotsParams();
}
if (vm.$options.store) {
Vue.prototype.$store = vm.$options.store;
}
uniIdMixin(Vue);
Vue.prototype.mpHost = "mp-kuaishou";
Vue.mixin({
beforeCreate () {
if (!this.$options.mpType) {
return
}
this.mpType = this.$options.mpType;
this.$mp = {
data: {},
[this.mpType]: this.$options.mpInstance
};
this.$scope = this.$options.mpInstance;
delete this.$options.mpType;
delete this.$options.mpInstance;
if (this.mpType === 'page' && typeof getApp === 'function') { // hack vue-i18n
const app = getApp();
if (app.$vm && app.$vm.$i18n) {
this._i18n = app.$vm.$i18n;
}
}
if (this.mpType !== 'app') {
initRefs(this);
initMocks(this, mocks);
}
}
});
const appOptions = {
onLaunch (args) {
if (this.$vm) { // 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return
}
this.$vm = vm;
this.$vm.$mp = {
app: this
};
this.$vm.$scope = this;
// vm 上也挂载 globalData
this.$vm.globalData = this.globalData;
this.$vm._isMounted = true;
this.$vm.__call_hook('mounted', args);
this.$vm.__call_hook('onLaunch', args);
}
};
// 兼容旧版本 globalData
appOptions.globalData = vm.$options.globalData || {};
// 将 methods 中的方法挂在 getApp() 中
const methods = vm.$options.methods;
if (methods) {
Object.keys(methods).forEach(name => {
appOptions[name] = methods[name];
});
}
initAppLocale(Vue, vm, ks.getSystemInfoSync().language || 'zh-Hans');
initHooks(appOptions, hooks);
return appOptions
}
const mocks = ['__route__', '__wxExparserNodeId__', '__wxWebviewId__'];
......
......@@ -473,7 +473,8 @@ const removeInterceptor = defineSyncApi(API_REMOVE_INTERCEPTOR, (method, interce
else if (isPlainObject(method)) {
removeInterceptorHook(globalInterceptors, method);
}
}, RemoveInterceptorProtocol);
}, RemoveInterceptorProtocol);
const interceptors = {};
const API_ON = '$on';
const OnProtocol = [
......@@ -753,7 +754,10 @@ const onLocaleChange = (fn) => {
if (onLocaleChangeCallbacks.indexOf(fn) === -1) {
onLocaleChangeCallbacks.push(fn);
}
};
};
if (typeof global !== 'undefined') {
global.getLocale = getLocale;
}
const baseApis = {
$on,
......@@ -761,6 +765,7 @@ const baseApis = {
$once,
$emit,
upx2px,
interceptors,
addInterceptor,
removeInterceptor,
onAppLaunch,
......
import Vue from 'vue';
import { initVueI18n } from '@dcloudio/uni-i18n';
let realAtob;
const b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
const b64re = /^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;
if (typeof atob !== 'function') {
realAtob = function (str) {
str = String(str).replace(/[\t\n\f\r ]+/g, '');
if (!b64re.test(str)) { throw new Error("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.") }
// Adding the padding if missing, for semplicity
str += '=='.slice(2 - (str.length & 3));
var bitmap; var result = ''; var r1; var r2; var i = 0;
for (; i < str.length;) {
bitmap = b64.indexOf(str.charAt(i++)) << 18 | b64.indexOf(str.charAt(i++)) << 12 |
(r1 = b64.indexOf(str.charAt(i++))) << 6 | (r2 = b64.indexOf(str.charAt(i++)));
result += r1 === 64 ? String.fromCharCode(bitmap >> 16 & 255)
: r2 === 64 ? String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255)
: String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255, bitmap & 255);
}
return result
};
} else {
// 注意atob只能在全局对象上调用,例如:`const Base64 = {atob};Base64.atob('xxxx')`是错误的用法
realAtob = atob;
}
function b64DecodeUnicode (str) {
return decodeURIComponent(atob(str).split('').map(function (c) {
return decodeURIComponent(realAtob(str).split('').map(function (c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2)
}).join(''))
}
......@@ -431,6 +459,10 @@ function onLocaleChange (fn) {
if (onLocaleChangeCallbacks.indexOf(fn) === -1) {
onLocaleChangeCallbacks.push(fn);
}
}
if (typeof global !== 'undefined') {
global.getLocale = getLocale;
}
const interceptors = {
......@@ -1613,9 +1645,12 @@ let locale;
locale = wx.getSystemInfoSync().language;
}
const i18n = initVueI18n(locale, {});
const i18n = initVueI18n(
locale,
{}
);
const t = i18n.t;
const i18nMixin = i18n.mixin = {
const i18nMixin = (i18n.mixin = {
beforeCreate () {
const unwatch = i18n.i18n.watchLocale(() => {
this.$forceUpdate();
......@@ -1629,7 +1664,7 @@ const i18nMixin = i18n.mixin = {
return t(key, values)
}
}
};
});
const setLocale$1 = i18n.setLocale;
const getLocale$1 = i18n.getLocale;
......@@ -1638,7 +1673,7 @@ function initAppLocale (Vue, appVm, locale) {
locale: locale || i18n.getLocale()
});
const localeWatchers = [];
appVm.$watchLocale = (fn) => {
appVm.$watchLocale = fn => {
localeWatchers.push(fn);
};
Object.defineProperty(appVm, '$locale', {
......@@ -1652,172 +1687,172 @@ function initAppLocale (Vue, appVm, locale) {
});
}
const hooks = [
'onShow',
'onHide',
'onError',
'onPageNotFound',
'onThemeChange',
'onUnhandledRejection'
];
function initEventChannel$1 () {
Vue.prototype.getOpenerEventChannel = function () {
if (!this.__eventChannel__) {
this.__eventChannel__ = new EventChannel();
}
return this.__eventChannel__
};
const callHook = Vue.prototype.__call_hook;
Vue.prototype.__call_hook = function (hook, args) {
if (hook === 'onLoad' && args && args.__id__) {
this.__eventChannel__ = getEventChannel(args.__id__);
delete args.__id__;
}
return callHook.call(this, hook, args)
};
}
function initScopedSlotsParams () {
const center = {};
const parents = {};
Vue.prototype.$hasScopedSlotsParams = function (vueId) {
const has = center[vueId];
if (!has) {
parents[vueId] = this;
this.$on('hook:destory', () => {
delete parents[vueId];
});
}
return has
};
Vue.prototype.$getScopedSlotsParams = function (vueId, name, key) {
const data = center[vueId];
if (data) {
const object = data[name] || {};
return key ? object[key] : object
} else {
parents[vueId] = this;
this.$on('hook:destory', () => {
delete parents[vueId];
});
}
};
Vue.prototype.$setScopedSlotsParams = function (name, value) {
const vueIds = this.$options.propsData.vueId;
if (vueIds) {
const vueId = vueIds.split(',')[0];
const object = center[vueId] = center[vueId] || {};
object[name] = value;
if (parents[vueId]) {
parents[vueId].$forceUpdate();
}
}
};
Vue.mixin({
destroyed () {
const propsData = this.$options.propsData;
const vueId = propsData && propsData.vueId;
if (vueId) {
delete center[vueId];
delete parents[vueId];
}
}
});
}
function parseBaseApp (vm, {
mocks,
initRefs
}) {
initEventChannel$1();
{
initScopedSlotsParams();
}
if (vm.$options.store) {
Vue.prototype.$store = vm.$options.store;
}
uniIdMixin(Vue);
Vue.prototype.mpHost = "mp-qq";
Vue.mixin({
beforeCreate () {
if (!this.$options.mpType) {
return
}
this.mpType = this.$options.mpType;
this.$mp = {
data: {},
[this.mpType]: this.$options.mpInstance
};
this.$scope = this.$options.mpInstance;
delete this.$options.mpType;
delete this.$options.mpInstance;
if (this.mpType === 'page' && typeof getApp === 'function') { // hack vue-i18n
const app = getApp();
if (app.$vm && app.$vm.$i18n) {
this._i18n = app.$vm.$i18n;
}
}
if (this.mpType !== 'app') {
initRefs(this);
initMocks(this, mocks);
}
}
});
const appOptions = {
onLaunch (args) {
if (this.$vm) { // 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return
}
{
if (wx.canIUse && !wx.canIUse('nextTick')) { // 事实 上2.2.3 即可,简单使用 2.3.0 的 nextTick 判断
console.error('当前微信基础库版本过低,请将 微信开发者工具-详情-项目设置-调试基础库版本 更换为`2.3.0`以上');
}
}
this.$vm = vm;
this.$vm.$mp = {
app: this
};
this.$vm.$scope = this;
// vm 上也挂载 globalData
this.$vm.globalData = this.globalData;
this.$vm._isMounted = true;
this.$vm.__call_hook('mounted', args);
this.$vm.__call_hook('onLaunch', args);
}
};
// 兼容旧版本 globalData
appOptions.globalData = vm.$options.globalData || {};
// 将 methods 中的方法挂在 getApp() 中
const methods = vm.$options.methods;
if (methods) {
Object.keys(methods).forEach(name => {
appOptions[name] = methods[name];
});
}
initAppLocale(Vue, vm, wx.getSystemInfoSync().language || 'zh-Hans');
initHooks(appOptions, hooks);
return appOptions
const hooks = [
'onShow',
'onHide',
'onError',
'onPageNotFound',
'onThemeChange',
'onUnhandledRejection'
];
function initEventChannel$1 () {
Vue.prototype.getOpenerEventChannel = function () {
if (!this.__eventChannel__) {
this.__eventChannel__ = new EventChannel();
}
return this.__eventChannel__
};
const callHook = Vue.prototype.__call_hook;
Vue.prototype.__call_hook = function (hook, args) {
if (hook === 'onLoad' && args && args.__id__) {
this.__eventChannel__ = getEventChannel(args.__id__);
delete args.__id__;
}
return callHook.call(this, hook, args)
};
}
function initScopedSlotsParams () {
const center = {};
const parents = {};
Vue.prototype.$hasScopedSlotsParams = function (vueId) {
const has = center[vueId];
if (!has) {
parents[vueId] = this;
this.$on('hook:destory', () => {
delete parents[vueId];
});
}
return has
};
Vue.prototype.$getScopedSlotsParams = function (vueId, name, key) {
const data = center[vueId];
if (data) {
const object = data[name] || {};
return key ? object[key] : object
} else {
parents[vueId] = this;
this.$on('hook:destory', () => {
delete parents[vueId];
});
}
};
Vue.prototype.$setScopedSlotsParams = function (name, value) {
const vueIds = this.$options.propsData.vueId;
if (vueIds) {
const vueId = vueIds.split(',')[0];
const object = center[vueId] = center[vueId] || {};
object[name] = value;
if (parents[vueId]) {
parents[vueId].$forceUpdate();
}
}
};
Vue.mixin({
destroyed () {
const propsData = this.$options.propsData;
const vueId = propsData && propsData.vueId;
if (vueId) {
delete center[vueId];
delete parents[vueId];
}
}
});
}
function parseBaseApp (vm, {
mocks,
initRefs
}) {
initEventChannel$1();
{
initScopedSlotsParams();
}
if (vm.$options.store) {
Vue.prototype.$store = vm.$options.store;
}
uniIdMixin(Vue);
Vue.prototype.mpHost = "mp-qq";
Vue.mixin({
beforeCreate () {
if (!this.$options.mpType) {
return
}
this.mpType = this.$options.mpType;
this.$mp = {
data: {},
[this.mpType]: this.$options.mpInstance
};
this.$scope = this.$options.mpInstance;
delete this.$options.mpType;
delete this.$options.mpInstance;
if (this.mpType === 'page' && typeof getApp === 'function') { // hack vue-i18n
const app = getApp();
if (app.$vm && app.$vm.$i18n) {
this._i18n = app.$vm.$i18n;
}
}
if (this.mpType !== 'app') {
initRefs(this);
initMocks(this, mocks);
}
}
});
const appOptions = {
onLaunch (args) {
if (this.$vm) { // 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return
}
{
if (wx.canIUse && !wx.canIUse('nextTick')) { // 事实 上2.2.3 即可,简单使用 2.3.0 的 nextTick 判断
console.error('当前微信基础库版本过低,请将 微信开发者工具-详情-项目设置-调试基础库版本 更换为`2.3.0`以上');
}
}
this.$vm = vm;
this.$vm.$mp = {
app: this
};
this.$vm.$scope = this;
// vm 上也挂载 globalData
this.$vm.globalData = this.globalData;
this.$vm._isMounted = true;
this.$vm.__call_hook('mounted', args);
this.$vm.__call_hook('onLaunch', args);
}
};
// 兼容旧版本 globalData
appOptions.globalData = vm.$options.globalData || {};
// 将 methods 中的方法挂在 getApp() 中
const methods = vm.$options.methods;
if (methods) {
Object.keys(methods).forEach(name => {
appOptions[name] = methods[name];
});
}
initAppLocale(Vue, vm, wx.getSystemInfoSync().language || 'zh-Hans');
initHooks(appOptions, hooks);
return appOptions
}
const mocks = ['__route__', '__wxExparserNodeId__', '__wxWebviewId__'];
......
......@@ -473,7 +473,8 @@ const removeInterceptor = defineSyncApi(API_REMOVE_INTERCEPTOR, (method, interce
else if (isPlainObject(method)) {
removeInterceptorHook(globalInterceptors, method);
}
}, RemoveInterceptorProtocol);
}, RemoveInterceptorProtocol);
const interceptors = {};
const API_ON = '$on';
const OnProtocol = [
......@@ -753,7 +754,10 @@ const onLocaleChange = (fn) => {
if (onLocaleChangeCallbacks.indexOf(fn) === -1) {
onLocaleChangeCallbacks.push(fn);
}
};
};
if (typeof global !== 'undefined') {
global.getLocale = getLocale;
}
const baseApis = {
$on,
......@@ -761,6 +765,7 @@ const baseApis = {
$once,
$emit,
upx2px,
interceptors,
addInterceptor,
removeInterceptor,
onAppLaunch,
......
import Vue from 'vue';
import { initVueI18n } from '@dcloudio/uni-i18n';
let realAtob;
const b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
const b64re = /^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;
if (typeof atob !== 'function') {
realAtob = function (str) {
str = String(str).replace(/[\t\n\f\r ]+/g, '');
if (!b64re.test(str)) { throw new Error("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.") }
// Adding the padding if missing, for semplicity
str += '=='.slice(2 - (str.length & 3));
var bitmap; var result = ''; var r1; var r2; var i = 0;
for (; i < str.length;) {
bitmap = b64.indexOf(str.charAt(i++)) << 18 | b64.indexOf(str.charAt(i++)) << 12 |
(r1 = b64.indexOf(str.charAt(i++))) << 6 | (r2 = b64.indexOf(str.charAt(i++)));
result += r1 === 64 ? String.fromCharCode(bitmap >> 16 & 255)
: r2 === 64 ? String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255)
: String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255, bitmap & 255);
}
return result
};
} else {
// 注意atob只能在全局对象上调用,例如:`const Base64 = {atob};Base64.atob('xxxx')`是错误的用法
realAtob = atob;
}
function b64DecodeUnicode (str) {
return decodeURIComponent(atob(str).split('').map(function (c) {
return decodeURIComponent(realAtob(str).split('').map(function (c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2)
}).join(''))
}
......@@ -431,6 +459,10 @@ function onLocaleChange (fn) {
if (onLocaleChangeCallbacks.indexOf(fn) === -1) {
onLocaleChangeCallbacks.push(fn);
}
}
if (typeof global !== 'undefined') {
global.getLocale = getLocale;
}
const interceptors = {
......@@ -1709,9 +1741,12 @@ let locale;
locale = tt.getSystemInfoSync().language;
}
const i18n = initVueI18n(locale, {});
const i18n = initVueI18n(
locale,
{}
);
const t = i18n.t;
const i18nMixin = i18n.mixin = {
const i18nMixin = (i18n.mixin = {
beforeCreate () {
const unwatch = i18n.i18n.watchLocale(() => {
this.$forceUpdate();
......@@ -1725,7 +1760,7 @@ const i18nMixin = i18n.mixin = {
return t(key, values)
}
}
};
});
const setLocale$1 = i18n.setLocale;
const getLocale$1 = i18n.getLocale;
......@@ -1734,7 +1769,7 @@ function initAppLocale (Vue, appVm, locale) {
locale: locale || i18n.getLocale()
});
const localeWatchers = [];
appVm.$watchLocale = (fn) => {
appVm.$watchLocale = fn => {
localeWatchers.push(fn);
};
Object.defineProperty(appVm, '$locale', {
......@@ -1748,167 +1783,167 @@ function initAppLocale (Vue, appVm, locale) {
});
}
const hooks = [
'onShow',
'onHide',
'onError',
'onPageNotFound',
'onThemeChange',
'onUnhandledRejection'
];
function initEventChannel$1 () {
Vue.prototype.getOpenerEventChannel = function () {
if (!this.__eventChannel__) {
this.__eventChannel__ = new EventChannel();
}
return this.__eventChannel__
};
const callHook = Vue.prototype.__call_hook;
Vue.prototype.__call_hook = function (hook, args) {
if (hook === 'onLoad' && args && args.__id__) {
this.__eventChannel__ = getEventChannel(args.__id__);
delete args.__id__;
}
return callHook.call(this, hook, args)
};
}
function initScopedSlotsParams () {
const center = {};
const parents = {};
Vue.prototype.$hasScopedSlotsParams = function (vueId) {
const has = center[vueId];
if (!has) {
parents[vueId] = this;
this.$on('hook:destory', () => {
delete parents[vueId];
});
}
return has
};
Vue.prototype.$getScopedSlotsParams = function (vueId, name, key) {
const data = center[vueId];
if (data) {
const object = data[name] || {};
return key ? object[key] : object
} else {
parents[vueId] = this;
this.$on('hook:destory', () => {
delete parents[vueId];
});
}
};
Vue.prototype.$setScopedSlotsParams = function (name, value) {
const vueIds = this.$options.propsData.vueId;
if (vueIds) {
const vueId = vueIds.split(',')[0];
const object = center[vueId] = center[vueId] || {};
object[name] = value;
if (parents[vueId]) {
parents[vueId].$forceUpdate();
}
}
};
Vue.mixin({
destroyed () {
const propsData = this.$options.propsData;
const vueId = propsData && propsData.vueId;
if (vueId) {
delete center[vueId];
delete parents[vueId];
}
}
});
}
function parseBaseApp (vm, {
mocks,
initRefs
}) {
initEventChannel$1();
{
initScopedSlotsParams();
}
if (vm.$options.store) {
Vue.prototype.$store = vm.$options.store;
}
uniIdMixin(Vue);
Vue.prototype.mpHost = "mp-toutiao";
Vue.mixin({
beforeCreate () {
if (!this.$options.mpType) {
return
}
this.mpType = this.$options.mpType;
this.$mp = {
data: {},
[this.mpType]: this.$options.mpInstance
};
this.$scope = this.$options.mpInstance;
delete this.$options.mpType;
delete this.$options.mpInstance;
if (this.mpType === 'page' && typeof getApp === 'function') { // hack vue-i18n
const app = getApp();
if (app.$vm && app.$vm.$i18n) {
this._i18n = app.$vm.$i18n;
}
}
if (this.mpType !== 'app') {
initRefs(this);
initMocks(this, mocks);
}
}
});
const appOptions = {
onLaunch (args) {
if (this.$vm) { // 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return
}
this.$vm = vm;
this.$vm.$mp = {
app: this
};
this.$vm.$scope = this;
// vm 上也挂载 globalData
this.$vm.globalData = this.globalData;
this.$vm._isMounted = true;
this.$vm.__call_hook('mounted', args);
this.$vm.__call_hook('onLaunch', args);
}
};
// 兼容旧版本 globalData
appOptions.globalData = vm.$options.globalData || {};
// 将 methods 中的方法挂在 getApp() 中
const methods = vm.$options.methods;
if (methods) {
Object.keys(methods).forEach(name => {
appOptions[name] = methods[name];
});
}
initAppLocale(Vue, vm, tt.getSystemInfoSync().language || 'zh-Hans');
initHooks(appOptions, hooks);
return appOptions
const hooks = [
'onShow',
'onHide',
'onError',
'onPageNotFound',
'onThemeChange',
'onUnhandledRejection'
];
function initEventChannel$1 () {
Vue.prototype.getOpenerEventChannel = function () {
if (!this.__eventChannel__) {
this.__eventChannel__ = new EventChannel();
}
return this.__eventChannel__
};
const callHook = Vue.prototype.__call_hook;
Vue.prototype.__call_hook = function (hook, args) {
if (hook === 'onLoad' && args && args.__id__) {
this.__eventChannel__ = getEventChannel(args.__id__);
delete args.__id__;
}
return callHook.call(this, hook, args)
};
}
function initScopedSlotsParams () {
const center = {};
const parents = {};
Vue.prototype.$hasScopedSlotsParams = function (vueId) {
const has = center[vueId];
if (!has) {
parents[vueId] = this;
this.$on('hook:destory', () => {
delete parents[vueId];
});
}
return has
};
Vue.prototype.$getScopedSlotsParams = function (vueId, name, key) {
const data = center[vueId];
if (data) {
const object = data[name] || {};
return key ? object[key] : object
} else {
parents[vueId] = this;
this.$on('hook:destory', () => {
delete parents[vueId];
});
}
};
Vue.prototype.$setScopedSlotsParams = function (name, value) {
const vueIds = this.$options.propsData.vueId;
if (vueIds) {
const vueId = vueIds.split(',')[0];
const object = center[vueId] = center[vueId] || {};
object[name] = value;
if (parents[vueId]) {
parents[vueId].$forceUpdate();
}
}
};
Vue.mixin({
destroyed () {
const propsData = this.$options.propsData;
const vueId = propsData && propsData.vueId;
if (vueId) {
delete center[vueId];
delete parents[vueId];
}
}
});
}
function parseBaseApp (vm, {
mocks,
initRefs
}) {
initEventChannel$1();
{
initScopedSlotsParams();
}
if (vm.$options.store) {
Vue.prototype.$store = vm.$options.store;
}
uniIdMixin(Vue);
Vue.prototype.mpHost = "mp-toutiao";
Vue.mixin({
beforeCreate () {
if (!this.$options.mpType) {
return
}
this.mpType = this.$options.mpType;
this.$mp = {
data: {},
[this.mpType]: this.$options.mpInstance
};
this.$scope = this.$options.mpInstance;
delete this.$options.mpType;
delete this.$options.mpInstance;
if (this.mpType === 'page' && typeof getApp === 'function') { // hack vue-i18n
const app = getApp();
if (app.$vm && app.$vm.$i18n) {
this._i18n = app.$vm.$i18n;
}
}
if (this.mpType !== 'app') {
initRefs(this);
initMocks(this, mocks);
}
}
});
const appOptions = {
onLaunch (args) {
if (this.$vm) { // 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return
}
this.$vm = vm;
this.$vm.$mp = {
app: this
};
this.$vm.$scope = this;
// vm 上也挂载 globalData
this.$vm.globalData = this.globalData;
this.$vm._isMounted = true;
this.$vm.__call_hook('mounted', args);
this.$vm.__call_hook('onLaunch', args);
}
};
// 兼容旧版本 globalData
appOptions.globalData = vm.$options.globalData || {};
// 将 methods 中的方法挂在 getApp() 中
const methods = vm.$options.methods;
if (methods) {
Object.keys(methods).forEach(name => {
appOptions[name] = methods[name];
});
}
initAppLocale(Vue, vm, tt.getSystemInfoSync().language || 'zh-Hans');
initHooks(appOptions, hooks);
return appOptions
}
function findVmByVueId (vm, vuePid) {
......
......@@ -473,7 +473,8 @@ const removeInterceptor = defineSyncApi(API_REMOVE_INTERCEPTOR, (method, interce
else if (isPlainObject(method)) {
removeInterceptorHook(globalInterceptors, method);
}
}, RemoveInterceptorProtocol);
}, RemoveInterceptorProtocol);
const interceptors = {};
const API_ON = '$on';
const OnProtocol = [
......@@ -753,7 +754,10 @@ const onLocaleChange = (fn) => {
if (onLocaleChangeCallbacks.indexOf(fn) === -1) {
onLocaleChangeCallbacks.push(fn);
}
};
};
if (typeof global !== 'undefined') {
global.getLocale = getLocale;
}
const baseApis = {
$on,
......@@ -761,6 +765,7 @@ const baseApis = {
$once,
$emit,
upx2px,
interceptors,
addInterceptor,
removeInterceptor,
onAppLaunch,
......
import Vue from 'vue';
import { initVueI18n } from '@dcloudio/uni-i18n';
let realAtob;
const b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
const b64re = /^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;
if (typeof atob !== 'function') {
realAtob = function (str) {
str = String(str).replace(/[\t\n\f\r ]+/g, '');
if (!b64re.test(str)) { throw new Error("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.") }
// Adding the padding if missing, for semplicity
str += '=='.slice(2 - (str.length & 3));
var bitmap; var result = ''; var r1; var r2; var i = 0;
for (; i < str.length;) {
bitmap = b64.indexOf(str.charAt(i++)) << 18 | b64.indexOf(str.charAt(i++)) << 12 |
(r1 = b64.indexOf(str.charAt(i++))) << 6 | (r2 = b64.indexOf(str.charAt(i++)));
result += r1 === 64 ? String.fromCharCode(bitmap >> 16 & 255)
: r2 === 64 ? String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255)
: String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255, bitmap & 255);
}
return result
};
} else {
// 注意atob只能在全局对象上调用,例如:`const Base64 = {atob};Base64.atob('xxxx')`是错误的用法
realAtob = atob;
}
function b64DecodeUnicode (str) {
return decodeURIComponent(atob(str).split('').map(function (c) {
return decodeURIComponent(realAtob(str).split('').map(function (c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2)
}).join(''))
}
......@@ -431,6 +459,10 @@ function onLocaleChange (fn) {
if (onLocaleChangeCallbacks.indexOf(fn) === -1) {
onLocaleChangeCallbacks.push(fn);
}
}
if (typeof global !== 'undefined') {
global.getLocale = getLocale;
}
const interceptors = {
......@@ -1349,9 +1381,12 @@ let locale;
locale = wx.getSystemInfoSync().language;
}
const i18n = initVueI18n(locale, {});
const i18n = initVueI18n(
locale,
{}
);
const t = i18n.t;
const i18nMixin = i18n.mixin = {
const i18nMixin = (i18n.mixin = {
beforeCreate () {
const unwatch = i18n.i18n.watchLocale(() => {
this.$forceUpdate();
......@@ -1365,7 +1400,7 @@ const i18nMixin = i18n.mixin = {
return t(key, values)
}
}
};
});
const setLocale$1 = i18n.setLocale;
const getLocale$1 = i18n.getLocale;
......@@ -1374,7 +1409,7 @@ function initAppLocale (Vue, appVm, locale) {
locale: locale || i18n.getLocale()
});
const localeWatchers = [];
appVm.$watchLocale = (fn) => {
appVm.$watchLocale = fn => {
localeWatchers.push(fn);
};
Object.defineProperty(appVm, '$locale', {
......@@ -1401,172 +1436,172 @@ function getEventChannel (id) {
return eventChannelStack.shift()
}
const hooks = [
'onShow',
'onHide',
'onError',
'onPageNotFound',
'onThemeChange',
'onUnhandledRejection'
];
function initEventChannel () {
Vue.prototype.getOpenerEventChannel = function () {
// 微信小程序使用自身getOpenerEventChannel
{
return this.$scope.getOpenerEventChannel()
}
};
const callHook = Vue.prototype.__call_hook;
Vue.prototype.__call_hook = function (hook, args) {
if (hook === 'onLoad' && args && args.__id__) {
this.__eventChannel__ = getEventChannel(args.__id__);
delete args.__id__;
}
return callHook.call(this, hook, args)
};
}
function initScopedSlotsParams () {
const center = {};
const parents = {};
Vue.prototype.$hasScopedSlotsParams = function (vueId) {
const has = center[vueId];
if (!has) {
parents[vueId] = this;
this.$on('hook:destory', () => {
delete parents[vueId];
});
}
return has
};
Vue.prototype.$getScopedSlotsParams = function (vueId, name, key) {
const data = center[vueId];
if (data) {
const object = data[name] || {};
return key ? object[key] : object
} else {
parents[vueId] = this;
this.$on('hook:destory', () => {
delete parents[vueId];
});
}
};
Vue.prototype.$setScopedSlotsParams = function (name, value) {
const vueIds = this.$options.propsData.vueId;
if (vueIds) {
const vueId = vueIds.split(',')[0];
const object = center[vueId] = center[vueId] || {};
object[name] = value;
if (parents[vueId]) {
parents[vueId].$forceUpdate();
}
}
};
Vue.mixin({
destroyed () {
const propsData = this.$options.propsData;
const vueId = propsData && propsData.vueId;
if (vueId) {
delete center[vueId];
delete parents[vueId];
}
}
});
}
function parseBaseApp (vm, {
mocks,
initRefs
}) {
initEventChannel();
{
initScopedSlotsParams();
}
if (vm.$options.store) {
Vue.prototype.$store = vm.$options.store;
}
uniIdMixin(Vue);
Vue.prototype.mpHost = "mp-weixin";
Vue.mixin({
beforeCreate () {
if (!this.$options.mpType) {
return
}
this.mpType = this.$options.mpType;
this.$mp = {
data: {},
[this.mpType]: this.$options.mpInstance
};
this.$scope = this.$options.mpInstance;
delete this.$options.mpType;
delete this.$options.mpInstance;
if (this.mpType === 'page' && typeof getApp === 'function') { // hack vue-i18n
const app = getApp();
if (app.$vm && app.$vm.$i18n) {
this._i18n = app.$vm.$i18n;
}
}
if (this.mpType !== 'app') {
initRefs(this);
initMocks(this, mocks);
}
}
});
const appOptions = {
onLaunch (args) {
if (this.$vm) { // 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return
}
{
if (wx.canIUse && !wx.canIUse('nextTick')) { // 事实 上2.2.3 即可,简单使用 2.3.0 的 nextTick 判断
console.error('当前微信基础库版本过低,请将 微信开发者工具-详情-项目设置-调试基础库版本 更换为`2.3.0`以上');
}
}
this.$vm = vm;
this.$vm.$mp = {
app: this
};
this.$vm.$scope = this;
// vm 上也挂载 globalData
this.$vm.globalData = this.globalData;
this.$vm._isMounted = true;
this.$vm.__call_hook('mounted', args);
this.$vm.__call_hook('onLaunch', args);
}
};
// 兼容旧版本 globalData
appOptions.globalData = vm.$options.globalData || {};
// 将 methods 中的方法挂在 getApp() 中
const methods = vm.$options.methods;
if (methods) {
Object.keys(methods).forEach(name => {
appOptions[name] = methods[name];
});
}
initAppLocale(Vue, vm, wx.getSystemInfoSync().language || 'zh-Hans');
initHooks(appOptions, hooks);
return appOptions
const hooks = [
'onShow',
'onHide',
'onError',
'onPageNotFound',
'onThemeChange',
'onUnhandledRejection'
];
function initEventChannel () {
Vue.prototype.getOpenerEventChannel = function () {
// 微信小程序使用自身getOpenerEventChannel
{
return this.$scope.getOpenerEventChannel()
}
};
const callHook = Vue.prototype.__call_hook;
Vue.prototype.__call_hook = function (hook, args) {
if (hook === 'onLoad' && args && args.__id__) {
this.__eventChannel__ = getEventChannel(args.__id__);
delete args.__id__;
}
return callHook.call(this, hook, args)
};
}
function initScopedSlotsParams () {
const center = {};
const parents = {};
Vue.prototype.$hasScopedSlotsParams = function (vueId) {
const has = center[vueId];
if (!has) {
parents[vueId] = this;
this.$on('hook:destory', () => {
delete parents[vueId];
});
}
return has
};
Vue.prototype.$getScopedSlotsParams = function (vueId, name, key) {
const data = center[vueId];
if (data) {
const object = data[name] || {};
return key ? object[key] : object
} else {
parents[vueId] = this;
this.$on('hook:destory', () => {
delete parents[vueId];
});
}
};
Vue.prototype.$setScopedSlotsParams = function (name, value) {
const vueIds = this.$options.propsData.vueId;
if (vueIds) {
const vueId = vueIds.split(',')[0];
const object = center[vueId] = center[vueId] || {};
object[name] = value;
if (parents[vueId]) {
parents[vueId].$forceUpdate();
}
}
};
Vue.mixin({
destroyed () {
const propsData = this.$options.propsData;
const vueId = propsData && propsData.vueId;
if (vueId) {
delete center[vueId];
delete parents[vueId];
}
}
});
}
function parseBaseApp (vm, {
mocks,
initRefs
}) {
initEventChannel();
{
initScopedSlotsParams();
}
if (vm.$options.store) {
Vue.prototype.$store = vm.$options.store;
}
uniIdMixin(Vue);
Vue.prototype.mpHost = "mp-weixin";
Vue.mixin({
beforeCreate () {
if (!this.$options.mpType) {
return
}
this.mpType = this.$options.mpType;
this.$mp = {
data: {},
[this.mpType]: this.$options.mpInstance
};
this.$scope = this.$options.mpInstance;
delete this.$options.mpType;
delete this.$options.mpInstance;
if (this.mpType === 'page' && typeof getApp === 'function') { // hack vue-i18n
const app = getApp();
if (app.$vm && app.$vm.$i18n) {
this._i18n = app.$vm.$i18n;
}
}
if (this.mpType !== 'app') {
initRefs(this);
initMocks(this, mocks);
}
}
});
const appOptions = {
onLaunch (args) {
if (this.$vm) { // 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return
}
{
if (wx.canIUse && !wx.canIUse('nextTick')) { // 事实 上2.2.3 即可,简单使用 2.3.0 的 nextTick 判断
console.error('当前微信基础库版本过低,请将 微信开发者工具-详情-项目设置-调试基础库版本 更换为`2.3.0`以上');
}
}
this.$vm = vm;
this.$vm.$mp = {
app: this
};
this.$vm.$scope = this;
// vm 上也挂载 globalData
this.$vm.globalData = this.globalData;
this.$vm._isMounted = true;
this.$vm.__call_hook('mounted', args);
this.$vm.__call_hook('onLaunch', args);
}
};
// 兼容旧版本 globalData
appOptions.globalData = vm.$options.globalData || {};
// 将 methods 中的方法挂在 getApp() 中
const methods = vm.$options.methods;
if (methods) {
Object.keys(methods).forEach(name => {
appOptions[name] = methods[name];
});
}
initAppLocale(Vue, vm, wx.getSystemInfoSync().language || 'zh-Hans');
initHooks(appOptions, hooks);
return appOptions
}
const mocks = ['__route__', '__wxExparserNodeId__', '__wxWebviewId__'];
......
......@@ -437,7 +437,8 @@ const removeInterceptor = defineSyncApi(API_REMOVE_INTERCEPTOR, (method, interce
else if (isPlainObject(method)) {
removeInterceptorHook(globalInterceptors, method);
}
}, RemoveInterceptorProtocol);
}, RemoveInterceptorProtocol);
const interceptors = {};
const API_ON = '$on';
const OnProtocol = [
......@@ -717,7 +718,10 @@ const onLocaleChange = (fn) => {
if (onLocaleChangeCallbacks.indexOf(fn) === -1) {
onLocaleChangeCallbacks.push(fn);
}
};
};
if (typeof global !== 'undefined') {
global.getLocale = getLocale;
}
const baseApis = {
$on,
......@@ -725,6 +729,7 @@ const baseApis = {
$once,
$emit,
upx2px,
interceptors,
addInterceptor,
removeInterceptor,
onAppLaunch,
......
import Vue from 'vue';
import { initVueI18n } from '@dcloudio/uni-i18n';
let realAtob;
const b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
const b64re = /^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;
if (typeof atob !== 'function') {
realAtob = function (str) {
str = String(str).replace(/[\t\n\f\r ]+/g, '');
if (!b64re.test(str)) { throw new Error("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.") }
// Adding the padding if missing, for semplicity
str += '=='.slice(2 - (str.length & 3));
var bitmap; var result = ''; var r1; var r2; var i = 0;
for (; i < str.length;) {
bitmap = b64.indexOf(str.charAt(i++)) << 18 | b64.indexOf(str.charAt(i++)) << 12 |
(r1 = b64.indexOf(str.charAt(i++))) << 6 | (r2 = b64.indexOf(str.charAt(i++)));
result += r1 === 64 ? String.fromCharCode(bitmap >> 16 & 255)
: r2 === 64 ? String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255)
: String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255, bitmap & 255);
}
return result
};
} else {
// 注意atob只能在全局对象上调用,例如:`const Base64 = {atob};Base64.atob('xxxx')`是错误的用法
realAtob = atob;
}
function b64DecodeUnicode (str) {
return decodeURIComponent(atob(str).split('').map(function (c) {
return decodeURIComponent(realAtob(str).split('').map(function (c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2)
}).join(''))
}
......@@ -431,6 +459,10 @@ function onLocaleChange (fn) {
if (onLocaleChangeCallbacks.indexOf(fn) === -1) {
onLocaleChangeCallbacks.push(fn);
}
}
if (typeof global !== 'undefined') {
global.getLocale = getLocale;
}
const interceptors = {
......@@ -1419,9 +1451,12 @@ let locale;
locale = qa.getSystemInfoSync().language;
}
const i18n = initVueI18n(locale, {});
const i18n = initVueI18n(
locale,
{}
);
const t = i18n.t;
const i18nMixin = i18n.mixin = {
const i18nMixin = (i18n.mixin = {
beforeCreate () {
const unwatch = i18n.i18n.watchLocale(() => {
this.$forceUpdate();
......@@ -1435,7 +1470,7 @@ const i18nMixin = i18n.mixin = {
return t(key, values)
}
}
};
});
const setLocale$1 = i18n.setLocale;
const getLocale$1 = i18n.getLocale;
......@@ -1444,7 +1479,7 @@ function initAppLocale (Vue, appVm, locale) {
locale: locale || i18n.getLocale()
});
const localeWatchers = [];
appVm.$watchLocale = (fn) => {
appVm.$watchLocale = fn => {
localeWatchers.push(fn);
};
Object.defineProperty(appVm, '$locale', {
......@@ -1458,112 +1493,112 @@ function initAppLocale (Vue, appVm, locale) {
});
}
const hooks = [
'onShow',
'onHide',
'onError',
'onPageNotFound',
'onThemeChange',
'onUnhandledRejection'
];
function initEventChannel$1 () {
Vue.prototype.getOpenerEventChannel = function () {
if (!this.__eventChannel__) {
this.__eventChannel__ = new EventChannel();
}
return this.__eventChannel__
};
const callHook = Vue.prototype.__call_hook;
Vue.prototype.__call_hook = function (hook, args) {
if (hook === 'onLoad' && args && args.__id__) {
this.__eventChannel__ = getEventChannel(args.__id__);
delete args.__id__;
}
return callHook.call(this, hook, args)
};
}
function parseBaseApp (vm, {
mocks,
initRefs
}) {
initEventChannel$1();
if (vm.$options.store) {
Vue.prototype.$store = vm.$options.store;
}
uniIdMixin(Vue);
Vue.prototype.mpHost = "quickapp-webview";
Vue.mixin({
beforeCreate () {
if (!this.$options.mpType) {
return
}
this.mpType = this.$options.mpType;
this.$mp = {
data: {},
[this.mpType]: this.$options.mpInstance
};
this.$scope = this.$options.mpInstance;
delete this.$options.mpType;
delete this.$options.mpInstance;
if (this.mpType === 'page' && typeof getApp === 'function') { // hack vue-i18n
const app = getApp();
if (app.$vm && app.$vm.$i18n) {
this._i18n = app.$vm.$i18n;
}
}
if (this.mpType !== 'app') {
initRefs(this);
initMocks(this, mocks);
}
}
});
const appOptions = {
onLaunch (args) {
if (this.$vm) { // 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return
}
this.$vm = vm;
this.$vm.$mp = {
app: this
};
this.$vm.$scope = this;
// vm 上也挂载 globalData
this.$vm.globalData = this.globalData;
this.$vm._isMounted = true;
this.$vm.__call_hook('mounted', args);
this.$vm.__call_hook('onLaunch', args);
}
};
// 兼容旧版本 globalData
appOptions.globalData = vm.$options.globalData || {};
// 将 methods 中的方法挂在 getApp() 中
const methods = vm.$options.methods;
if (methods) {
Object.keys(methods).forEach(name => {
appOptions[name] = methods[name];
});
}
initAppLocale(Vue, vm, qa.getSystemInfoSync().language || 'zh-Hans');
initHooks(appOptions, hooks);
return appOptions
const hooks = [
'onShow',
'onHide',
'onError',
'onPageNotFound',
'onThemeChange',
'onUnhandledRejection'
];
function initEventChannel$1 () {
Vue.prototype.getOpenerEventChannel = function () {
if (!this.__eventChannel__) {
this.__eventChannel__ = new EventChannel();
}
return this.__eventChannel__
};
const callHook = Vue.prototype.__call_hook;
Vue.prototype.__call_hook = function (hook, args) {
if (hook === 'onLoad' && args && args.__id__) {
this.__eventChannel__ = getEventChannel(args.__id__);
delete args.__id__;
}
return callHook.call(this, hook, args)
};
}
function parseBaseApp (vm, {
mocks,
initRefs
}) {
initEventChannel$1();
if (vm.$options.store) {
Vue.prototype.$store = vm.$options.store;
}
uniIdMixin(Vue);
Vue.prototype.mpHost = "quickapp-webview";
Vue.mixin({
beforeCreate () {
if (!this.$options.mpType) {
return
}
this.mpType = this.$options.mpType;
this.$mp = {
data: {},
[this.mpType]: this.$options.mpInstance
};
this.$scope = this.$options.mpInstance;
delete this.$options.mpType;
delete this.$options.mpInstance;
if (this.mpType === 'page' && typeof getApp === 'function') { // hack vue-i18n
const app = getApp();
if (app.$vm && app.$vm.$i18n) {
this._i18n = app.$vm.$i18n;
}
}
if (this.mpType !== 'app') {
initRefs(this);
initMocks(this, mocks);
}
}
});
const appOptions = {
onLaunch (args) {
if (this.$vm) { // 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return
}
this.$vm = vm;
this.$vm.$mp = {
app: this
};
this.$vm.$scope = this;
// vm 上也挂载 globalData
this.$vm.globalData = this.globalData;
this.$vm._isMounted = true;
this.$vm.__call_hook('mounted', args);
this.$vm.__call_hook('onLaunch', args);
}
};
// 兼容旧版本 globalData
appOptions.globalData = vm.$options.globalData || {};
// 将 methods 中的方法挂在 getApp() 中
const methods = vm.$options.methods;
if (methods) {
Object.keys(methods).forEach(name => {
appOptions[name] = methods[name];
});
}
initAppLocale(Vue, vm, qa.getSystemInfoSync().language || 'zh-Hans');
initHooks(appOptions, hooks);
return appOptions
}
const mocks = ['nodeId', 'componentName', '_componentId', 'uniquePrefix'];
......
......@@ -473,7 +473,8 @@ const removeInterceptor = defineSyncApi(API_REMOVE_INTERCEPTOR, (method, interce
else if (isPlainObject(method)) {
removeInterceptorHook(globalInterceptors, method);
}
}, RemoveInterceptorProtocol);
}, RemoveInterceptorProtocol);
const interceptors = {};
const API_ON = '$on';
const OnProtocol = [
......@@ -753,7 +754,10 @@ const onLocaleChange = (fn) => {
if (onLocaleChangeCallbacks.indexOf(fn) === -1) {
onLocaleChangeCallbacks.push(fn);
}
};
};
if (typeof global !== 'undefined') {
global.getLocale = getLocale;
}
const baseApis = {
$on,
......@@ -761,6 +765,7 @@ const baseApis = {
$once,
$emit,
upx2px,
interceptors,
addInterceptor,
removeInterceptor,
onAppLaunch,
......
......@@ -30,4 +30,8 @@ export function onLocaleChange (fn) {
if (onLocaleChangeCallbacks.indexOf(fn) === -1) {
onLocaleChangeCallbacks.push(fn)
}
}
if (typeof global !== 'undefined') {
global.getLocale = getLocale
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册