Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wzj-java
uni-app
提交
fd8d558f
U
uni-app
项目概览
wzj-java
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
fd8d558f
编写于
9月 02, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wip(i18n): mp
上级
0afa02f1
变更
17
展开全部
隐藏空白更改
内联
并排
Showing
17 changed file
with
1666 addition
and
722 deletion
+1666
-722
build/rollup.config.mp.js
build/rollup.config.mp.js
+3
-3
packages/uni-app-plus/dist/index.js
packages/uni-app-plus/dist/index.js
+280
-16
packages/uni-app-plus/dist/index.v3.js
packages/uni-app-plus/dist/index.v3.js
+2
-2
packages/uni-h5/dist/index.umd.min.js
packages/uni-h5/dist/index.umd.min.js
+1
-1
packages/uni-mp-alipay/dist/index.js
packages/uni-mp-alipay/dist/index.js
+508
-419
packages/uni-mp-baidu/dist/index.js
packages/uni-mp-baidu/dist/index.js
+145
-33
packages/uni-mp-kuaishou/dist/index.js
packages/uni-mp-kuaishou/dist/index.js
+87
-2
packages/uni-mp-qq/dist/index.js
packages/uni-mp-qq/dist/index.js
+105
-16
packages/uni-mp-toutiao/dist/index.js
packages/uni-mp-toutiao/dist/index.js
+276
-191
packages/uni-mp-weixin/dist/index.js
packages/uni-mp-weixin/dist/index.js
+105
-16
packages/uni-quickapp-native/dist/vue.dev.js
packages/uni-quickapp-native/dist/vue.dev.js
+1
-1
packages/uni-quickapp-native/dist/vue.prod.js
packages/uni-quickapp-native/dist/vue.prod.js
+1
-1
packages/uni-quickapp-webview/dist/index.js
packages/uni-quickapp-webview/dist/index.js
+105
-16
src/core/helpers/i18n/index.js
src/core/helpers/i18n/index.js
+3
-3
src/core/runtime/base.js
src/core/runtime/base.js
+2
-0
src/core/runtime/locale.js
src/core/runtime/locale.js
+33
-0
src/platforms/mp-weixin/runtime/wrapper/app-base-parser.js
src/platforms/mp-weixin/runtime/wrapper/app-base-parser.js
+9
-2
未找到文件。
build/rollup.config.mp.js
浏览文件 @
fd8d558f
const
path
=
require
(
'
path
'
)
const
path
=
require
(
'
path
'
)
const
json
=
require
(
'
@rollup/plugin-json
'
)
const
alias
=
require
(
'
@rollup/plugin-alias
'
)
const
replace
=
require
(
'
@rollup/plugin-replace
'
)
...
...
@@ -75,7 +75,7 @@ module.exports = {
find
:
'
uni-helpers
'
,
replacement
:
path
.
resolve
(
__dirname
,
'
../src/core/helpers
'
)
}]
}),
}),
json
(),
replace
({
__GLOBAL__
:
platform
.
prefix
,
...
...
@@ -84,5 +84,5 @@ module.exports = {
__PLATFORM__
:
JSON
.
stringify
(
process
.
env
.
UNI_PLATFORM
)
})
],
external
:
[
'
vue
'
]
external
:
[
'
vue
'
,
'
@dcloudio/uni-i18n
'
]
}
packages/uni-app-plus/dist/index.js
浏览文件 @
fd8d558f
import
Vue
from
'
vue
'
;
import
{
initVueI18n
}
from
'
@dcloudio/uni-i18n
'
;
function
b64DecodeUnicode
(
str
)
{
return
decodeURIComponent
(
atob
(
str
).
split
(
''
).
map
(
function
(
c
)
{
...
...
@@ -192,7 +193,7 @@ function queue (hooks, data) {
}
if
(
res
===
false
)
{
return
{
then
()
{}
then
()
{
}
}
}
}
...
...
@@ -240,15 +241,15 @@ function getApiInterceptorHooks (method) {
if
(
hook
!==
'
returnValue
'
)
{
interceptor
[
hook
]
=
globalInterceptors
[
hook
].
slice
();
}
});
const
scopedInterceptor
=
scopedInterceptors
[
method
];
if
(
scopedInterceptor
)
{
Object
.
keys
(
scopedInterceptor
).
forEach
(
hook
=>
{
if
(
hook
!==
'
returnValue
'
)
{
interceptor
[
hook
]
=
(
interceptor
[
hook
]
||
[]).
concat
(
scopedInterceptor
[
hook
]);
}
});
}
});
const
scopedInterceptor
=
scopedInterceptors
[
method
];
if
(
scopedInterceptor
)
{
Object
.
keys
(
scopedInterceptor
).
forEach
(
hook
=>
{
if
(
hook
!==
'
returnValue
'
)
{
interceptor
[
hook
]
=
(
interceptor
[
hook
]
||
[]).
concat
(
scopedInterceptor
[
hook
]);
}
});
}
return
interceptor
}
...
...
@@ -272,16 +273,20 @@ const promiseInterceptor = {
if
(
!
isPromise
(
res
))
{
return
res
}
return
res
.
then
(
res
=>
{
return
res
[
1
]
}).
catch
(
res
=>
{
return
res
[
0
]
return
new
Promise
((
resolve
,
reject
)
=>
{
res
.
then
(
res
=>
{
if
(
res
[
0
])
{
reject
(
res
[
0
]);
}
else
{
resolve
(
res
[
1
]);
}
});
})
}
};
const
SYNC_API_RE
=
/^
\$
|Window$|WindowStyle$|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
;
/^
\$
|Window$|WindowStyle$|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64
|getLocale|setLocale
/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
...
...
@@ -394,6 +399,40 @@ function upx2px (number, newDeviceWidth) {
return
number
<
0
?
-
result
:
result
}
function
getLocale
()
{
// 优先使用 $locale
const
app
=
getApp
({
allowDefault
:
true
});
if
(
app
&&
app
.
$vm
)
{
return
app
.
$vm
.
$locale
}
return
wx
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
}
function
setLocale
(
locale
)
{
const
app
=
getApp
();
if
(
!
app
)
{
return
false
}
const
oldLocale
=
app
.
$vm
.
$locale
;
if
(
oldLocale
!==
locale
)
{
app
.
$vm
.
$locale
=
locale
;
onLocaleChangeCallbacks
.
forEach
((
fn
)
=>
fn
({
locale
}));
return
true
}
return
false
}
const
onLocaleChangeCallbacks
=
[];
function
onLocaleChange
(
fn
)
{
if
(
onLocaleChangeCallbacks
.
indexOf
(
fn
)
===
-
1
)
{
onLocaleChangeCallbacks
.
push
(
fn
);
}
}
const
interceptors
=
{
promiseInterceptor
};
...
...
@@ -401,6 +440,9 @@ const interceptors = {
var
baseApi
=
/*#__PURE__*/
Object
.
freeze
({
__proto__
:
null
,
upx2px
:
upx2px
,
getLocale
:
getLocale
,
setLocale
:
setLocale
,
onLocaleChange
:
onLocaleChange
,
addInterceptor
:
addInterceptor
,
removeInterceptor
:
removeInterceptor
,
interceptors
:
interceptors
...
...
@@ -662,7 +704,7 @@ function initTriggerEvent (mpInstance) {
};
}
function
initHook
(
name
,
options
)
{
function
initHook
(
name
,
options
,
isComponent
)
{
const
oldHook
=
options
[
name
];
if
(
!
oldHook
)
{
options
[
name
]
=
function
()
{
...
...
@@ -1232,6 +1274,226 @@ function handleEvent (event) {
}
}
var
en
=
{
"
uni.app.quit
"
:
"
Press back button again to exit
"
,
"
uni.async.error
"
:
"
The connection timed out, click the screen to try again.
"
,
"
uni.showActionSheet.cancel
"
:
"
Cancel
"
,
"
uni.showToast.unpaired
"
:
"
Please note showToast must be paired with hideToast
"
,
"
uni.showLoading.unpaired
"
:
"
Please note showLoading must be paired with hideLoading
"
,
"
uni.showModal.cancel
"
:
"
Cancel
"
,
"
uni.showModal.confirm
"
:
"
OK
"
,
"
uni.chooseImage.cancel
"
:
"
Cancel
"
,
"
uni.chooseImage.sourceType.album
"
:
"
Album
"
,
"
uni.chooseImage.sourceType.camera
"
:
"
Camera
"
,
"
uni.chooseVideo.cancel
"
:
"
Cancel
"
,
"
uni.chooseVideo.sourceType.album
"
:
"
Album
"
,
"
uni.chooseVideo.sourceType.camera
"
:
"
Camera
"
,
"
uni.previewImage.cancel
"
:
"
Cancel
"
,
"
uni.previewImage.button.save
"
:
"
Save Image
"
,
"
uni.previewImage.save.success
"
:
"
Saved successfully
"
,
"
uni.previewImage.save.fail
"
:
"
Save failed
"
,
"
uni.setClipboardData.success
"
:
"
Content copied
"
,
"
uni.scanCode.title
"
:
"
Scan code
"
,
"
uni.scanCode.album
"
:
"
Album
"
,
"
uni.scanCode.fail
"
:
"
Recognition failure
"
,
"
uni.scanCode.flash.on
"
:
"
Tap to turn light on
"
,
"
uni.scanCode.flash.off
"
:
"
Tap to turn light off
"
,
"
uni.startSoterAuthentication.authContent
"
:
"
Fingerprint recognition
"
,
"
uni.picker.done
"
:
"
Done
"
,
"
uni.picker.cancel
"
:
"
Cancel
"
,
"
uni.video.danmu
"
:
"
Danmu
"
,
"
uni.video.volume
"
:
"
Volume
"
,
"
uni.button.feedback.title
"
:
"
feedback
"
,
"
uni.button.feedback.send
"
:
"
send
"
};
var
es
=
{
"
uni.app.quit
"
:
"
Pulse otra vez para salir
"
,
"
uni.async.error
"
:
"
Se agotó el tiempo de conexión, haga clic en la pantalla para volver a intentarlo.
"
,
"
uni.showActionSheet.cancel
"
:
"
Cancelar
"
,
"
uni.showToast.unpaired
"
:
"
Tenga en cuenta que showToast debe estar emparejado con hideToast
"
,
"
uni.showLoading.unpaired
"
:
"
Tenga en cuenta que showLoading debe estar emparejado con hideLoading
"
,
"
uni.showModal.cancel
"
:
"
Cancelar
"
,
"
uni.showModal.confirm
"
:
"
OK
"
,
"
uni.chooseImage.cancel
"
:
"
Cancelar
"
,
"
uni.chooseImage.sourceType.album
"
:
"
Álbum
"
,
"
uni.chooseImage.sourceType.camera
"
:
"
Cámara
"
,
"
uni.chooseVideo.cancel
"
:
"
Cancelar
"
,
"
uni.chooseVideo.sourceType.album
"
:
"
Álbum
"
,
"
uni.chooseVideo.sourceType.camera
"
:
"
Cámara
"
,
"
uni.previewImage.cancel
"
:
"
Cancelar
"
,
"
uni.previewImage.button.save
"
:
"
Guardar imagen
"
,
"
uni.previewImage.save.success
"
:
"
Guardado exitosamente
"
,
"
uni.previewImage.save.fail
"
:
"
Error al guardar
"
,
"
uni.setClipboardData.success
"
:
"
Contenido copiado
"
,
"
uni.scanCode.title
"
:
"
Código de escaneo
"
,
"
uni.scanCode.album
"
:
"
Álbum
"
,
"
uni.scanCode.fail
"
:
"
Échec de la reconnaissance
"
,
"
uni.scanCode.flash.on
"
:
"
Toque para encender la luz
"
,
"
uni.scanCode.flash.off
"
:
"
Toque para apagar la luz
"
,
"
uni.startSoterAuthentication.authContent
"
:
"
Reconocimiento de huellas dactilares
"
,
"
uni.picker.done
"
:
"
OK
"
,
"
uni.picker.cancel
"
:
"
Cancelar
"
,
"
uni.video.danmu
"
:
"
Danmu
"
,
"
uni.video.volume
"
:
"
Volumen
"
,
"
uni.button.feedback.title
"
:
"
realimentación
"
,
"
uni.button.feedback.send
"
:
"
enviar
"
};
var
fr
=
{
"
uni.app.quit
"
:
"
Appuyez à nouveau pour quitter l'application
"
,
"
uni.async.error
"
:
"
La connexion a expiré, cliquez sur l'écran pour réessayer.
"
,
"
uni.showActionSheet.cancel
"
:
"
Annuler
"
,
"
uni.showToast.unpaired
"
:
"
Veuillez noter que showToast doit être associé à hideToast
"
,
"
uni.showLoading.unpaired
"
:
"
Veuillez noter que showLoading doit être associé à hideLoading
"
,
"
uni.showModal.cancel
"
:
"
Annuler
"
,
"
uni.showModal.confirm
"
:
"
OK
"
,
"
uni.chooseImage.cancel
"
:
"
Annuler
"
,
"
uni.chooseImage.sourceType.album
"
:
"
Album
"
,
"
uni.chooseImage.sourceType.camera
"
:
"
Caméra
"
,
"
uni.chooseVideo.cancel
"
:
"
Annuler
"
,
"
uni.chooseVideo.sourceType.album
"
:
"
Album
"
,
"
uni.chooseVideo.sourceType.camera
"
:
"
Caméra
"
,
"
uni.previewImage.cancel
"
:
"
Annuler
"
,
"
uni.previewImage.button.save
"
:
"
Guardar imagen
"
,
"
uni.previewImage.save.success
"
:
"
Enregistré avec succès
"
,
"
uni.previewImage.save.fail
"
:
"
Échec de la sauvegarde
"
,
"
uni.setClipboardData.success
"
:
"
Contenu copié
"
,
"
uni.scanCode.title
"
:
"
Code d’analyse
"
,
"
uni.scanCode.album
"
:
"
Album
"
,
"
uni.scanCode.fail
"
:
"
Fallo de reconocimiento
"
,
"
uni.scanCode.flash.on
"
:
"
Appuyez pour activer l'éclairage
"
,
"
uni.scanCode.flash.off
"
:
"
Appuyez pour désactiver l'éclairage
"
,
"
uni.startSoterAuthentication.authContent
"
:
"
Reconnaissance de l'empreinte digitale
"
,
"
uni.picker.done
"
:
"
OK
"
,
"
uni.picker.cancel
"
:
"
Annuler
"
,
"
uni.video.danmu
"
:
"
Danmu
"
,
"
uni.video.volume
"
:
"
Le Volume
"
,
"
uni.button.feedback.title
"
:
"
retour d'information
"
,
"
uni.button.feedback.send
"
:
"
envoyer
"
};
var
zhHans
=
{
"
uni.app.quit
"
:
"
再按一次退出应用
"
,
"
uni.async.error
"
:
"
连接服务器超时,点击屏幕重试
"
,
"
uni.showActionSheet.cancel
"
:
"
取消
"
,
"
uni.showToast.unpaired
"
:
"
请注意 showToast 与 hideToast 必须配对使用
"
,
"
uni.showLoading.unpaired
"
:
"
请注意 showLoading 与 hideLoading 必须配对使用
"
,
"
uni.showModal.cancel
"
:
"
取消
"
,
"
uni.showModal.confirm
"
:
"
确定
"
,
"
uni.chooseImage.cancel
"
:
"
取消
"
,
"
uni.chooseImage.sourceType.album
"
:
"
从相册选择
"
,
"
uni.chooseImage.sourceType.camera
"
:
"
拍摄
"
,
"
uni.chooseVideo.cancel
"
:
"
取消
"
,
"
uni.chooseVideo.sourceType.album
"
:
"
从相册选择
"
,
"
uni.chooseVideo.sourceType.camera
"
:
"
拍摄
"
,
"
uni.previewImage.cancel
"
:
"
取消
"
,
"
uni.previewImage.button.save
"
:
"
保存图像
"
,
"
uni.previewImage.save.success
"
:
"
保存图像到相册成功
"
,
"
uni.previewImage.save.fail
"
:
"
保存图像到相册失败
"
,
"
uni.setClipboardData.success
"
:
"
内容已复制
"
,
"
uni.scanCode.title
"
:
"
扫码
"
,
"
uni.scanCode.album
"
:
"
相册
"
,
"
uni.scanCode.fail
"
:
"
识别失败
"
,
"
uni.scanCode.flash.on
"
:
"
轻触照亮
"
,
"
uni.scanCode.flash.off
"
:
"
轻触关闭
"
,
"
uni.startSoterAuthentication.authContent
"
:
"
指纹识别中...
"
,
"
uni.picker.done
"
:
"
完成
"
,
"
uni.picker.cancel
"
:
"
取消
"
,
"
uni.video.danmu
"
:
"
弹幕
"
,
"
uni.video.volume
"
:
"
音量
"
,
"
uni.button.feedback.title
"
:
"
问题反馈
"
,
"
uni.button.feedback.send
"
:
"
发送
"
};
var
zhHant
=
{
"
uni.app.quit
"
:
"
再按一次退出應用
"
,
"
uni.async.error
"
:
"
連接服務器超時,點擊屏幕重試
"
,
"
uni.showActionSheet.cancel
"
:
"
取消
"
,
"
uni.showToast.unpaired
"
:
"
請注意 showToast 與 hideToast 必須配對使用
"
,
"
uni.showLoading.unpaired
"
:
"
請注意 showLoading 與 hideLoading 必須配對使用
"
,
"
uni.showModal.cancel
"
:
"
取消
"
,
"
uni.showModal.confirm
"
:
"
確定
"
,
"
uni.chooseImage.cancel
"
:
"
取消
"
,
"
uni.chooseImage.sourceType.album
"
:
"
從相冊選擇
"
,
"
uni.chooseImage.sourceType.camera
"
:
"
拍攝
"
,
"
uni.chooseVideo.cancel
"
:
"
取消
"
,
"
uni.chooseVideo.sourceType.album
"
:
"
從相冊選擇
"
,
"
uni.chooseVideo.sourceType.camera
"
:
"
拍攝
"
,
"
uni.previewImage.cancel
"
:
"
取消
"
,
"
uni.previewImage.button.save
"
:
"
保存圖像
"
,
"
uni.previewImage.save.success
"
:
"
保存圖像到相冊成功
"
,
"
uni.previewImage.save.fail
"
:
"
保存圖像到相冊失敗
"
,
"
uni.setClipboardData.success
"
:
"
內容已復制
"
,
"
uni.scanCode.title
"
:
"
掃碼
"
,
"
uni.scanCode.album
"
:
"
相冊
"
,
"
uni.scanCode.fail
"
:
"
識別失敗
"
,
"
uni.scanCode.flash.on
"
:
"
輕觸照亮
"
,
"
uni.scanCode.flash.off
"
:
"
輕觸關閉
"
,
"
uni.startSoterAuthentication.authContent
"
:
"
指紋識別中...
"
,
"
uni.picker.done
"
:
"
完成
"
,
"
uni.picker.cancel
"
:
"
取消
"
,
"
uni.video.danmu
"
:
"
彈幕
"
,
"
uni.video.volume
"
:
"
音量
"
,
"
uni.button.feedback.title
"
:
"
問題反饋
"
,
"
uni.button.feedback.send
"
:
"
發送
"
};
const
messages
=
{
en
,
es
,
fr
,
'
zh-Hans
'
:
zhHans
,
'
zh-Hant
'
:
zhHant
};
let
locale
;
{
if
(
typeof
weex
===
'
object
'
)
{
locale
=
weex
.
requireModule
(
'
plus
'
).
getLanguage
();
}
}
const
i18n
=
initVueI18n
(
locale
,
messages
);
const
t
=
i18n
.
t
;
const
i18nMixin
=
i18n
.
mixin
=
{
beforeCreate
()
{
const
unwatch
=
i18n
.
i18n
.
watchLocale
(()
=>
{
this
.
$forceUpdate
();
});
this
.
$once
(
'
hook:beforeDestroy
'
,
function
()
{
unwatch
();
});
},
methods
:
{
$$t
(
key
,
values
)
{
return
t
(
key
,
values
)
}
}
};
const
setLocale$1
=
i18n
.
setLocale
;
const
getLocale$1
=
i18n
.
getLocale
;
function
initAppLocale
(
Vue
,
appVm
,
locale
)
{
const
state
=
Vue
.
observable
({
locale
:
locale
||
i18n
.
getLocale
()
});
const
localeWatchers
=
[];
appVm
.
$watchLocale
=
(
fn
)
=>
{
localeWatchers
.
push
(
fn
);
};
Object
.
defineProperty
(
appVm
,
'
$locale
'
,
{
get
()
{
return
state
.
locale
},
set
(
v
)
{
state
.
locale
=
v
;
localeWatchers
.
forEach
(
watch
=>
watch
(
v
));
}
});
}
class
EventChannel
{
constructor
(
id
,
events
)
{
this
.
id
=
id
;
...
...
@@ -1414,6 +1676,8 @@ function parseBaseApp (vm, {
});
}
initAppLocale
(
Vue
,
vm
,
wx
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
);
initHooks
(
appOptions
,
hooks
);
return
appOptions
...
...
packages/uni-app-plus/dist/index.v3.js
浏览文件 @
fd8d558f
...
...
@@ -1666,9 +1666,9 @@ var serviceContext = (function () {
};
const getLocale = i18n.getLocale;
function initAppLocale (Vue, appVm) {
function initAppLocale (Vue, appVm
, locale
) {
const state = Vue.observable({
locale: i18n.getLocale()
locale:
locale ||
i18n.getLocale()
});
const localeWatchers = [];
appVm.$watchLocale = (fn) => {
...
...
packages/uni-h5/dist/index.umd.min.js
浏览文件 @
fd8d558f
此差异已折叠。
点击以展开。
packages/uni-mp-alipay/dist/index.js
浏览文件 @
fd8d558f
此差异已折叠。
点击以展开。
packages/uni-mp-baidu/dist/index.js
浏览文件 @
fd8d558f
import
Vue
from
'
vue
'
;
import
{
initVueI18n
}
from
'
@dcloudio/uni-i18n
'
;
function
b64DecodeUnicode
(
str
)
{
return
decodeURIComponent
(
atob
(
str
).
split
(
''
).
map
(
function
(
c
)
{
...
...
@@ -192,7 +193,7 @@ function queue (hooks, data) {
}
if
(
res
===
false
)
{
return
{
then
()
{}
then
()
{
}
}
}
}
...
...
@@ -240,15 +241,15 @@ function getApiInterceptorHooks (method) {
if
(
hook
!==
'
returnValue
'
)
{
interceptor
[
hook
]
=
globalInterceptors
[
hook
].
slice
();
}
});
const
scopedInterceptor
=
scopedInterceptors
[
method
];
if
(
scopedInterceptor
)
{
Object
.
keys
(
scopedInterceptor
).
forEach
(
hook
=>
{
if
(
hook
!==
'
returnValue
'
)
{
interceptor
[
hook
]
=
(
interceptor
[
hook
]
||
[]).
concat
(
scopedInterceptor
[
hook
]);
}
});
}
});
const
scopedInterceptor
=
scopedInterceptors
[
method
];
if
(
scopedInterceptor
)
{
Object
.
keys
(
scopedInterceptor
).
forEach
(
hook
=>
{
if
(
hook
!==
'
returnValue
'
)
{
interceptor
[
hook
]
=
(
interceptor
[
hook
]
||
[]).
concat
(
scopedInterceptor
[
hook
]);
}
});
}
return
interceptor
}
...
...
@@ -272,16 +273,20 @@ const promiseInterceptor = {
if
(
!
isPromise
(
res
))
{
return
res
}
return
res
.
then
(
res
=>
{
return
res
[
1
]
}).
catch
(
res
=>
{
return
res
[
0
]
return
new
Promise
((
resolve
,
reject
)
=>
{
res
.
then
(
res
=>
{
if
(
res
[
0
])
{
reject
(
res
[
0
]);
}
else
{
resolve
(
res
[
1
]);
}
});
})
}
};
const
SYNC_API_RE
=
/^
\$
|Window$|WindowStyle$|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
;
/^
\$
|Window$|WindowStyle$|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64
|getLocale|setLocale
/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
...
...
@@ -394,6 +399,40 @@ function upx2px (number, newDeviceWidth) {
return
number
<
0
?
-
result
:
result
}
function
getLocale
()
{
// 优先使用 $locale
const
app
=
getApp
({
allowDefault
:
true
});
if
(
app
&&
app
.
$vm
)
{
return
app
.
$vm
.
$locale
}
return
swan
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
}
function
setLocale
(
locale
)
{
const
app
=
getApp
();
if
(
!
app
)
{
return
false
}
const
oldLocale
=
app
.
$vm
.
$locale
;
if
(
oldLocale
!==
locale
)
{
app
.
$vm
.
$locale
=
locale
;
onLocaleChangeCallbacks
.
forEach
((
fn
)
=>
fn
({
locale
}));
return
true
}
return
false
}
const
onLocaleChangeCallbacks
=
[];
function
onLocaleChange
(
fn
)
{
if
(
onLocaleChangeCallbacks
.
indexOf
(
fn
)
===
-
1
)
{
onLocaleChangeCallbacks
.
push
(
fn
);
}
}
const
interceptors
=
{
promiseInterceptor
};
...
...
@@ -401,6 +440,9 @@ const interceptors = {
var
baseApi
=
/*#__PURE__*/
Object
.
freeze
({
__proto__
:
null
,
upx2px
:
upx2px
,
getLocale
:
getLocale
,
setLocale
:
setLocale
,
onLocaleChange
:
onLocaleChange
,
addInterceptor
:
addInterceptor
,
removeInterceptor
:
removeInterceptor
,
interceptors
:
interceptors
...
...
@@ -1059,7 +1101,7 @@ function initTriggerEvent (mpInstance) {
};
}
function
initHook
(
name
,
options
)
{
function
initHook
(
name
,
options
,
isComponent
)
{
const
oldHook
=
options
[
name
];
if
(
!
oldHook
)
{
options
[
name
]
=
function
()
{
...
...
@@ -1655,6 +1697,51 @@ function handleEvent (event) {
}
}
let
locale
;
{
locale
=
swan
.
getSystemInfoSync
().
language
;
}
const
i18n
=
initVueI18n
(
locale
,
{});
const
t
=
i18n
.
t
;
const
i18nMixin
=
i18n
.
mixin
=
{
beforeCreate
()
{
const
unwatch
=
i18n
.
i18n
.
watchLocale
(()
=>
{
this
.
$forceUpdate
();
});
this
.
$once
(
'
hook:beforeDestroy
'
,
function
()
{
unwatch
();
});
},
methods
:
{
$$t
(
key
,
values
)
{
return
t
(
key
,
values
)
}
}
};
const
setLocale$1
=
i18n
.
setLocale
;
const
getLocale$1
=
i18n
.
getLocale
;
function
initAppLocale
(
Vue
,
appVm
,
locale
)
{
const
state
=
Vue
.
observable
({
locale
:
locale
||
i18n
.
getLocale
()
});
const
localeWatchers
=
[];
appVm
.
$watchLocale
=
(
fn
)
=>
{
localeWatchers
.
push
(
fn
);
};
Object
.
defineProperty
(
appVm
,
'
$locale
'
,
{
get
()
{
return
state
.
locale
},
set
(
v
)
{
state
.
locale
=
v
;
localeWatchers
.
forEach
(
watch
=>
watch
(
v
));
}
});
}
const
hooks
=
[
'
onShow
'
,
'
onHide
'
,
...
...
@@ -1811,6 +1898,8 @@ function parseBaseApp (vm, {
});
}
initAppLocale
(
Vue
,
vm
,
swan
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
);
initHooks
(
appOptions
,
hooks
);
return
appOptions
...
...
@@ -1962,6 +2051,44 @@ function stringifyQuery (obj, encodeStr = encode) {
return
res
?
`?
${
res
}
`
:
''
}
/**
* 用于延迟调用 setData
* 在 setData 真实调用的时机需执行 fixSetDataEnd
* @param {*} mpInstance
*/
function
fixSetDataStart
(
mpInstance
)
{
const
setData
=
mpInstance
.
setData
;
const
setDataArgs
=
[];
mpInstance
.
setData
=
function
()
{
setDataArgs
.
push
(
arguments
);
};
mpInstance
.
__fixInitData
=
function
()
{
this
.
setData
=
setData
;
const
fn
=
()
=>
{
setDataArgs
.
forEach
(
args
=>
{
setData
.
apply
(
this
,
args
);
});
};
if
(
setDataArgs
.
length
)
{
if
(
this
.
groupSetData
)
{
this
.
groupSetData
(
fn
);
}
else
{
fn
();
}
}
};
}
/**
* 恢复真实的 setData 方法
* @param {*} mpInstance
*/
function
fixSetDataEnd
(
mpInstance
)
{
if
(
mpInstance
.
__fixInitData
)
{
mpInstance
.
__fixInitData
();
delete
mpInstance
.
__fixInitData
;
}
}
function
parseBaseComponent
(
vueComponentOptions
,
{
isPage
,
initRelation
...
...
@@ -2075,22 +2202,7 @@ function parseComponent (vueOptions) {
}
// 处理百度小程序 onInit 生命周期调用 setData 无效的问题
const
setData
=
this
.
setData
;
const
setDataArgs
=
[];
this
.
setData
=
function
()
{
setDataArgs
.
push
(
arguments
);
};
this
.
__fixInitData
=
function
()
{
delete
this
.
__fixInitData
;
this
.
setData
=
setData
;
if
(
setDataArgs
.
length
)
{
this
.
groupSetData
(()
=>
{
setDataArgs
.
forEach
(
args
=>
{
setData
.
apply
(
this
,
args
);
});
});
}
};
fixSetDataStart
(
this
);
oldAttached
.
call
(
this
);
this
.
pageinstance
.
$vm
=
this
.
$vm
;
this
.
$vm
.
__call_hook
(
'
onInit
'
,
query
);
...
...
@@ -2100,7 +2212,7 @@ function parseComponent (vueOptions) {
oldAttached
.
call
(
this
);
}
else
{
initMocks
(
this
.
$vm
,
mocks
);
this
.
__fixInitData
&&
this
.
__fixInitData
(
);
fixSetDataEnd
(
this
);
}
if
(
isPage
.
call
(
this
))
{
// 百度 onLoad 在 attached 之前触发(基础库小于 3.70)
// 百度 当组件作为页面时 pageinstancce 不是原来组件的 instance
...
...
packages/uni-mp-kuaishou/dist/index.js
浏览文件 @
fd8d558f
import
Vue
from
'
vue
'
;
import
{
initVueI18n
}
from
'
@dcloudio/uni-i18n
'
;
function
b64DecodeUnicode
(
str
)
{
return
decodeURIComponent
(
atob
(
str
).
split
(
''
).
map
(
function
(
c
)
{
...
...
@@ -285,7 +286,7 @@ const promiseInterceptor = {
};
const
SYNC_API_RE
=
/^
\$
|Window$|WindowStyle$|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
;
/^
\$
|Window$|WindowStyle$|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64
|getLocale|setLocale
/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
...
...
@@ -398,6 +399,40 @@ function upx2px (number, newDeviceWidth) {
return
number
<
0
?
-
result
:
result
}
function
getLocale
()
{
// 优先使用 $locale
const
app
=
getApp
({
allowDefault
:
true
});
if
(
app
&&
app
.
$vm
)
{
return
app
.
$vm
.
$locale
}
return
ks
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
}
function
setLocale
(
locale
)
{
const
app
=
getApp
();
if
(
!
app
)
{
return
false
}
const
oldLocale
=
app
.
$vm
.
$locale
;
if
(
oldLocale
!==
locale
)
{
app
.
$vm
.
$locale
=
locale
;
onLocaleChangeCallbacks
.
forEach
((
fn
)
=>
fn
({
locale
}));
return
true
}
return
false
}
const
onLocaleChangeCallbacks
=
[];
function
onLocaleChange
(
fn
)
{
if
(
onLocaleChangeCallbacks
.
indexOf
(
fn
)
===
-
1
)
{
onLocaleChangeCallbacks
.
push
(
fn
);
}
}
const
interceptors
=
{
promiseInterceptor
};
...
...
@@ -405,6 +440,9 @@ const interceptors = {
var
baseApi
=
/*#__PURE__*/
Object
.
freeze
({
__proto__
:
null
,
upx2px
:
upx2px
,
getLocale
:
getLocale
,
setLocale
:
setLocale
,
onLocaleChange
:
onLocaleChange
,
addInterceptor
:
addInterceptor
,
removeInterceptor
:
removeInterceptor
,
interceptors
:
interceptors
...
...
@@ -838,7 +876,7 @@ function initTriggerEvent (mpInstance) {
};
}
function
initHook
(
name
,
options
)
{
function
initHook
(
name
,
options
,
isComponent
)
{
const
oldHook
=
options
[
name
];
if
(
!
oldHook
)
{
options
[
name
]
=
function
()
{
...
...
@@ -1408,6 +1446,51 @@ function handleEvent (event) {
}
}
let
locale
;
{
locale
=
ks
.
getSystemInfoSync
().
language
;
}
const
i18n
=
initVueI18n
(
locale
,
{});
const
t
=
i18n
.
t
;
const
i18nMixin
=
i18n
.
mixin
=
{
beforeCreate
()
{
const
unwatch
=
i18n
.
i18n
.
watchLocale
(()
=>
{
this
.
$forceUpdate
();
});
this
.
$once
(
'
hook:beforeDestroy
'
,
function
()
{
unwatch
();
});
},
methods
:
{
$$t
(
key
,
values
)
{
return
t
(
key
,
values
)
}
}
};
const
setLocale$1
=
i18n
.
setLocale
;
const
getLocale$1
=
i18n
.
getLocale
;
function
initAppLocale
(
Vue
,
appVm
,
locale
)
{
const
state
=
Vue
.
observable
({
locale
:
locale
||
i18n
.
getLocale
()
});
const
localeWatchers
=
[];
appVm
.
$watchLocale
=
(
fn
)
=>
{
localeWatchers
.
push
(
fn
);
};
Object
.
defineProperty
(
appVm
,
'
$locale
'
,
{
get
()
{
return
state
.
locale
},
set
(
v
)
{
state
.
locale
=
v
;
localeWatchers
.
forEach
(
watch
=>
watch
(
v
));
}
});
}
const
hooks
=
[
'
onShow
'
,
'
onHide
'
,
...
...
@@ -1564,6 +1647,8 @@ function parseBaseApp (vm, {
});
}
initAppLocale
(
Vue
,
vm
,
ks
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
);
initHooks
(
appOptions
,
hooks
);
return
appOptions
...
...
packages/uni-mp-qq/dist/index.js
浏览文件 @
fd8d558f
import
Vue
from
'
vue
'
;
import
{
initVueI18n
}
from
'
@dcloudio/uni-i18n
'
;
function
b64DecodeUnicode
(
str
)
{
return
decodeURIComponent
(
atob
(
str
).
split
(
''
).
map
(
function
(
c
)
{
...
...
@@ -192,7 +193,7 @@ function queue (hooks, data) {
}
if
(
res
===
false
)
{
return
{
then
()
{}
then
()
{
}
}
}
}
...
...
@@ -240,15 +241,15 @@ function getApiInterceptorHooks (method) {
if
(
hook
!==
'
returnValue
'
)
{
interceptor
[
hook
]
=
globalInterceptors
[
hook
].
slice
();
}
});
const
scopedInterceptor
=
scopedInterceptors
[
method
];
if
(
scopedInterceptor
)
{
Object
.
keys
(
scopedInterceptor
).
forEach
(
hook
=>
{
if
(
hook
!==
'
returnValue
'
)
{
interceptor
[
hook
]
=
(
interceptor
[
hook
]
||
[]).
concat
(
scopedInterceptor
[
hook
]);
}
});
}
});
const
scopedInterceptor
=
scopedInterceptors
[
method
];
if
(
scopedInterceptor
)
{
Object
.
keys
(
scopedInterceptor
).
forEach
(
hook
=>
{
if
(
hook
!==
'
returnValue
'
)
{
interceptor
[
hook
]
=
(
interceptor
[
hook
]
||
[]).
concat
(
scopedInterceptor
[
hook
]);
}
});
}
return
interceptor
}
...
...
@@ -272,16 +273,20 @@ const promiseInterceptor = {
if
(
!
isPromise
(
res
))
{
return
res
}
return
res
.
then
(
res
=>
{
return
res
[
1
]
}).
catch
(
res
=>
{
return
res
[
0
]
return
new
Promise
((
resolve
,
reject
)
=>
{
res
.
then
(
res
=>
{
if
(
res
[
0
])
{
reject
(
res
[
0
]);
}
else
{
resolve
(
res
[
1
]);
}
});
})
}
};
const
SYNC_API_RE
=
/^
\$
|Window$|WindowStyle$|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
;
/^
\$
|Window$|WindowStyle$|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64
|getLocale|setLocale
/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
...
...
@@ -394,6 +399,40 @@ function upx2px (number, newDeviceWidth) {
return
number
<
0
?
-
result
:
result
}
function
getLocale
()
{
// 优先使用 $locale
const
app
=
getApp
({
allowDefault
:
true
});
if
(
app
&&
app
.
$vm
)
{
return
app
.
$vm
.
$locale
}
return
wx
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
}
function
setLocale
(
locale
)
{
const
app
=
getApp
();
if
(
!
app
)
{
return
false
}
const
oldLocale
=
app
.
$vm
.
$locale
;
if
(
oldLocale
!==
locale
)
{
app
.
$vm
.
$locale
=
locale
;
onLocaleChangeCallbacks
.
forEach
((
fn
)
=>
fn
({
locale
}));
return
true
}
return
false
}
const
onLocaleChangeCallbacks
=
[];
function
onLocaleChange
(
fn
)
{
if
(
onLocaleChangeCallbacks
.
indexOf
(
fn
)
===
-
1
)
{
onLocaleChangeCallbacks
.
push
(
fn
);
}
}
const
interceptors
=
{
promiseInterceptor
};
...
...
@@ -401,6 +440,9 @@ const interceptors = {
var
baseApi
=
/*#__PURE__*/
Object
.
freeze
({
__proto__
:
null
,
upx2px
:
upx2px
,
getLocale
:
getLocale
,
setLocale
:
setLocale
,
onLocaleChange
:
onLocaleChange
,
addInterceptor
:
addInterceptor
,
removeInterceptor
:
removeInterceptor
,
interceptors
:
interceptors
...
...
@@ -995,7 +1037,7 @@ function initTriggerEvent (mpInstance) {
};
}
function
initHook
(
name
,
options
)
{
function
initHook
(
name
,
options
,
isComponent
)
{
const
oldHook
=
options
[
name
];
if
(
!
oldHook
)
{
options
[
name
]
=
function
()
{
...
...
@@ -1565,6 +1607,51 @@ function handleEvent (event) {
}
}
let
locale
;
{
locale
=
wx
.
getSystemInfoSync
().
language
;
}
const
i18n
=
initVueI18n
(
locale
,
{});
const
t
=
i18n
.
t
;
const
i18nMixin
=
i18n
.
mixin
=
{
beforeCreate
()
{
const
unwatch
=
i18n
.
i18n
.
watchLocale
(()
=>
{
this
.
$forceUpdate
();
});
this
.
$once
(
'
hook:beforeDestroy
'
,
function
()
{
unwatch
();
});
},
methods
:
{
$$t
(
key
,
values
)
{
return
t
(
key
,
values
)
}
}
};
const
setLocale$1
=
i18n
.
setLocale
;
const
getLocale$1
=
i18n
.
getLocale
;
function
initAppLocale
(
Vue
,
appVm
,
locale
)
{
const
state
=
Vue
.
observable
({
locale
:
locale
||
i18n
.
getLocale
()
});
const
localeWatchers
=
[];
appVm
.
$watchLocale
=
(
fn
)
=>
{
localeWatchers
.
push
(
fn
);
};
Object
.
defineProperty
(
appVm
,
'
$locale
'
,
{
get
()
{
return
state
.
locale
},
set
(
v
)
{
state
.
locale
=
v
;
localeWatchers
.
forEach
(
watch
=>
watch
(
v
));
}
});
}
const
hooks
=
[
'
onShow
'
,
'
onHide
'
,
...
...
@@ -1726,6 +1813,8 @@ function parseBaseApp (vm, {
});
}
initAppLocale
(
Vue
,
vm
,
wx
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
);
initHooks
(
appOptions
,
hooks
);
return
appOptions
...
...
packages/uni-mp-toutiao/dist/index.js
浏览文件 @
fd8d558f
import
Vue
from
'
vue
'
;
import
{
initVueI18n
}
from
'
@dcloudio/uni-i18n
'
;
function
b64DecodeUnicode
(
str
)
{
return
decodeURIComponent
(
atob
(
str
).
split
(
''
).
map
(
function
(
c
)
{
return
'
%
'
+
(
'
00
'
+
c
.
charCodeAt
(
0
).
toString
(
16
)).
slice
(
-
2
)
}).
join
(
''
))
}
function
getCurrentUserInfo
()
{
const
token
=
(
tt
).
getStorageSync
(
'
uni_id_token
'
)
||
''
;
const
tokenArr
=
token
.
split
(
'
.
'
);
if
(
!
token
||
tokenArr
.
length
!==
3
)
{
return
{
uid
:
null
,
role
:
[],
permission
:
[],
tokenExpired
:
0
}
}
let
userInfo
;
try
{
userInfo
=
JSON
.
parse
(
b64DecodeUnicode
(
tokenArr
[
1
]));
}
catch
(
error
)
{
throw
new
Error
(
'
获取当前用户信息出错,详细错误信息为:
'
+
error
.
message
)
}
userInfo
.
tokenExpired
=
userInfo
.
exp
*
1000
;
delete
userInfo
.
exp
;
delete
userInfo
.
iat
;
return
userInfo
}
function
uniIdMixin
(
Vue
)
{
Vue
.
prototype
.
uniIDHasRole
=
function
(
roleId
)
{
const
{
role
}
=
getCurrentUserInfo
();
return
role
.
indexOf
(
roleId
)
>
-
1
};
Vue
.
prototype
.
uniIDHasPermission
=
function
(
permissionId
)
{
const
{
permission
}
=
getCurrentUserInfo
();
return
this
.
uniIDHasRole
(
'
admin
'
)
||
permission
.
indexOf
(
permissionId
)
>
-
1
};
Vue
.
prototype
.
uniIDTokenValid
=
function
()
{
const
{
tokenExpired
}
=
getCurrentUserInfo
();
return
tokenExpired
>
Date
.
now
()
};
function
b64DecodeUnicode
(
str
)
{
return
decodeURIComponent
(
atob
(
str
).
split
(
''
).
map
(
function
(
c
)
{
return
'
%
'
+
(
'
00
'
+
c
.
charCodeAt
(
0
).
toString
(
16
)).
slice
(
-
2
)
}).
join
(
''
))
}
function
getCurrentUserInfo
()
{
const
token
=
(
tt
).
getStorageSync
(
'
uni_id_token
'
)
||
''
;
const
tokenArr
=
token
.
split
(
'
.
'
);
if
(
!
token
||
tokenArr
.
length
!==
3
)
{
return
{
uid
:
null
,
role
:
[],
permission
:
[],
tokenExpired
:
0
}
}
let
userInfo
;
try
{
userInfo
=
JSON
.
parse
(
b64DecodeUnicode
(
tokenArr
[
1
]));
}
catch
(
error
)
{
throw
new
Error
(
'
获取当前用户信息出错,详细错误信息为:
'
+
error
.
message
)
}
userInfo
.
tokenExpired
=
userInfo
.
exp
*
1000
;
delete
userInfo
.
exp
;
delete
userInfo
.
iat
;
return
userInfo
}
function
uniIdMixin
(
Vue
)
{
Vue
.
prototype
.
uniIDHasRole
=
function
(
roleId
)
{
const
{
role
}
=
getCurrentUserInfo
();
return
role
.
indexOf
(
roleId
)
>
-
1
};
Vue
.
prototype
.
uniIDHasPermission
=
function
(
permissionId
)
{
const
{
permission
}
=
getCurrentUserInfo
();
return
this
.
uniIDHasRole
(
'
admin
'
)
||
permission
.
indexOf
(
permissionId
)
>
-
1
};
Vue
.
prototype
.
uniIDTokenValid
=
function
()
{
const
{
tokenExpired
}
=
getCurrentUserInfo
();
return
tokenExpired
>
Date
.
now
()
};
}
const
_toString
=
Object
.
prototype
.
toString
;
...
...
@@ -398,6 +399,40 @@ function upx2px (number, newDeviceWidth) {
return
number
<
0
?
-
result
:
result
}
function
getLocale
()
{
// 优先使用 $locale
const
app
=
getApp
({
allowDefault
:
true
});
if
(
app
&&
app
.
$vm
)
{
return
app
.
$vm
.
$locale
}
return
tt
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
}
function
setLocale
(
locale
)
{
const
app
=
getApp
();
if
(
!
app
)
{
return
false
}
const
oldLocale
=
app
.
$vm
.
$locale
;
if
(
oldLocale
!==
locale
)
{
app
.
$vm
.
$locale
=
locale
;
onLocaleChangeCallbacks
.
forEach
((
fn
)
=>
fn
({
locale
}));
return
true
}
return
false
}
const
onLocaleChangeCallbacks
=
[];
function
onLocaleChange
(
fn
)
{
if
(
onLocaleChangeCallbacks
.
indexOf
(
fn
)
===
-
1
)
{
onLocaleChangeCallbacks
.
push
(
fn
);
}
}
const
interceptors
=
{
promiseInterceptor
};
...
...
@@ -405,6 +440,9 @@ const interceptors = {
var
baseApi
=
/*#__PURE__*/
Object
.
freeze
({
__proto__
:
null
,
upx2px
:
upx2px
,
getLocale
:
getLocale
,
setLocale
:
setLocale
,
onLocaleChange
:
onLocaleChange
,
addInterceptor
:
addInterceptor
,
removeInterceptor
:
removeInterceptor
,
interceptors
:
interceptors
...
...
@@ -581,44 +619,44 @@ var previewImage = {
}
};
const
UUID_KEY
=
'
__DC_STAT_UUID
'
;
let
deviceId
;
function
addUuid
(
result
)
{
deviceId
=
deviceId
||
tt
.
getStorageSync
(
UUID_KEY
);
if
(
!
deviceId
)
{
deviceId
=
Date
.
now
()
+
''
+
Math
.
floor
(
Math
.
random
()
*
1
e7
);
tt
.
setStorage
({
key
:
UUID_KEY
,
data
:
deviceId
});
}
result
.
deviceId
=
deviceId
;
}
function
addSafeAreaInsets
(
result
)
{
if
(
result
.
safeArea
)
{
const
safeArea
=
result
.
safeArea
;
result
.
safeAreaInsets
=
{
top
:
safeArea
.
top
,
left
:
safeArea
.
left
,
right
:
result
.
windowWidth
-
safeArea
.
right
,
bottom
:
result
.
windowHeight
-
safeArea
.
bottom
};
}
}
var
getSystemInfo
=
{
returnValue
:
function
(
result
)
{
addUuid
(
result
);
addSafeAreaInsets
(
result
);
}
const
UUID_KEY
=
'
__DC_STAT_UUID
'
;
let
deviceId
;
function
addUuid
(
result
)
{
deviceId
=
deviceId
||
tt
.
getStorageSync
(
UUID_KEY
);
if
(
!
deviceId
)
{
deviceId
=
Date
.
now
()
+
''
+
Math
.
floor
(
Math
.
random
()
*
1
e7
);
tt
.
setStorage
({
key
:
UUID_KEY
,
data
:
deviceId
});
}
result
.
deviceId
=
deviceId
;
}
function
addSafeAreaInsets
(
result
)
{
if
(
result
.
safeArea
)
{
const
safeArea
=
result
.
safeArea
;
result
.
safeAreaInsets
=
{
top
:
safeArea
.
top
,
left
:
safeArea
.
left
,
right
:
result
.
windowWidth
-
safeArea
.
right
,
bottom
:
result
.
windowHeight
-
safeArea
.
bottom
};
}
}
var
getSystemInfo
=
{
returnValue
:
function
(
result
)
{
addUuid
(
result
);
addSafeAreaInsets
(
result
);
}
};
const
oName
=
'
getUserInfo
'
;
const
nName
=
'
getUserProfile
'
;
var
getUserProfile
=
{
name
:
tt
.
canIUse
(
nName
)
?
nName
:
oName
const
oName
=
'
getUserInfo
'
;
const
nName
=
'
getUserProfile
'
;
var
getUserProfile
=
{
name
:
tt
.
canIUse
(
nName
)
?
nName
:
oName
};
// 不支持的 API 列表
...
...
@@ -978,96 +1016,96 @@ var eventApi = /*#__PURE__*/Object.freeze({
$emit
:
$emit
});
function
createMediaQueryObserver
()
{
const
mediaQueryObserver
=
{};
const
{
windowWidth
,
windowHeight
}
=
tt
.
getSystemInfoSync
();
const
orientation
=
windowWidth
<
windowHeight
?
'
portrait
'
:
'
landscape
'
;
mediaQueryObserver
.
observe
=
(
options
,
callback
)
=>
{
let
matches
=
true
;
for
(
const
item
in
options
)
{
const
itemValue
=
item
===
'
orientation
'
?
options
[
item
]
:
Number
(
options
[
item
]);
if
(
options
[
item
]
!==
''
)
{
if
(
item
===
'
width
'
)
{
if
(
itemValue
===
windowWidth
)
{
matches
=
true
;
}
else
{
matches
=
false
;
callback
(
matches
);
return
matches
}
}
if
(
item
===
'
minWidth
'
)
{
if
(
windowWidth
>=
itemValue
)
{
matches
=
true
;
}
else
{
matches
=
false
;
callback
(
matches
);
return
matches
}
}
if
(
item
===
'
maxWidth
'
)
{
if
(
windowWidth
<=
itemValue
)
{
matches
=
true
;
}
else
{
matches
=
false
;
callback
(
matches
);
return
matches
}
}
if
(
item
===
'
height
'
)
{
if
(
itemValue
===
windowHeight
)
{
matches
=
true
;
}
else
{
matches
=
false
;
callback
(
matches
);
return
matches
}
}
if
(
item
===
'
minHeight
'
)
{
if
(
windowHeight
>=
itemValue
)
{
matches
=
true
;
}
else
{
matches
=
false
;
callback
(
matches
);
return
matches
}
}
if
(
item
===
'
maxHeight
'
)
{
if
(
windowHeight
<=
itemValue
)
{
matches
=
true
;
}
else
{
matches
=
false
;
callback
(
matches
);
return
matches
}
}
if
(
item
===
'
orientation
'
)
{
if
(
options
[
item
]
===
orientation
)
{
matches
=
true
;
}
else
{
matches
=
false
;
callback
(
matches
);
return
matches
}
}
}
}
callback
(
matches
);
return
matches
};
mediaQueryObserver
.
disconnect
=
()
=>
{
};
return
mediaQueryObserver
function
createMediaQueryObserver
()
{
const
mediaQueryObserver
=
{};
const
{
windowWidth
,
windowHeight
}
=
tt
.
getSystemInfoSync
();
const
orientation
=
windowWidth
<
windowHeight
?
'
portrait
'
:
'
landscape
'
;
mediaQueryObserver
.
observe
=
(
options
,
callback
)
=>
{
let
matches
=
true
;
for
(
const
item
in
options
)
{
const
itemValue
=
item
===
'
orientation
'
?
options
[
item
]
:
Number
(
options
[
item
]);
if
(
options
[
item
]
!==
''
)
{
if
(
item
===
'
width
'
)
{
if
(
itemValue
===
windowWidth
)
{
matches
=
true
;
}
else
{
matches
=
false
;
callback
(
matches
);
return
matches
}
}
if
(
item
===
'
minWidth
'
)
{
if
(
windowWidth
>=
itemValue
)
{
matches
=
true
;
}
else
{
matches
=
false
;
callback
(
matches
);
return
matches
}
}
if
(
item
===
'
maxWidth
'
)
{
if
(
windowWidth
<=
itemValue
)
{
matches
=
true
;
}
else
{
matches
=
false
;
callback
(
matches
);
return
matches
}
}
if
(
item
===
'
height
'
)
{
if
(
itemValue
===
windowHeight
)
{
matches
=
true
;
}
else
{
matches
=
false
;
callback
(
matches
);
return
matches
}
}
if
(
item
===
'
minHeight
'
)
{
if
(
windowHeight
>=
itemValue
)
{
matches
=
true
;
}
else
{
matches
=
false
;
callback
(
matches
);
return
matches
}
}
if
(
item
===
'
maxHeight
'
)
{
if
(
windowHeight
<=
itemValue
)
{
matches
=
true
;
}
else
{
matches
=
false
;
callback
(
matches
);
return
matches
}
}
if
(
item
===
'
orientation
'
)
{
if
(
options
[
item
]
===
orientation
)
{
matches
=
true
;
}
else
{
matches
=
false
;
callback
(
matches
);
return
matches
}
}
}
}
callback
(
matches
);
return
matches
};
mediaQueryObserver
.
disconnect
=
()
=>
{
};
return
mediaQueryObserver
}
var
api
=
/*#__PURE__*/
Object
.
freeze
({
...
...
@@ -1665,6 +1703,51 @@ function handleEvent (event) {
}
}
let
locale
;
{
locale
=
tt
.
getSystemInfoSync
().
language
;
}
const
i18n
=
initVueI18n
(
locale
,
{});
const
t
=
i18n
.
t
;
const
i18nMixin
=
i18n
.
mixin
=
{
beforeCreate
()
{
const
unwatch
=
i18n
.
i18n
.
watchLocale
(()
=>
{
this
.
$forceUpdate
();
});
this
.
$once
(
'
hook:beforeDestroy
'
,
function
()
{
unwatch
();
});
},
methods
:
{
$$t
(
key
,
values
)
{
return
t
(
key
,
values
)
}
}
};
const
setLocale$1
=
i18n
.
setLocale
;
const
getLocale$1
=
i18n
.
getLocale
;
function
initAppLocale
(
Vue
,
appVm
,
locale
)
{
const
state
=
Vue
.
observable
({
locale
:
locale
||
i18n
.
getLocale
()
});
const
localeWatchers
=
[];
appVm
.
$watchLocale
=
(
fn
)
=>
{
localeWatchers
.
push
(
fn
);
};
Object
.
defineProperty
(
appVm
,
'
$locale
'
,
{
get
()
{
return
state
.
locale
},
set
(
v
)
{
state
.
locale
=
v
;
localeWatchers
.
forEach
(
watch
=>
watch
(
v
));
}
});
}
const
hooks
=
[
'
onShow
'
,
'
onHide
'
,
...
...
@@ -1821,6 +1904,8 @@ function parseBaseApp (vm, {
});
}
initAppLocale
(
Vue
,
vm
,
tt
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
);
initHooks
(
appOptions
,
hooks
);
return
appOptions
...
...
@@ -2301,23 +2386,23 @@ function createSubpackageApp (vm) {
return
vm
}
function
createPlugin
(
vm
)
{
const
appOptions
=
parseApp
(
vm
);
if
(
isFn
(
appOptions
.
onShow
)
&&
tt
.
onAppShow
)
{
tt
.
onAppShow
((...
args
)
=>
{
appOptions
.
onShow
.
apply
(
vm
,
args
);
});
}
if
(
isFn
(
appOptions
.
onHide
)
&&
tt
.
onAppHide
)
{
tt
.
onAppHide
((...
args
)
=>
{
appOptions
.
onHide
.
apply
(
vm
,
args
);
});
}
if
(
isFn
(
appOptions
.
onLaunch
))
{
const
args
=
tt
.
getLaunchOptionsSync
&&
tt
.
getLaunchOptionsSync
();
appOptions
.
onLaunch
.
call
(
vm
,
args
);
}
return
vm
function
createPlugin
(
vm
)
{
const
appOptions
=
parseApp
(
vm
);
if
(
isFn
(
appOptions
.
onShow
)
&&
tt
.
onAppShow
)
{
tt
.
onAppShow
((...
args
)
=>
{
appOptions
.
onShow
.
apply
(
vm
,
args
);
});
}
if
(
isFn
(
appOptions
.
onHide
)
&&
tt
.
onAppHide
)
{
tt
.
onAppHide
((...
args
)
=>
{
appOptions
.
onHide
.
apply
(
vm
,
args
);
});
}
if
(
isFn
(
appOptions
.
onLaunch
))
{
const
args
=
tt
.
getLaunchOptionsSync
&&
tt
.
getLaunchOptionsSync
();
appOptions
.
onLaunch
.
call
(
vm
,
args
);
}
return
vm
}
todos
.
forEach
(
todoApi
=>
{
...
...
packages/uni-mp-weixin/dist/index.js
浏览文件 @
fd8d558f
import
Vue
from
'
vue
'
;
import
{
initVueI18n
}
from
'
@dcloudio/uni-i18n
'
;
function
b64DecodeUnicode
(
str
)
{
return
decodeURIComponent
(
atob
(
str
).
split
(
''
).
map
(
function
(
c
)
{
...
...
@@ -192,7 +193,7 @@ function queue (hooks, data) {
}
if
(
res
===
false
)
{
return
{
then
()
{}
then
()
{
}
}
}
}
...
...
@@ -240,15 +241,15 @@ function getApiInterceptorHooks (method) {
if
(
hook
!==
'
returnValue
'
)
{
interceptor
[
hook
]
=
globalInterceptors
[
hook
].
slice
();
}
});
const
scopedInterceptor
=
scopedInterceptors
[
method
];
if
(
scopedInterceptor
)
{
Object
.
keys
(
scopedInterceptor
).
forEach
(
hook
=>
{
if
(
hook
!==
'
returnValue
'
)
{
interceptor
[
hook
]
=
(
interceptor
[
hook
]
||
[]).
concat
(
scopedInterceptor
[
hook
]);
}
});
}
});
const
scopedInterceptor
=
scopedInterceptors
[
method
];
if
(
scopedInterceptor
)
{
Object
.
keys
(
scopedInterceptor
).
forEach
(
hook
=>
{
if
(
hook
!==
'
returnValue
'
)
{
interceptor
[
hook
]
=
(
interceptor
[
hook
]
||
[]).
concat
(
scopedInterceptor
[
hook
]);
}
});
}
return
interceptor
}
...
...
@@ -272,16 +273,20 @@ const promiseInterceptor = {
if
(
!
isPromise
(
res
))
{
return
res
}
return
res
.
then
(
res
=>
{
return
res
[
1
]
}).
catch
(
res
=>
{
return
res
[
0
]
return
new
Promise
((
resolve
,
reject
)
=>
{
res
.
then
(
res
=>
{
if
(
res
[
0
])
{
reject
(
res
[
0
]);
}
else
{
resolve
(
res
[
1
]);
}
});
})
}
};
const
SYNC_API_RE
=
/^
\$
|Window$|WindowStyle$|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
;
/^
\$
|Window$|WindowStyle$|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64
|getLocale|setLocale
/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
...
...
@@ -394,6 +399,40 @@ function upx2px (number, newDeviceWidth) {
return
number
<
0
?
-
result
:
result
}
function
getLocale
()
{
// 优先使用 $locale
const
app
=
getApp
({
allowDefault
:
true
});
if
(
app
&&
app
.
$vm
)
{
return
app
.
$vm
.
$locale
}
return
wx
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
}
function
setLocale
(
locale
)
{
const
app
=
getApp
();
if
(
!
app
)
{
return
false
}
const
oldLocale
=
app
.
$vm
.
$locale
;
if
(
oldLocale
!==
locale
)
{
app
.
$vm
.
$locale
=
locale
;
onLocaleChangeCallbacks
.
forEach
((
fn
)
=>
fn
({
locale
}));
return
true
}
return
false
}
const
onLocaleChangeCallbacks
=
[];
function
onLocaleChange
(
fn
)
{
if
(
onLocaleChangeCallbacks
.
indexOf
(
fn
)
===
-
1
)
{
onLocaleChangeCallbacks
.
push
(
fn
);
}
}
const
interceptors
=
{
promiseInterceptor
};
...
...
@@ -401,6 +440,9 @@ const interceptors = {
var
baseApi
=
/*#__PURE__*/
Object
.
freeze
({
__proto__
:
null
,
upx2px
:
upx2px
,
getLocale
:
getLocale
,
setLocale
:
setLocale
,
onLocaleChange
:
onLocaleChange
,
addInterceptor
:
addInterceptor
,
removeInterceptor
:
removeInterceptor
,
interceptors
:
interceptors
...
...
@@ -731,7 +773,7 @@ function initTriggerEvent (mpInstance) {
};
}
function
initHook
(
name
,
options
)
{
function
initHook
(
name
,
options
,
isComponent
)
{
const
oldHook
=
options
[
name
];
if
(
!
oldHook
)
{
options
[
name
]
=
function
()
{
...
...
@@ -1301,6 +1343,51 @@ function handleEvent (event) {
}
}
let
locale
;
{
locale
=
wx
.
getSystemInfoSync
().
language
;
}
const
i18n
=
initVueI18n
(
locale
,
{});
const
t
=
i18n
.
t
;
const
i18nMixin
=
i18n
.
mixin
=
{
beforeCreate
()
{
const
unwatch
=
i18n
.
i18n
.
watchLocale
(()
=>
{
this
.
$forceUpdate
();
});
this
.
$once
(
'
hook:beforeDestroy
'
,
function
()
{
unwatch
();
});
},
methods
:
{
$$t
(
key
,
values
)
{
return
t
(
key
,
values
)
}
}
};
const
setLocale$1
=
i18n
.
setLocale
;
const
getLocale$1
=
i18n
.
getLocale
;
function
initAppLocale
(
Vue
,
appVm
,
locale
)
{
const
state
=
Vue
.
observable
({
locale
:
locale
||
i18n
.
getLocale
()
});
const
localeWatchers
=
[];
appVm
.
$watchLocale
=
(
fn
)
=>
{
localeWatchers
.
push
(
fn
);
};
Object
.
defineProperty
(
appVm
,
'
$locale
'
,
{
get
()
{
return
state
.
locale
},
set
(
v
)
{
state
.
locale
=
v
;
localeWatchers
.
forEach
(
watch
=>
watch
(
v
));
}
});
}
const
eventChannels
=
{};
const
eventChannelStack
=
[];
...
...
@@ -1475,6 +1562,8 @@ function parseBaseApp (vm, {
});
}
initAppLocale
(
Vue
,
vm
,
wx
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
);
initHooks
(
appOptions
,
hooks
);
return
appOptions
...
...
packages/uni-quickapp-native/dist/vue.dev.js
浏览文件 @
fd8d558f
此差异已折叠。
点击以展开。
packages/uni-quickapp-native/dist/vue.prod.js
浏览文件 @
fd8d558f
此差异已折叠。
点击以展开。
packages/uni-quickapp-webview/dist/index.js
浏览文件 @
fd8d558f
import
Vue
from
'
vue
'
;
import
{
initVueI18n
}
from
'
@dcloudio/uni-i18n
'
;
function
b64DecodeUnicode
(
str
)
{
return
decodeURIComponent
(
atob
(
str
).
split
(
''
).
map
(
function
(
c
)
{
...
...
@@ -192,7 +193,7 @@ function queue (hooks, data) {
}
if
(
res
===
false
)
{
return
{
then
()
{}
then
()
{
}
}
}
}
...
...
@@ -240,15 +241,15 @@ function getApiInterceptorHooks (method) {
if
(
hook
!==
'
returnValue
'
)
{
interceptor
[
hook
]
=
globalInterceptors
[
hook
].
slice
();
}
});
const
scopedInterceptor
=
scopedInterceptors
[
method
];
if
(
scopedInterceptor
)
{
Object
.
keys
(
scopedInterceptor
).
forEach
(
hook
=>
{
if
(
hook
!==
'
returnValue
'
)
{
interceptor
[
hook
]
=
(
interceptor
[
hook
]
||
[]).
concat
(
scopedInterceptor
[
hook
]);
}
});
}
});
const
scopedInterceptor
=
scopedInterceptors
[
method
];
if
(
scopedInterceptor
)
{
Object
.
keys
(
scopedInterceptor
).
forEach
(
hook
=>
{
if
(
hook
!==
'
returnValue
'
)
{
interceptor
[
hook
]
=
(
interceptor
[
hook
]
||
[]).
concat
(
scopedInterceptor
[
hook
]);
}
});
}
return
interceptor
}
...
...
@@ -272,16 +273,20 @@ const promiseInterceptor = {
if
(
!
isPromise
(
res
))
{
return
res
}
return
res
.
then
(
res
=>
{
return
res
[
1
]
}).
catch
(
res
=>
{
return
res
[
0
]
return
new
Promise
((
resolve
,
reject
)
=>
{
res
.
then
(
res
=>
{
if
(
res
[
0
])
{
reject
(
res
[
0
]);
}
else
{
resolve
(
res
[
1
]);
}
});
})
}
};
const
SYNC_API_RE
=
/^
\$
|Window$|WindowStyle$|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
;
/^
\$
|Window$|WindowStyle$|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64
|getLocale|setLocale
/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
...
...
@@ -394,6 +399,40 @@ function upx2px (number, newDeviceWidth) {
return
number
<
0
?
-
result
:
result
}
function
getLocale
()
{
// 优先使用 $locale
const
app
=
getApp
({
allowDefault
:
true
});
if
(
app
&&
app
.
$vm
)
{
return
app
.
$vm
.
$locale
}
return
qa
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
}
function
setLocale
(
locale
)
{
const
app
=
getApp
();
if
(
!
app
)
{
return
false
}
const
oldLocale
=
app
.
$vm
.
$locale
;
if
(
oldLocale
!==
locale
)
{
app
.
$vm
.
$locale
=
locale
;
onLocaleChangeCallbacks
.
forEach
((
fn
)
=>
fn
({
locale
}));
return
true
}
return
false
}
const
onLocaleChangeCallbacks
=
[];
function
onLocaleChange
(
fn
)
{
if
(
onLocaleChangeCallbacks
.
indexOf
(
fn
)
===
-
1
)
{
onLocaleChangeCallbacks
.
push
(
fn
);
}
}
const
interceptors
=
{
promiseInterceptor
};
...
...
@@ -401,6 +440,9 @@ const interceptors = {
var
baseApi
=
/*#__PURE__*/
Object
.
freeze
({
__proto__
:
null
,
upx2px
:
upx2px
,
getLocale
:
getLocale
,
setLocale
:
setLocale
,
onLocaleChange
:
onLocaleChange
,
addInterceptor
:
addInterceptor
,
removeInterceptor
:
removeInterceptor
,
interceptors
:
interceptors
...
...
@@ -801,7 +843,7 @@ function initTriggerEvent (mpInstance) {
};
}
function
initHook
(
name
,
options
)
{
function
initHook
(
name
,
options
,
isComponent
)
{
const
oldHook
=
options
[
name
];
if
(
!
oldHook
)
{
options
[
name
]
=
function
()
{
...
...
@@ -1371,6 +1413,51 @@ function handleEvent (event) {
}
}
let
locale
;
{
locale
=
qa
.
getSystemInfoSync
().
language
;
}
const
i18n
=
initVueI18n
(
locale
,
{});
const
t
=
i18n
.
t
;
const
i18nMixin
=
i18n
.
mixin
=
{
beforeCreate
()
{
const
unwatch
=
i18n
.
i18n
.
watchLocale
(()
=>
{
this
.
$forceUpdate
();
});
this
.
$once
(
'
hook:beforeDestroy
'
,
function
()
{
unwatch
();
});
},
methods
:
{
$$t
(
key
,
values
)
{
return
t
(
key
,
values
)
}
}
};
const
setLocale$1
=
i18n
.
setLocale
;
const
getLocale$1
=
i18n
.
getLocale
;
function
initAppLocale
(
Vue
,
appVm
,
locale
)
{
const
state
=
Vue
.
observable
({
locale
:
locale
||
i18n
.
getLocale
()
});
const
localeWatchers
=
[];
appVm
.
$watchLocale
=
(
fn
)
=>
{
localeWatchers
.
push
(
fn
);
};
Object
.
defineProperty
(
appVm
,
'
$locale
'
,
{
get
()
{
return
state
.
locale
},
set
(
v
)
{
state
.
locale
=
v
;
localeWatchers
.
forEach
(
watch
=>
watch
(
v
));
}
});
}
const
hooks
=
[
'
onShow
'
,
'
onHide
'
,
...
...
@@ -1472,6 +1559,8 @@ function parseBaseApp (vm, {
});
}
initAppLocale
(
Vue
,
vm
,
qa
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
);
initHooks
(
appOptions
,
hooks
);
return
appOptions
...
...
src/core/helpers/i18n/index.js
浏览文件 @
fd8d558f
...
...
@@ -25,7 +25,7 @@ if (__PLATFORM__ === 'h5') {
locale
=
weex
.
requireModule
(
'
plus
'
).
getLanguage
()
}
}
else
{
locale
=
uni
.
getSystemInfoSync
().
language
locale
=
__GLOBAL__
.
getSystemInfoSync
().
language
}
export
const
i18n
=
initVueI18n
(
locale
,
__PLATFORM__
===
'
app-plus
'
||
__PLATFORM__
===
'
h5
'
?
messages
:
{})
...
...
@@ -48,9 +48,9 @@ export const i18nMixin = i18n.mixin = {
export
const
setLocale
=
i18n
.
setLocale
export
const
getLocale
=
i18n
.
getLocale
export
function
initAppLocale
(
Vue
,
appVm
)
{
export
function
initAppLocale
(
Vue
,
appVm
,
locale
)
{
const
state
=
Vue
.
observable
({
locale
:
i18n
.
getLocale
()
locale
:
locale
||
i18n
.
getLocale
()
})
const
localeWatchers
=
[]
appVm
.
$watchLocale
=
(
fn
)
=>
{
...
...
src/core/runtime/base.js
浏览文件 @
fd8d558f
...
...
@@ -3,4 +3,6 @@ export {
}
from
'
./upx2px
'
export
*
from
'
./locale
'
export
*
from
'
../service/api/base/interceptor
'
src/core/runtime/locale.js
0 → 100644
浏览文件 @
fd8d558f
export
function
getLocale
()
{
// 优先使用 $locale
const
app
=
getApp
({
allowDefault
:
true
})
if
(
app
&&
app
.
$vm
)
{
return
app
.
$vm
.
$locale
}
return
__GLOBAL__
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
}
export
function
setLocale
(
locale
)
{
const
app
=
getApp
()
if
(
!
app
)
{
return
false
}
const
oldLocale
=
app
.
$vm
.
$locale
if
(
oldLocale
!==
locale
)
{
app
.
$vm
.
$locale
=
locale
onLocaleChangeCallbacks
.
forEach
((
fn
)
=>
fn
({
locale
}))
return
true
}
return
false
}
const
onLocaleChangeCallbacks
=
[]
export
function
onLocaleChange
(
fn
)
{
if
(
onLocaleChangeCallbacks
.
indexOf
(
fn
)
===
-
1
)
{
onLocaleChangeCallbacks
.
push
(
fn
)
}
}
src/platforms/mp-weixin/runtime/wrapper/app-base-parser.js
浏览文件 @
fd8d558f
...
...
@@ -5,6 +5,10 @@ import {
initMocks
}
from
'
uni-wrapper/util
'
import
{
initAppLocale
}
from
'
uni-helpers/i18n/index
'
import
EventChannel
from
'
uni-helpers/EventChannel
'
import
{
...
...
@@ -102,7 +106,8 @@ export default function parseBaseApp (vm, {
initRefs
})
{
initEventChannel
()
if
(
__PLATFORM__
===
'
mp-weixin
'
||
__PLATFORM__
===
'
mp-qq
'
||
__PLATFORM__
===
'
mp-toutiao
'
||
__PLATFORM__
===
'
mp-kuaishou
'
||
__PLATFORM__
===
'
mp-alipay
'
||
__PLATFORM__
===
'
mp-baidu
'
)
{
if
(
__PLATFORM__
===
'
mp-weixin
'
||
__PLATFORM__
===
'
mp-qq
'
||
__PLATFORM__
===
'
mp-toutiao
'
||
__PLATFORM__
===
'
mp-kuaishou
'
||
__PLATFORM__
===
'
mp-alipay
'
||
__PLATFORM__
===
'
mp-baidu
'
)
{
initScopedSlotsParams
()
}
if
(
vm
.
$options
.
store
)
{
...
...
@@ -180,7 +185,9 @@ export default function parseBaseApp (vm, {
})
}
initAppLocale
(
Vue
,
vm
,
__GLOBAL__
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
)
initHooks
(
appOptions
,
hooks
)
return
appOptions
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录