@dcloudio/uni-quickapp-webview 2.0.1-34720220422002 → 2.0.1-34920220607003
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +422 -95
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import Vue from 'vue';
|
|
2
1
|
import { initVueI18n } from '@dcloudio/uni-i18n';
|
|
2
|
+
import Vue from 'vue';
|
|
3
3
|
|
|
4
4
|
let realAtob;
|
|
5
5
|
|
|
@@ -98,7 +98,7 @@ function hasOwn (obj, key) {
|
|
|
98
98
|
return hasOwnProperty.call(obj, key)
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
function noop () {}
|
|
101
|
+
function noop () { }
|
|
102
102
|
|
|
103
103
|
/**
|
|
104
104
|
* Create a cached version of a pure function.
|
|
@@ -314,7 +314,7 @@ const promiseInterceptor = {
|
|
|
314
314
|
};
|
|
315
315
|
|
|
316
316
|
const SYNC_API_RE =
|
|
317
|
-
/^\$|Window$|WindowStyle$|sendHostEvent|sendNativeEvent|restoreGlobal|requireGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64|getLocale|setLocale/;
|
|
317
|
+
/^\$|Window$|WindowStyle$|sendHostEvent|sendNativeEvent|restoreGlobal|requireGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64|getLocale|setLocale|invokePushCallback|getWindowInfo|getDeviceInfo|getAppBaseInfo/;
|
|
318
318
|
|
|
319
319
|
const CONTEXT_API_RE = /^create|Manager$/;
|
|
320
320
|
|
|
@@ -427,7 +427,134 @@ function upx2px (number, newDeviceWidth) {
|
|
|
427
427
|
return number < 0 ? -result : result
|
|
428
428
|
}
|
|
429
429
|
|
|
430
|
-
|
|
430
|
+
const LOCALE_ZH_HANS = 'zh-Hans';
|
|
431
|
+
const LOCALE_ZH_HANT = 'zh-Hant';
|
|
432
|
+
const LOCALE_EN = 'en';
|
|
433
|
+
const LOCALE_FR = 'fr';
|
|
434
|
+
const LOCALE_ES = 'es';
|
|
435
|
+
|
|
436
|
+
const messages = {};
|
|
437
|
+
|
|
438
|
+
let locale;
|
|
439
|
+
|
|
440
|
+
{
|
|
441
|
+
locale = normalizeLocale(qa.getSystemInfoSync().language) || LOCALE_EN;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
function initI18nMessages () {
|
|
445
|
+
if (!isEnableLocale()) {
|
|
446
|
+
return
|
|
447
|
+
}
|
|
448
|
+
const localeKeys = Object.keys(__uniConfig.locales);
|
|
449
|
+
if (localeKeys.length) {
|
|
450
|
+
localeKeys.forEach((locale) => {
|
|
451
|
+
const curMessages = messages[locale];
|
|
452
|
+
const userMessages = __uniConfig.locales[locale];
|
|
453
|
+
if (curMessages) {
|
|
454
|
+
Object.assign(curMessages, userMessages);
|
|
455
|
+
} else {
|
|
456
|
+
messages[locale] = userMessages;
|
|
457
|
+
}
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
initI18nMessages();
|
|
463
|
+
|
|
464
|
+
const i18n = initVueI18n(
|
|
465
|
+
locale,
|
|
466
|
+
{}
|
|
467
|
+
);
|
|
468
|
+
const t = i18n.t;
|
|
469
|
+
const i18nMixin = (i18n.mixin = {
|
|
470
|
+
beforeCreate () {
|
|
471
|
+
const unwatch = i18n.i18n.watchLocale(() => {
|
|
472
|
+
this.$forceUpdate();
|
|
473
|
+
});
|
|
474
|
+
this.$once('hook:beforeDestroy', function () {
|
|
475
|
+
unwatch();
|
|
476
|
+
});
|
|
477
|
+
},
|
|
478
|
+
methods: {
|
|
479
|
+
$$t (key, values) {
|
|
480
|
+
return t(key, values)
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
});
|
|
484
|
+
const setLocale = i18n.setLocale;
|
|
485
|
+
const getLocale = i18n.getLocale;
|
|
486
|
+
|
|
487
|
+
function initAppLocale (Vue, appVm, locale) {
|
|
488
|
+
const state = Vue.observable({
|
|
489
|
+
locale: locale || i18n.getLocale()
|
|
490
|
+
});
|
|
491
|
+
const localeWatchers = [];
|
|
492
|
+
appVm.$watchLocale = fn => {
|
|
493
|
+
localeWatchers.push(fn);
|
|
494
|
+
};
|
|
495
|
+
Object.defineProperty(appVm, '$locale', {
|
|
496
|
+
get () {
|
|
497
|
+
return state.locale
|
|
498
|
+
},
|
|
499
|
+
set (v) {
|
|
500
|
+
state.locale = v;
|
|
501
|
+
localeWatchers.forEach(watch => watch(v));
|
|
502
|
+
}
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
function isEnableLocale () {
|
|
507
|
+
return typeof __uniConfig !== 'undefined' && __uniConfig.locales && !!Object.keys(__uniConfig.locales).length
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
function include (str, parts) {
|
|
511
|
+
return !!parts.find((part) => str.indexOf(part) !== -1)
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
function startsWith (str, parts) {
|
|
515
|
+
return parts.find((part) => str.indexOf(part) === 0)
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
function normalizeLocale (locale, messages) {
|
|
519
|
+
if (!locale) {
|
|
520
|
+
return
|
|
521
|
+
}
|
|
522
|
+
locale = locale.trim().replace(/_/g, '-');
|
|
523
|
+
if (messages && messages[locale]) {
|
|
524
|
+
return locale
|
|
525
|
+
}
|
|
526
|
+
locale = locale.toLowerCase();
|
|
527
|
+
if (locale === 'chinese') {
|
|
528
|
+
// 支付宝
|
|
529
|
+
return LOCALE_ZH_HANS
|
|
530
|
+
}
|
|
531
|
+
if (locale.indexOf('zh') === 0) {
|
|
532
|
+
if (locale.indexOf('-hans') > -1) {
|
|
533
|
+
return LOCALE_ZH_HANS
|
|
534
|
+
}
|
|
535
|
+
if (locale.indexOf('-hant') > -1) {
|
|
536
|
+
return LOCALE_ZH_HANT
|
|
537
|
+
}
|
|
538
|
+
if (include(locale, ['-tw', '-hk', '-mo', '-cht'])) {
|
|
539
|
+
return LOCALE_ZH_HANT
|
|
540
|
+
}
|
|
541
|
+
return LOCALE_ZH_HANS
|
|
542
|
+
}
|
|
543
|
+
const lang = startsWith(locale, [LOCALE_EN, LOCALE_FR, LOCALE_ES]);
|
|
544
|
+
if (lang) {
|
|
545
|
+
return lang
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
// export function initI18n() {
|
|
549
|
+
// const localeKeys = Object.keys(__uniConfig.locales || {})
|
|
550
|
+
// if (localeKeys.length) {
|
|
551
|
+
// localeKeys.forEach((locale) =>
|
|
552
|
+
// i18n.add(locale, __uniConfig.locales[locale])
|
|
553
|
+
// )
|
|
554
|
+
// }
|
|
555
|
+
// }
|
|
556
|
+
|
|
557
|
+
function getLocale$1 () {
|
|
431
558
|
// 优先使用 $locale
|
|
432
559
|
const app = getApp({
|
|
433
560
|
allowDefault: true
|
|
@@ -435,10 +562,10 @@ function getLocale () {
|
|
|
435
562
|
if (app && app.$vm) {
|
|
436
563
|
return app.$vm.$locale
|
|
437
564
|
}
|
|
438
|
-
return qa.getSystemInfoSync().language ||
|
|
565
|
+
return normalizeLocale(qa.getSystemInfoSync().language) || LOCALE_EN
|
|
439
566
|
}
|
|
440
567
|
|
|
441
|
-
function setLocale (locale) {
|
|
568
|
+
function setLocale$1 (locale) {
|
|
442
569
|
const app = getApp();
|
|
443
570
|
if (!app) {
|
|
444
571
|
return false
|
|
@@ -462,7 +589,7 @@ function onLocaleChange (fn) {
|
|
|
462
589
|
}
|
|
463
590
|
|
|
464
591
|
if (typeof global !== 'undefined') {
|
|
465
|
-
global.getLocale = getLocale;
|
|
592
|
+
global.getLocale = getLocale$1;
|
|
466
593
|
}
|
|
467
594
|
|
|
468
595
|
const interceptors = {
|
|
@@ -472,8 +599,8 @@ const interceptors = {
|
|
|
472
599
|
var baseApi = /*#__PURE__*/Object.freeze({
|
|
473
600
|
__proto__: null,
|
|
474
601
|
upx2px: upx2px,
|
|
475
|
-
getLocale: getLocale,
|
|
476
|
-
setLocale: setLocale,
|
|
602
|
+
getLocale: getLocale$1,
|
|
603
|
+
setLocale: setLocale$1,
|
|
477
604
|
onLocaleChange: onLocaleChange,
|
|
478
605
|
addInterceptor: addInterceptor,
|
|
479
606
|
removeInterceptor: removeInterceptor,
|
|
@@ -651,10 +778,165 @@ var previewImage = {
|
|
|
651
778
|
}
|
|
652
779
|
};
|
|
653
780
|
|
|
781
|
+
const UUID_KEY = '__DC_STAT_UUID';
|
|
782
|
+
let deviceId;
|
|
783
|
+
function useDeviceId (result) {
|
|
784
|
+
deviceId = deviceId || qa.getStorageSync(UUID_KEY);
|
|
785
|
+
if (!deviceId) {
|
|
786
|
+
deviceId = Date.now() + '' + Math.floor(Math.random() * 1e7);
|
|
787
|
+
qa.setStorage({
|
|
788
|
+
key: UUID_KEY,
|
|
789
|
+
data: deviceId
|
|
790
|
+
});
|
|
791
|
+
}
|
|
792
|
+
result.deviceId = deviceId;
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
function addSafeAreaInsets (result) {
|
|
796
|
+
if (result.safeArea) {
|
|
797
|
+
const safeArea = result.safeArea;
|
|
798
|
+
result.safeAreaInsets = {
|
|
799
|
+
top: safeArea.top,
|
|
800
|
+
left: safeArea.left,
|
|
801
|
+
right: result.windowWidth - safeArea.right,
|
|
802
|
+
bottom: result.screenHeight - safeArea.bottom
|
|
803
|
+
};
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
function populateParameters (result) {
|
|
808
|
+
const {
|
|
809
|
+
brand = '', model = '', system = '',
|
|
810
|
+
language = '', theme, version,
|
|
811
|
+
platform, fontSizeSetting,
|
|
812
|
+
SDKVersion, pixelRatio, deviceOrientation
|
|
813
|
+
} = result;
|
|
814
|
+
// const isQuickApp = "quickapp-webview".indexOf('quickapp-webview') !== -1
|
|
815
|
+
|
|
816
|
+
// osName osVersion
|
|
817
|
+
let osName = '';
|
|
818
|
+
let osVersion = '';
|
|
819
|
+
{
|
|
820
|
+
osName = system.split(' ')[0] || '';
|
|
821
|
+
osVersion = system.split(' ')[1] || '';
|
|
822
|
+
}
|
|
823
|
+
let hostVersion = version;
|
|
824
|
+
|
|
825
|
+
// deviceType
|
|
826
|
+
const deviceType = getGetDeviceType(result, model);
|
|
827
|
+
|
|
828
|
+
// deviceModel
|
|
829
|
+
const deviceBrand = getDeviceBrand(brand);
|
|
830
|
+
|
|
831
|
+
// hostName
|
|
832
|
+
const _hostName = getHostName(result);
|
|
833
|
+
|
|
834
|
+
// deviceOrientation
|
|
835
|
+
let _deviceOrientation = deviceOrientation; // 仅 微信 百度 支持
|
|
836
|
+
|
|
837
|
+
// devicePixelRatio
|
|
838
|
+
let _devicePixelRatio = pixelRatio;
|
|
839
|
+
|
|
840
|
+
// SDKVersion
|
|
841
|
+
let _SDKVersion = SDKVersion;
|
|
842
|
+
|
|
843
|
+
// hostLanguage
|
|
844
|
+
const hostLanguage = language.replace(/_/g, '-');
|
|
845
|
+
|
|
846
|
+
// wx.getAccountInfoSync
|
|
847
|
+
|
|
848
|
+
const parameters = {
|
|
849
|
+
appId: process.env.UNI_APP_ID,
|
|
850
|
+
appName: process.env.UNI_APP_NAME,
|
|
851
|
+
appVersion: process.env.UNI_APP_VERSION_NAME,
|
|
852
|
+
appVersionCode: process.env.UNI_APP_VERSION_CODE,
|
|
853
|
+
appLanguage: getAppLanguage(hostLanguage),
|
|
854
|
+
uniCompileVersion: process.env.UNI_COMPILER_VERSION,
|
|
855
|
+
uniRuntimeVersion: process.env.UNI_COMPILER_VERSION,
|
|
856
|
+
uniPlatform: process.env.UNI_SUB_PLATFORM || process.env.UNI_PLATFORM,
|
|
857
|
+
deviceBrand,
|
|
858
|
+
deviceModel: model,
|
|
859
|
+
deviceType,
|
|
860
|
+
devicePixelRatio: _devicePixelRatio,
|
|
861
|
+
deviceOrientation: _deviceOrientation,
|
|
862
|
+
osName: osName.toLocaleLowerCase(),
|
|
863
|
+
osVersion,
|
|
864
|
+
hostTheme: theme,
|
|
865
|
+
hostVersion,
|
|
866
|
+
hostLanguage,
|
|
867
|
+
hostName: _hostName,
|
|
868
|
+
hostSDKVersion: _SDKVersion,
|
|
869
|
+
hostFontSizeSetting: fontSizeSetting,
|
|
870
|
+
windowTop: 0,
|
|
871
|
+
windowBottom: 0,
|
|
872
|
+
// TODO
|
|
873
|
+
osLanguage: undefined,
|
|
874
|
+
osTheme: undefined,
|
|
875
|
+
ua: undefined,
|
|
876
|
+
hostPackageName: undefined,
|
|
877
|
+
browserName: undefined,
|
|
878
|
+
browserVersion: undefined
|
|
879
|
+
};
|
|
880
|
+
|
|
881
|
+
Object.assign(result, parameters);
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
function getGetDeviceType (result, model) {
|
|
885
|
+
let deviceType = result.deviceType || 'phone';
|
|
886
|
+
{
|
|
887
|
+
const deviceTypeMaps = {
|
|
888
|
+
ipad: 'pad',
|
|
889
|
+
windows: 'pc',
|
|
890
|
+
mac: 'pc'
|
|
891
|
+
};
|
|
892
|
+
const deviceTypeMapsKeys = Object.keys(deviceTypeMaps);
|
|
893
|
+
const _model = model.toLocaleLowerCase();
|
|
894
|
+
for (let index = 0; index < deviceTypeMapsKeys.length; index++) {
|
|
895
|
+
const _m = deviceTypeMapsKeys[index];
|
|
896
|
+
if (_model.indexOf(_m) !== -1) {
|
|
897
|
+
deviceType = deviceTypeMaps[_m];
|
|
898
|
+
break
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
return deviceType
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
function getDeviceBrand (brand) {
|
|
906
|
+
let deviceBrand = brand;
|
|
907
|
+
if (deviceBrand) {
|
|
908
|
+
deviceBrand = brand.toLocaleLowerCase();
|
|
909
|
+
}
|
|
910
|
+
return deviceBrand
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
function getAppLanguage (defaultLanguage) {
|
|
914
|
+
return getLocale$1
|
|
915
|
+
? getLocale$1()
|
|
916
|
+
: defaultLanguage
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
function getHostName (result) {
|
|
920
|
+
const _platform = "quickapp-webview".split('-')[1];
|
|
921
|
+
let _hostName = result.hostName || _platform; // mp-jd
|
|
922
|
+
|
|
923
|
+
return _hostName
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
var getSystemInfo = {
|
|
927
|
+
returnValue: function (result) {
|
|
928
|
+
useDeviceId(result);
|
|
929
|
+
addSafeAreaInsets(result);
|
|
930
|
+
populateParameters(result);
|
|
931
|
+
}
|
|
932
|
+
};
|
|
933
|
+
|
|
654
934
|
const protocols = {
|
|
655
935
|
navigateTo,
|
|
656
936
|
redirectTo,
|
|
657
|
-
previewImage
|
|
937
|
+
previewImage,
|
|
938
|
+
getSystemInfo,
|
|
939
|
+
getSystemInfoSync: getSystemInfo
|
|
658
940
|
};
|
|
659
941
|
const todos = [
|
|
660
942
|
'preloadPage',
|
|
@@ -855,8 +1137,136 @@ var eventApi = /*#__PURE__*/Object.freeze({
|
|
|
855
1137
|
$emit: $emit
|
|
856
1138
|
});
|
|
857
1139
|
|
|
1140
|
+
/**
|
|
1141
|
+
* 框架内 try-catch
|
|
1142
|
+
*/
|
|
1143
|
+
/**
|
|
1144
|
+
* 开发者 try-catch
|
|
1145
|
+
*/
|
|
1146
|
+
function tryCatch (fn) {
|
|
1147
|
+
return function () {
|
|
1148
|
+
try {
|
|
1149
|
+
return fn.apply(fn, arguments)
|
|
1150
|
+
} catch (e) {
|
|
1151
|
+
// TODO
|
|
1152
|
+
console.error(e);
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1157
|
+
function getApiCallbacks (params) {
|
|
1158
|
+
const apiCallbacks = {};
|
|
1159
|
+
for (const name in params) {
|
|
1160
|
+
const param = params[name];
|
|
1161
|
+
if (isFn(param)) {
|
|
1162
|
+
apiCallbacks[name] = tryCatch(param);
|
|
1163
|
+
delete params[name];
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
return apiCallbacks
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
let cid;
|
|
1170
|
+
let cidErrMsg;
|
|
1171
|
+
|
|
1172
|
+
function normalizePushMessage (message) {
|
|
1173
|
+
try {
|
|
1174
|
+
return JSON.parse(message)
|
|
1175
|
+
} catch (e) {}
|
|
1176
|
+
return message
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
function invokePushCallback (
|
|
1180
|
+
args
|
|
1181
|
+
) {
|
|
1182
|
+
if (args.type === 'clientId') {
|
|
1183
|
+
cid = args.cid;
|
|
1184
|
+
cidErrMsg = args.errMsg;
|
|
1185
|
+
invokeGetPushCidCallbacks(cid, args.errMsg);
|
|
1186
|
+
} else if (args.type === 'pushMsg') {
|
|
1187
|
+
onPushMessageCallbacks.forEach((callback) => {
|
|
1188
|
+
callback({
|
|
1189
|
+
type: 'receive',
|
|
1190
|
+
data: normalizePushMessage(args.message)
|
|
1191
|
+
});
|
|
1192
|
+
});
|
|
1193
|
+
} else if (args.type === 'click') {
|
|
1194
|
+
onPushMessageCallbacks.forEach((callback) => {
|
|
1195
|
+
callback({
|
|
1196
|
+
type: 'click',
|
|
1197
|
+
data: normalizePushMessage(args.message)
|
|
1198
|
+
});
|
|
1199
|
+
});
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
const getPushCidCallbacks = [];
|
|
1204
|
+
|
|
1205
|
+
function invokeGetPushCidCallbacks (cid, errMsg) {
|
|
1206
|
+
getPushCidCallbacks.forEach((callback) => {
|
|
1207
|
+
callback(cid, errMsg);
|
|
1208
|
+
});
|
|
1209
|
+
getPushCidCallbacks.length = 0;
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
function getPushClientid (args) {
|
|
1213
|
+
if (!isPlainObject(args)) {
|
|
1214
|
+
args = {};
|
|
1215
|
+
}
|
|
1216
|
+
const {
|
|
1217
|
+
success,
|
|
1218
|
+
fail,
|
|
1219
|
+
complete
|
|
1220
|
+
} = getApiCallbacks(args);
|
|
1221
|
+
const hasSuccess = isFn(success);
|
|
1222
|
+
const hasFail = isFn(fail);
|
|
1223
|
+
const hasComplete = isFn(complete);
|
|
1224
|
+
getPushCidCallbacks.push((cid, errMsg) => {
|
|
1225
|
+
let res;
|
|
1226
|
+
if (cid) {
|
|
1227
|
+
res = {
|
|
1228
|
+
errMsg: 'getPushClientid:ok',
|
|
1229
|
+
cid
|
|
1230
|
+
};
|
|
1231
|
+
hasSuccess && success(res);
|
|
1232
|
+
} else {
|
|
1233
|
+
res = {
|
|
1234
|
+
errMsg: 'getPushClientid:fail' + (errMsg ? ' ' + errMsg : '')
|
|
1235
|
+
};
|
|
1236
|
+
hasFail && fail(res);
|
|
1237
|
+
}
|
|
1238
|
+
hasComplete && complete(res);
|
|
1239
|
+
});
|
|
1240
|
+
if (typeof cid !== 'undefined') {
|
|
1241
|
+
Promise.resolve().then(() => invokeGetPushCidCallbacks(cid, cidErrMsg));
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
|
|
1245
|
+
const onPushMessageCallbacks = [];
|
|
1246
|
+
// 不使用 defineOnApi 实现,是因为 defineOnApi 依赖 UniServiceJSBridge ,该对象目前在小程序上未提供,故简单实现
|
|
1247
|
+
const onPushMessage = (fn) => {
|
|
1248
|
+
if (onPushMessageCallbacks.indexOf(fn) === -1) {
|
|
1249
|
+
onPushMessageCallbacks.push(fn);
|
|
1250
|
+
}
|
|
1251
|
+
};
|
|
1252
|
+
|
|
1253
|
+
const offPushMessage = (fn) => {
|
|
1254
|
+
if (!fn) {
|
|
1255
|
+
onPushMessageCallbacks.length = 0;
|
|
1256
|
+
} else {
|
|
1257
|
+
const index = onPushMessageCallbacks.indexOf(fn);
|
|
1258
|
+
if (index > -1) {
|
|
1259
|
+
onPushMessageCallbacks.splice(index, 1);
|
|
1260
|
+
}
|
|
1261
|
+
}
|
|
1262
|
+
};
|
|
1263
|
+
|
|
858
1264
|
var api = /*#__PURE__*/Object.freeze({
|
|
859
|
-
__proto__: null
|
|
1265
|
+
__proto__: null,
|
|
1266
|
+
getPushClientid: getPushClientid,
|
|
1267
|
+
onPushMessage: onPushMessage,
|
|
1268
|
+
offPushMessage: offPushMessage,
|
|
1269
|
+
invokePushCallback: invokePushCallback
|
|
860
1270
|
});
|
|
861
1271
|
|
|
862
1272
|
const MPPage = Page;
|
|
@@ -1451,89 +1861,6 @@ function handleEvent (event) {
|
|
|
1451
1861
|
}
|
|
1452
1862
|
}
|
|
1453
1863
|
|
|
1454
|
-
const messages = {};
|
|
1455
|
-
|
|
1456
|
-
let locale;
|
|
1457
|
-
|
|
1458
|
-
{
|
|
1459
|
-
locale = qa.getSystemInfoSync().language;
|
|
1460
|
-
}
|
|
1461
|
-
|
|
1462
|
-
function initI18nMessages () {
|
|
1463
|
-
if (!isEnableLocale()) {
|
|
1464
|
-
return
|
|
1465
|
-
}
|
|
1466
|
-
const localeKeys = Object.keys(__uniConfig.locales);
|
|
1467
|
-
if (localeKeys.length) {
|
|
1468
|
-
localeKeys.forEach((locale) => {
|
|
1469
|
-
const curMessages = messages[locale];
|
|
1470
|
-
const userMessages = __uniConfig.locales[locale];
|
|
1471
|
-
if (curMessages) {
|
|
1472
|
-
Object.assign(curMessages, userMessages);
|
|
1473
|
-
} else {
|
|
1474
|
-
messages[locale] = userMessages;
|
|
1475
|
-
}
|
|
1476
|
-
});
|
|
1477
|
-
}
|
|
1478
|
-
}
|
|
1479
|
-
|
|
1480
|
-
initI18nMessages();
|
|
1481
|
-
|
|
1482
|
-
const i18n = initVueI18n(
|
|
1483
|
-
locale,
|
|
1484
|
-
{}
|
|
1485
|
-
);
|
|
1486
|
-
const t = i18n.t;
|
|
1487
|
-
const i18nMixin = (i18n.mixin = {
|
|
1488
|
-
beforeCreate () {
|
|
1489
|
-
const unwatch = i18n.i18n.watchLocale(() => {
|
|
1490
|
-
this.$forceUpdate();
|
|
1491
|
-
});
|
|
1492
|
-
this.$once('hook:beforeDestroy', function () {
|
|
1493
|
-
unwatch();
|
|
1494
|
-
});
|
|
1495
|
-
},
|
|
1496
|
-
methods: {
|
|
1497
|
-
$$t (key, values) {
|
|
1498
|
-
return t(key, values)
|
|
1499
|
-
}
|
|
1500
|
-
}
|
|
1501
|
-
});
|
|
1502
|
-
const setLocale$1 = i18n.setLocale;
|
|
1503
|
-
const getLocale$1 = i18n.getLocale;
|
|
1504
|
-
|
|
1505
|
-
function initAppLocale (Vue, appVm, locale) {
|
|
1506
|
-
const state = Vue.observable({
|
|
1507
|
-
locale: locale || i18n.getLocale()
|
|
1508
|
-
});
|
|
1509
|
-
const localeWatchers = [];
|
|
1510
|
-
appVm.$watchLocale = fn => {
|
|
1511
|
-
localeWatchers.push(fn);
|
|
1512
|
-
};
|
|
1513
|
-
Object.defineProperty(appVm, '$locale', {
|
|
1514
|
-
get () {
|
|
1515
|
-
return state.locale
|
|
1516
|
-
},
|
|
1517
|
-
set (v) {
|
|
1518
|
-
state.locale = v;
|
|
1519
|
-
localeWatchers.forEach(watch => watch(v));
|
|
1520
|
-
}
|
|
1521
|
-
});
|
|
1522
|
-
}
|
|
1523
|
-
|
|
1524
|
-
function isEnableLocale () {
|
|
1525
|
-
return typeof __uniConfig !== 'undefined' && __uniConfig.locales && !!Object.keys(__uniConfig.locales).length
|
|
1526
|
-
}
|
|
1527
|
-
|
|
1528
|
-
// export function initI18n() {
|
|
1529
|
-
// const localeKeys = Object.keys(__uniConfig.locales || {})
|
|
1530
|
-
// if (localeKeys.length) {
|
|
1531
|
-
// localeKeys.forEach((locale) =>
|
|
1532
|
-
// i18n.add(locale, __uniConfig.locales[locale])
|
|
1533
|
-
// )
|
|
1534
|
-
// }
|
|
1535
|
-
// }
|
|
1536
|
-
|
|
1537
1864
|
const hooks = [
|
|
1538
1865
|
'onShow',
|
|
1539
1866
|
'onHide',
|
|
@@ -1635,7 +1962,7 @@ function parseBaseApp (vm, {
|
|
|
1635
1962
|
});
|
|
1636
1963
|
}
|
|
1637
1964
|
|
|
1638
|
-
initAppLocale(Vue, vm, qa.getSystemInfoSync().language ||
|
|
1965
|
+
initAppLocale(Vue, vm, normalizeLocale(qa.getSystemInfoSync().language) || LOCALE_EN);
|
|
1639
1966
|
|
|
1640
1967
|
initHooks(appOptions, hooks);
|
|
1641
1968
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcloudio/uni-quickapp-webview",
|
|
3
|
-
"version": "2.0.1-
|
|
3
|
+
"version": "2.0.1-34920220607003",
|
|
4
4
|
"description": "uni-app quickapp-webview",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -17,5 +17,5 @@
|
|
|
17
17
|
"name": "quickapp-webview",
|
|
18
18
|
"title": "快应用(Webview)版"
|
|
19
19
|
},
|
|
20
|
-
"gitHead": "
|
|
20
|
+
"gitHead": "ab4199a51b6a576ce347f419e2b013ec3a60c15a"
|
|
21
21
|
}
|