Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
m0_68066342
uni-app
提交
a17ee303
U
uni-app
项目概览
m0_68066342
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a17ee303
编写于
12月 28, 2021
作者:
Q
qiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore: build
上级
d62c78ca
变更
14
展开全部
隐藏空白更改
内联
并排
Showing
14 changed file
with
988 addition
and
695 deletion
+988
-695
packages/uni-app-plus/dist/index.js
packages/uni-app-plus/dist/index.js
+61
-18
packages/uni-app-plus/dist/view.umd.min.js
packages/uni-app-plus/dist/view.umd.min.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
+47
-15
packages/uni-mp-baidu/dist/index.js
packages/uni-mp-baidu/dist/index.js
+49
-8
packages/uni-mp-jd/dist/index.js
packages/uni-mp-jd/dist/index.js
+216
-317
packages/uni-mp-kuaishou/dist/index.js
packages/uni-mp-kuaishou/dist/index.js
+49
-8
packages/uni-mp-lark/dist/index.js
packages/uni-mp-lark/dist/index.js
+82
-9
packages/uni-mp-qq/dist/index.js
packages/uni-mp-qq/dist/index.js
+49
-8
packages/uni-mp-toutiao/dist/index.js
packages/uni-mp-toutiao/dist/index.js
+49
-8
packages/uni-mp-weixin/dist/index.js
packages/uni-mp-weixin/dist/index.js
+334
-293
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
+47
-6
未找到文件。
packages/uni-app-plus/dist/index.js
浏览文件 @
a17ee303
...
...
@@ -314,7 +314,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|getLocale|setLocale/
;
/^
\$
|Window$|WindowStyle$|send
HostEvent|send
NativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64|getLocale|setLocale/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
...
...
@@ -725,15 +725,16 @@ const customize = cached((str) => {
});
function
initTriggerEvent
(
mpInstance
)
{
{
if
(
!
wx
.
canIUse
||
!
wx
.
canIUse
(
'
nextTick
'
))
{
return
}
}
const
oldTriggerEvent
=
mpInstance
.
triggerEvent
;
mpInstance
.
t
riggerEvent
=
function
(
event
,
...
args
)
{
const
newT
riggerEvent
=
function
(
event
,
...
args
)
{
return
oldTriggerEvent
.
apply
(
mpInstance
,
[
customize
(
event
),
...
args
])
};
try
{
// 京东小程序 triggerEvent 为只读
mpInstance
.
triggerEvent
=
newTriggerEvent
;
}
catch
(
error
)
{
mpInstance
.
_triggerEvent
=
newTriggerEvent
;
}
}
function
initHook
(
name
,
options
,
isComponent
)
{
...
...
@@ -1320,6 +1321,7 @@ var en = {
"
uni.chooseVideo.cancel
"
:
"
Cancel
"
,
"
uni.chooseVideo.sourceType.album
"
:
"
Album
"
,
"
uni.chooseVideo.sourceType.camera
"
:
"
Camera
"
,
"
uni.chooseFile.notUserActivation
"
:
"
File chooser dialog can only be shown with a user activation
"
,
"
uni.previewImage.cancel
"
:
"
Cancel
"
,
"
uni.previewImage.button.save
"
:
"
Save Image
"
,
"
uni.previewImage.save.success
"
:
"
Saved successfully
"
,
...
...
@@ -1355,6 +1357,7 @@ var es = {
"
uni.chooseVideo.cancel
"
:
"
Cancelar
"
,
"
uni.chooseVideo.sourceType.album
"
:
"
Álbum
"
,
"
uni.chooseVideo.sourceType.camera
"
:
"
Cámara
"
,
"
uni.chooseFile.notUserActivation
"
:
"
El cuadro de diálogo del selector de archivos solo se puede mostrar con la activación del usuario
"
,
"
uni.previewImage.cancel
"
:
"
Cancelar
"
,
"
uni.previewImage.button.save
"
:
"
Guardar imagen
"
,
"
uni.previewImage.save.success
"
:
"
Guardado exitosamente
"
,
...
...
@@ -1390,6 +1393,7 @@ var fr = {
"
uni.chooseVideo.cancel
"
:
"
Annuler
"
,
"
uni.chooseVideo.sourceType.album
"
:
"
Album
"
,
"
uni.chooseVideo.sourceType.camera
"
:
"
Caméra
"
,
"
uni.chooseFile.notUserActivation
"
:
"
La boîte de dialogue du sélecteur de fichier ne peut être affichée qu'avec une activation par l'utilisateur
"
,
"
uni.previewImage.cancel
"
:
"
Annuler
"
,
"
uni.previewImage.button.save
"
:
"
Guardar imagen
"
,
"
uni.previewImage.save.success
"
:
"
Enregistré avec succès
"
,
...
...
@@ -1425,6 +1429,7 @@ var zhHans = {
"
uni.chooseVideo.cancel
"
:
"
取消
"
,
"
uni.chooseVideo.sourceType.album
"
:
"
从相册选择
"
,
"
uni.chooseVideo.sourceType.camera
"
:
"
拍摄
"
,
"
uni.chooseFile.notUserActivation
"
:
"
文件选择器对话框只能在由用户激活时显示
"
,
"
uni.previewImage.cancel
"
:
"
取消
"
,
"
uni.previewImage.button.save
"
:
"
保存图像
"
,
"
uni.previewImage.save.success
"
:
"
保存图像到相册成功
"
,
...
...
@@ -1460,6 +1465,7 @@ var zhHant = {
"
uni.chooseVideo.cancel
"
:
"
取消
"
,
"
uni.chooseVideo.sourceType.album
"
:
"
從相冊選擇
"
,
"
uni.chooseVideo.sourceType.camera
"
:
"
拍攝
"
,
"
uni.chooseFile.notUserActivation
"
:
"
文件選擇器對話框只能在由用戶激活時顯示
"
,
"
uni.previewImage.cancel
"
:
"
取消
"
,
"
uni.previewImage.button.save
"
:
"
保存圖像
"
,
"
uni.previewImage.save.success
"
:
"
保存圖像到相冊成功
"
,
...
...
@@ -1481,13 +1487,17 @@ var zhHant = {
"
uni.chooseLocation.cancel
"
:
"
取消
"
};
const
messages
=
{
en
,
es
,
fr
,
'
zh-Hans
'
:
zhHans
,
'
zh-Hant
'
:
zhHant
};
const
messages
=
{};
{
Object
.
assign
(
messages
,
{
en
,
es
,
fr
,
'
zh-Hans
'
:
zhHans
,
'
zh-Hant
'
:
zhHant
});
}
let
locale
;
...
...
@@ -1499,6 +1509,26 @@ let locale;
}
}
function
initI18nMessages
()
{
if
(
!
isEnableLocale
())
{
return
}
const
localeKeys
=
Object
.
keys
(
__uniConfig
.
locales
);
if
(
localeKeys
.
length
)
{
localeKeys
.
forEach
((
locale
)
=>
{
const
curMessages
=
messages
[
locale
];
const
userMessages
=
__uniConfig
.
locales
[
locale
];
if
(
curMessages
)
{
Object
.
assign
(
curMessages
,
userMessages
);
}
else
{
messages
[
locale
]
=
userMessages
;
}
});
}
}
initI18nMessages
();
const
i18n
=
initVueI18n
(
locale
,
messages
...
...
@@ -1539,7 +1569,20 @@ function initAppLocale (Vue, appVm, locale) {
localeWatchers
.
forEach
(
watch
=>
watch
(
v
));
}
});
}
}
function
isEnableLocale
()
{
return
typeof
__uniConfig
!==
'
undefined
'
&&
__uniConfig
.
locales
&&
!!
Object
.
keys
(
__uniConfig
.
locales
).
length
}
// export function initI18n() {
// const localeKeys = Object.keys(__uniConfig.locales || {})
// if (localeKeys.length) {
// localeKeys.forEach((locale) =>
// i18n.add(locale, __uniConfig.locales[locale])
// )
// }
// }
class
EventChannel
{
constructor
(
id
,
events
)
{
...
...
@@ -2091,17 +2134,17 @@ function createPlugin (vm) {
const
appOptions
=
parseApp$1
(
vm
);
if
(
isFn
(
appOptions
.
onShow
)
&&
wx
.
onAppShow
)
{
wx
.
onAppShow
((...
args
)
=>
{
appOptions
.
onShow
.
apply
(
vm
,
args
);
vm
.
__call_hook
(
'
onShow
'
,
args
);
});
}
if
(
isFn
(
appOptions
.
onHide
)
&&
wx
.
onAppHide
)
{
wx
.
onAppHide
((...
args
)
=>
{
appOptions
.
onHide
.
apply
(
vm
,
args
);
vm
.
__call_hook
(
'
onHide
'
,
args
);
});
}
if
(
isFn
(
appOptions
.
onLaunch
))
{
const
args
=
wx
.
getLaunchOptionsSync
&&
wx
.
getLaunchOptionsSync
();
appOptions
.
onLaunch
.
call
(
vm
,
args
);
vm
.
__call_hook
(
'
onLaunch
'
,
args
);
}
return
vm
}
...
...
packages/uni-app-plus/dist/view.umd.min.js
浏览文件 @
a17ee303
此差异已折叠。
点击以展开。
packages/uni-h5/dist/index.umd.min.js
浏览文件 @
a17ee303
此差异已折叠。
点击以展开。
packages/uni-mp-alipay/dist/index.js
浏览文件 @
a17ee303
...
...
@@ -314,7 +314,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|getLocale|setLocale/
;
/^
\$
|Window$|WindowStyle$|send
HostEvent|send
NativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64|getLocale|setLocale/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
...
...
@@ -2051,12 +2051,34 @@ function handleEvent (event) {
}
}
const
messages
=
{};
let
locale
;
{
locale
=
my
.
getSystemInfoSync
().
language
;
}
function
initI18nMessages
()
{
if
(
!
isEnableLocale
())
{
return
}
const
localeKeys
=
Object
.
keys
(
__uniConfig
.
locales
);
if
(
localeKeys
.
length
)
{
localeKeys
.
forEach
((
locale
)
=>
{
const
curMessages
=
messages
[
locale
];
const
userMessages
=
__uniConfig
.
locales
[
locale
];
if
(
curMessages
)
{
Object
.
assign
(
curMessages
,
userMessages
);
}
else
{
messages
[
locale
]
=
userMessages
;
}
});
}
}
initI18nMessages
();
const
i18n
=
initVueI18n
(
locale
,
{}
...
...
@@ -2097,7 +2119,20 @@ function initAppLocale (Vue, appVm, locale) {
localeWatchers
.
forEach
(
watch
=>
watch
(
v
));
}
});
}
}
function
isEnableLocale
()
{
return
typeof
__uniConfig
!==
'
undefined
'
&&
__uniConfig
.
locales
&&
!!
Object
.
keys
(
__uniConfig
.
locales
).
length
}
// export function initI18n() {
// const localeKeys = Object.keys(__uniConfig.locales || {})
// if (localeKeys.length) {
// localeKeys.forEach((locale) =>
// i18n.add(locale, __uniConfig.locales[locale])
// )
// }
// }
const
hooks
=
[
'
onShow
'
,
...
...
@@ -2137,7 +2172,7 @@ function initScopedSlotsParams () {
const
has
=
center
[
vueId
];
if
(
!
has
)
{
parents
[
vueId
]
=
this
;
this
.
$on
(
'
hook:dest
ory
'
,
()
=>
{
this
.
$on
(
'
hook:dest
royed
'
,
()
=>
{
delete
parents
[
vueId
];
});
}
...
...
@@ -2151,7 +2186,7 @@ function initScopedSlotsParams () {
return
key
?
object
[
key
]
:
object
}
else
{
parents
[
vueId
]
=
this
;
this
.
$on
(
'
hook:dest
ory
'
,
()
=>
{
this
.
$on
(
'
hook:dest
royed
'
,
()
=>
{
delete
parents
[
vueId
];
});
}
...
...
@@ -2570,18 +2605,15 @@ function parseApp (vm) {
my
.
getPhoneNumber
({
success
:
(
res
)
=>
{
$event
.
type
=
'
getphonenumber
'
;
const
response
=
JSON
.
parse
(
res
.
response
).
response
;
if
(
response
.
code
===
'
10000
'
)
{
// success
$event
.
detail
.
errMsg
=
'
getPhoneNumber:ok
'
;
$event
.
detail
.
encryptedData
=
res
.
response
;
}
else
{
$event
.
detail
.
errMsg
=
'
getPhoneNumber:fail Error:
'
+
res
.
response
;
}
const
response
=
JSON
.
parse
(
res
.
response
);
$event
.
detail
.
errMsg
=
'
getPhoneNumber:ok
'
;
$event
.
detail
.
encryptedData
=
response
.
response
;
$event
.
detail
.
sign
=
response
.
sign
;
this
[
method
](
$event
);
},
fail
:
(
res
)
=>
{
$event
.
type
=
'
getphonenumber
'
;
$event
.
detail
.
errMsg
=
'
getPhoneNumber:fail
'
;
$event
.
detail
.
errMsg
=
'
getPhoneNumber:fail
Error:
'
+
JSON
.
stringify
(
res
)
;
this
[
method
](
$event
);
}
});
...
...
@@ -2898,17 +2930,17 @@ function createPlugin (vm) {
const
appOptions
=
parseApp
(
vm
);
if
(
isFn
(
appOptions
.
onShow
)
&&
my
.
onAppShow
)
{
my
.
onAppShow
((...
args
)
=>
{
appOptions
.
onShow
.
apply
(
vm
,
args
);
vm
.
__call_hook
(
'
onShow
'
,
args
);
});
}
if
(
isFn
(
appOptions
.
onHide
)
&&
my
.
onAppHide
)
{
my
.
onAppHide
((...
args
)
=>
{
appOptions
.
onHide
.
apply
(
vm
,
args
);
vm
.
__call_hook
(
'
onHide
'
,
args
);
});
}
if
(
isFn
(
appOptions
.
onLaunch
))
{
const
args
=
my
.
getLaunchOptionsSync
&&
my
.
getLaunchOptionsSync
();
appOptions
.
onLaunch
.
call
(
vm
,
args
);
vm
.
__call_hook
(
'
onLaunch
'
,
args
);
}
return
vm
}
...
...
packages/uni-mp-baidu/dist/index.js
浏览文件 @
a17ee303
...
...
@@ -314,7 +314,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|getLocale|setLocale/
;
/^
\$
|Window$|WindowStyle$|send
HostEvent|send
NativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64|getLocale|setLocale/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
...
...
@@ -1128,9 +1128,15 @@ const customize = cached((str) => {
function
initTriggerEvent
(
mpInstance
)
{
const
oldTriggerEvent
=
mpInstance
.
triggerEvent
;
mpInstance
.
t
riggerEvent
=
function
(
event
,
...
args
)
{
const
newT
riggerEvent
=
function
(
event
,
...
args
)
{
return
oldTriggerEvent
.
apply
(
mpInstance
,
[
customize
(
event
),
...
args
])
};
try
{
// 京东小程序 triggerEvent 为只读
mpInstance
.
triggerEvent
=
newTriggerEvent
;
}
catch
(
error
)
{
mpInstance
.
_triggerEvent
=
newTriggerEvent
;
}
}
function
initHook
(
name
,
options
,
isComponent
)
{
...
...
@@ -1729,12 +1735,34 @@ function handleEvent (event) {
}
}
const
messages
=
{};
let
locale
;
{
locale
=
swan
.
getSystemInfoSync
().
language
;
}
function
initI18nMessages
()
{
if
(
!
isEnableLocale
())
{
return
}
const
localeKeys
=
Object
.
keys
(
__uniConfig
.
locales
);
if
(
localeKeys
.
length
)
{
localeKeys
.
forEach
((
locale
)
=>
{
const
curMessages
=
messages
[
locale
];
const
userMessages
=
__uniConfig
.
locales
[
locale
];
if
(
curMessages
)
{
Object
.
assign
(
curMessages
,
userMessages
);
}
else
{
messages
[
locale
]
=
userMessages
;
}
});
}
}
initI18nMessages
();
const
i18n
=
initVueI18n
(
locale
,
{}
...
...
@@ -1775,7 +1803,20 @@ function initAppLocale (Vue, appVm, locale) {
localeWatchers
.
forEach
(
watch
=>
watch
(
v
));
}
});
}
}
function
isEnableLocale
()
{
return
typeof
__uniConfig
!==
'
undefined
'
&&
__uniConfig
.
locales
&&
!!
Object
.
keys
(
__uniConfig
.
locales
).
length
}
// export function initI18n() {
// const localeKeys = Object.keys(__uniConfig.locales || {})
// if (localeKeys.length) {
// localeKeys.forEach((locale) =>
// i18n.add(locale, __uniConfig.locales[locale])
// )
// }
// }
const
hooks
=
[
'
onShow
'
,
...
...
@@ -1811,7 +1852,7 @@ function initScopedSlotsParams () {
const
has
=
center
[
vueId
];
if
(
!
has
)
{
parents
[
vueId
]
=
this
;
this
.
$on
(
'
hook:dest
ory
'
,
()
=>
{
this
.
$on
(
'
hook:dest
royed
'
,
()
=>
{
delete
parents
[
vueId
];
});
}
...
...
@@ -1825,7 +1866,7 @@ function initScopedSlotsParams () {
return
key
?
object
[
key
]
:
object
}
else
{
parents
[
vueId
]
=
this
;
this
.
$on
(
'
hook:dest
ory
'
,
()
=>
{
this
.
$on
(
'
hook:dest
royed
'
,
()
=>
{
delete
parents
[
vueId
];
});
}
...
...
@@ -2419,17 +2460,17 @@ function createPlugin (vm) {
const
appOptions
=
parseApp
(
vm
);
if
(
isFn
(
appOptions
.
onShow
)
&&
swan
.
onAppShow
)
{
swan
.
onAppShow
((...
args
)
=>
{
appOptions
.
onShow
.
apply
(
vm
,
args
);
vm
.
__call_hook
(
'
onShow
'
,
args
);
});
}
if
(
isFn
(
appOptions
.
onHide
)
&&
swan
.
onAppHide
)
{
swan
.
onAppHide
((...
args
)
=>
{
appOptions
.
onHide
.
apply
(
vm
,
args
);
vm
.
__call_hook
(
'
onHide
'
,
args
);
});
}
if
(
isFn
(
appOptions
.
onLaunch
))
{
const
args
=
swan
.
getLaunchOptionsSync
&&
swan
.
getLaunchOptionsSync
();
appOptions
.
onLaunch
.
call
(
vm
,
args
);
vm
.
__call_hook
(
'
onLaunch
'
,
args
);
}
return
vm
}
...
...
packages/uni-mp-jd/dist/index.js
浏览文件 @
a17ee303
...
...
@@ -314,7 +314,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|getLocale|setLocale/
;
/^
\$
|Window$|WindowStyle$|send
HostEvent|send
NativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64|getLocale|setLocale/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
...
...
@@ -480,227 +480,28 @@ var baseApi = /*#__PURE__*/Object.freeze({
interceptors
:
interceptors
});
class
EventChannel
{
constructor
(
id
,
events
)
{
this
.
id
=
id
;
this
.
listener
=
{};
this
.
emitCache
=
{};
if
(
events
)
{
Object
.
keys
(
events
).
forEach
(
name
=>
{
this
.
on
(
name
,
events
[
name
]);
});
}
}
emit
(
eventName
,
...
args
)
{
const
fns
=
this
.
listener
[
eventName
];
if
(
!
fns
)
{
return
(
this
.
emitCache
[
eventName
]
||
(
this
.
emitCache
[
eventName
]
=
[])).
push
(
args
)
}
fns
.
forEach
(
opt
=>
{
opt
.
fn
.
apply
(
opt
.
fn
,
args
);
});
this
.
listener
[
eventName
]
=
fns
.
filter
(
opt
=>
opt
.
type
!==
'
once
'
);
}
// import navigateTo from 'uni-helpers/navigate-to'
// import redirectTo from '../../../mp-weixin/helpers/redirect-to'
// import previewImage from '../../../mp-weixin/helpers/normalize-preview-image'
// import getSystemInfo from '../../../mp-weixin/helpers/system-info'
// import getUserProfile from '../../../mp-weixin/helpers/get-user-profile'
on
(
eventName
,
fn
)
{
this
.
_addListener
(
eventName
,
'
on
'
,
fn
);
this
.
_clearCache
(
eventName
);
}
once
(
eventName
,
fn
)
{
this
.
_addListener
(
eventName
,
'
once
'
,
fn
);
this
.
_clearCache
(
eventName
);
}
off
(
eventName
,
fn
)
{
const
fns
=
this
.
listener
[
eventName
];
if
(
!
fns
)
{
return
}
if
(
fn
)
{
for
(
let
i
=
0
;
i
<
fns
.
length
;)
{
if
(
fns
[
i
].
fn
===
fn
)
{
fns
.
splice
(
i
,
1
);
i
--
;
}
i
++
;
}
}
else
{
delete
this
.
listener
[
eventName
];
}
}
_clearCache
(
eventName
)
{
const
cacheArgs
=
this
.
emitCache
[
eventName
];
if
(
cacheArgs
)
{
for
(;
cacheArgs
.
length
>
0
;)
{
this
.
emit
.
apply
(
this
,
[
eventName
].
concat
(
cacheArgs
.
shift
()));
}
}
}
_addListener
(
eventName
,
type
,
fn
)
{
(
this
.
listener
[
eventName
]
||
(
this
.
listener
[
eventName
]
=
[])).
push
({
fn
,
type
});
}
}
const
eventChannels
=
{};
const
eventChannelStack
=
[];
let
id
=
0
;
function
initEventChannel
(
events
,
cache
=
true
)
{
id
++
;
const
eventChannel
=
new
EventChannel
(
id
,
events
);
if
(
cache
)
{
eventChannels
[
id
]
=
eventChannel
;
eventChannelStack
.
push
(
eventChannel
);
}
return
eventChannel
}
function
getEventChannel
(
id
)
{
if
(
id
)
{
const
eventChannel
=
eventChannels
[
id
];
delete
eventChannels
[
id
];
return
eventChannel
}
return
eventChannelStack
.
shift
()
}
var
navigateTo
=
{
args
(
fromArgs
,
toArgs
)
{
const
id
=
initEventChannel
(
fromArgs
.
events
).
id
;
if
(
fromArgs
.
url
)
{
fromArgs
.
url
=
fromArgs
.
url
+
(
fromArgs
.
url
.
indexOf
(
'
?
'
)
===
-
1
?
'
?
'
:
'
&
'
)
+
'
__id__=
'
+
id
;
}
},
returnValue
(
fromRes
,
toRes
)
{
fromRes
.
eventChannel
=
getEventChannel
();
}
};
function
findExistsPageIndex
(
url
)
{
const
pages
=
getCurrentPages
();
let
len
=
pages
.
length
;
while
(
len
--
)
{
const
page
=
pages
[
len
];
if
(
page
.
$page
&&
page
.
$page
.
fullPath
===
url
)
{
return
len
}
}
return
-
1
}
var
redirectTo
=
{
name
(
fromArgs
)
{
if
(
fromArgs
.
exists
===
'
back
'
&&
fromArgs
.
delta
)
{
return
'
navigateBack
'
}
return
'
redirectTo
'
},
args
(
fromArgs
)
{
if
(
fromArgs
.
exists
===
'
back
'
&&
fromArgs
.
url
)
{
const
existsPageIndex
=
findExistsPageIndex
(
fromArgs
.
url
);
if
(
existsPageIndex
!==
-
1
)
{
const
delta
=
getCurrentPages
().
length
-
1
-
existsPageIndex
;
if
(
delta
>
0
)
{
fromArgs
.
delta
=
delta
;
}
}
}
}
};
var
previewImage
=
{
args
(
fromArgs
)
{
let
currentIndex
=
parseInt
(
fromArgs
.
current
);
if
(
isNaN
(
currentIndex
))
{
return
}
const
urls
=
fromArgs
.
urls
;
if
(
!
Array
.
isArray
(
urls
))
{
return
}
const
len
=
urls
.
length
;
if
(
!
len
)
{
return
}
if
(
currentIndex
<
0
)
{
currentIndex
=
0
;
}
else
if
(
currentIndex
>=
len
)
{
currentIndex
=
len
-
1
;
}
if
(
currentIndex
>
0
)
{
fromArgs
.
current
=
urls
[
currentIndex
];
fromArgs
.
urls
=
urls
.
filter
(
(
item
,
index
)
=>
index
<
currentIndex
?
item
!==
urls
[
currentIndex
]
:
true
);
}
else
{
fromArgs
.
current
=
urls
[
0
];
}
return
{
indicator
:
false
,
loop
:
false
}
}
};
const
UUID_KEY
=
'
__DC_STAT_UUID
'
;
let
deviceId
;
function
addUuid
(
result
)
{
deviceId
=
deviceId
||
jd
.
getStorageSync
(
UUID_KEY
);
if
(
!
deviceId
)
{
deviceId
=
Date
.
now
()
+
''
+
Math
.
floor
(
Math
.
random
()
*
1
e7
);
jd
.
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
:
jd
.
canIUse
(
nName
)
?
nName
:
oName
};
// 需要做转换的 API 列表
const
protocols
=
{
navigateTo
,
redirectTo
,
previewImage
,
getSystemInfo
,
getSystemInfoSync
:
getSystemInfo
,
getUserProfile
//
navigateTo,
//
redirectTo,
//
previewImage,
//
getSystemInfo,
//
getSystemInfoSync: getSystemInfo,
//
getUserProfile
};
// 不支持的 API 列表
const
todos
=
[
'
getSelectedTextRange
'
];
// 存在兼容性的 API 列表
const
canIUses
=
[];
const
CALLBACKS
=
[
'
success
'
,
'
fail
'
,
'
cancel
'
,
'
complete
'
];
...
...
@@ -820,8 +621,8 @@ TODOS.forEach(function (name) {
var
providers
=
{
oauth
:
[
'
jd
'
],
share
:
[
'
jd
'
],
payment
:
[
''
],
push
:
[
''
]
payment
:
[
'
jd
'
],
push
:
[
'
jd
'
]
};
function
getProvider
({
...
...
@@ -902,9 +703,15 @@ const customize = cached((str) => {
function
initTriggerEvent
(
mpInstance
)
{
const
oldTriggerEvent
=
mpInstance
.
triggerEvent
;
mpInstance
.
t
riggerEvent
=
function
(
event
,
...
args
)
{
const
newT
riggerEvent
=
function
(
event
,
...
args
)
{
return
oldTriggerEvent
.
apply
(
mpInstance
,
[
customize
(
event
),
...
args
])
};
try
{
// 京东小程序 triggerEvent 为只读
mpInstance
.
triggerEvent
=
newTriggerEvent
;
}
catch
(
error
)
{
mpInstance
.
_triggerEvent
=
newTriggerEvent
;
}
}
function
initHook
(
name
,
options
,
isComponent
)
{
...
...
@@ -1477,12 +1284,34 @@ function handleEvent (event) {
}
}
const
messages
=
{};
let
locale
;
{
locale
=
jd
.
getSystemInfoSync
().
language
;
}
function
initI18nMessages
()
{
if
(
!
isEnableLocale
())
{
return
}
const
localeKeys
=
Object
.
keys
(
__uniConfig
.
locales
);
if
(
localeKeys
.
length
)
{
localeKeys
.
forEach
((
locale
)
=>
{
const
curMessages
=
messages
[
locale
];
const
userMessages
=
__uniConfig
.
locales
[
locale
];
if
(
curMessages
)
{
Object
.
assign
(
curMessages
,
userMessages
);
}
else
{
messages
[
locale
]
=
userMessages
;
}
});
}
}
initI18nMessages
();
const
i18n
=
initVueI18n
(
locale
,
{}
...
...
@@ -1523,6 +1352,100 @@ function initAppLocale (Vue, appVm, locale) {
localeWatchers
.
forEach
(
watch
=>
watch
(
v
));
}
});
}
function
isEnableLocale
()
{
return
typeof
__uniConfig
!==
'
undefined
'
&&
__uniConfig
.
locales
&&
!!
Object
.
keys
(
__uniConfig
.
locales
).
length
}
// export function initI18n() {
// const localeKeys = Object.keys(__uniConfig.locales || {})
// if (localeKeys.length) {
// localeKeys.forEach((locale) =>
// i18n.add(locale, __uniConfig.locales[locale])
// )
// }
// }
class
EventChannel
{
constructor
(
id
,
events
)
{
this
.
id
=
id
;
this
.
listener
=
{};
this
.
emitCache
=
{};
if
(
events
)
{
Object
.
keys
(
events
).
forEach
(
name
=>
{
this
.
on
(
name
,
events
[
name
]);
});
}
}
emit
(
eventName
,
...
args
)
{
const
fns
=
this
.
listener
[
eventName
];
if
(
!
fns
)
{
return
(
this
.
emitCache
[
eventName
]
||
(
this
.
emitCache
[
eventName
]
=
[])).
push
(
args
)
}
fns
.
forEach
(
opt
=>
{
opt
.
fn
.
apply
(
opt
.
fn
,
args
);
});
this
.
listener
[
eventName
]
=
fns
.
filter
(
opt
=>
opt
.
type
!==
'
once
'
);
}
on
(
eventName
,
fn
)
{
this
.
_addListener
(
eventName
,
'
on
'
,
fn
);
this
.
_clearCache
(
eventName
);
}
once
(
eventName
,
fn
)
{
this
.
_addListener
(
eventName
,
'
once
'
,
fn
);
this
.
_clearCache
(
eventName
);
}
off
(
eventName
,
fn
)
{
const
fns
=
this
.
listener
[
eventName
];
if
(
!
fns
)
{
return
}
if
(
fn
)
{
for
(
let
i
=
0
;
i
<
fns
.
length
;)
{
if
(
fns
[
i
].
fn
===
fn
)
{
fns
.
splice
(
i
,
1
);
i
--
;
}
i
++
;
}
}
else
{
delete
this
.
listener
[
eventName
];
}
}
_clearCache
(
eventName
)
{
const
cacheArgs
=
this
.
emitCache
[
eventName
];
if
(
cacheArgs
)
{
for
(;
cacheArgs
.
length
>
0
;)
{
this
.
emit
.
apply
(
this
,
[
eventName
].
concat
(
cacheArgs
.
shift
()));
}
}
}
_addListener
(
eventName
,
type
,
fn
)
{
(
this
.
listener
[
eventName
]
||
(
this
.
listener
[
eventName
]
=
[])).
push
({
fn
,
type
});
}
}
const
eventChannels
=
{};
const
eventChannelStack
=
[];
function
getEventChannel
(
id
)
{
if
(
id
)
{
const
eventChannel
=
eventChannels
[
id
];
delete
eventChannels
[
id
];
return
eventChannel
}
return
eventChannelStack
.
shift
()
}
const
hooks
=
[
...
...
@@ -1534,7 +1457,7 @@ const hooks = [
'
onUnhandledRejection
'
];
function
initEventChannel
$1
()
{
function
initEventChannel
()
{
Vue
.
prototype
.
getOpenerEventChannel
=
function
()
{
if
(
!
this
.
__eventChannel__
)
{
this
.
__eventChannel__
=
new
EventChannel
();
...
...
@@ -1607,7 +1530,7 @@ function parseBaseApp (vm, {
mocks
,
initRefs
})
{
initEventChannel
$1
();
initEventChannel
();
{
initScopedSlotsParams
();
}
...
...
@@ -1690,6 +1613,29 @@ function parseBaseApp (vm, {
const
mocks
=
[
'
__route__
'
,
'
__wxExparserNodeId__
'
,
'
__wxWebviewId__
'
];
function
findVmByVueId
(
vm
,
vuePid
)
{
const
$children
=
vm
.
$children
;
// 优先查找直属(反向查找:https://github.com/dcloudio/uni-app/issues/1200)
for
(
let
i
=
$children
.
length
-
1
;
i
>=
0
;
i
--
)
{
const
childVm
=
$children
[
i
];
if
(
childVm
.
$scope
.
_$vueId
===
vuePid
)
{
return
childVm
}
}
// 反向递归查找
let
parentVm
;
for
(
let
i
=
$children
.
length
-
1
;
i
>=
0
;
i
--
)
{
parentVm
=
findVmByVueId
(
$children
[
i
],
vuePid
);
if
(
parentVm
)
{
return
parentVm
}
}
}
function
initBehavior
(
options
)
{
return
Behavior
(
options
)
}
function
isPage
()
{
return
!!
this
.
route
}
...
...
@@ -1724,6 +1670,25 @@ function initRefs (vm) {
return
$refs
}
});
}
function
handleLink
(
event
)
{
const
{
vuePid
,
vueOptions
}
=
event
.
detail
||
event
.
value
;
// detail 是微信,value 是百度(dipatch)
let
parentVm
;
if
(
vuePid
)
{
parentVm
=
findVmByVueId
(
this
.
$vm
,
vuePid
);
}
if
(
!
parentVm
)
{
parentVm
=
this
.
$vm
;
}
vueOptions
.
parent
=
parentVm
;
}
function
parseApp
(
vm
)
{
...
...
@@ -1785,48 +1750,6 @@ function stringifyQuery (obj, encodeStr = encode) {
return
res
?
`?
${
res
}
`
:
''
}
function
findVmByVueId
(
vm
,
vuePid
)
{
const
$children
=
vm
.
$children
;
// 优先查找直属(反向查找:https://github.com/dcloudio/uni-app/issues/1200)
for
(
let
i
=
$children
.
length
-
1
;
i
>=
0
;
i
--
)
{
const
childVm
=
$children
[
i
];
if
(
childVm
.
$scope
.
_$vueId
===
vuePid
)
{
return
childVm
}
}
// 反向递归查找
let
parentVm
;
for
(
let
i
=
$children
.
length
-
1
;
i
>=
0
;
i
--
)
{
parentVm
=
findVmByVueId
(
$children
[
i
],
vuePid
);
if
(
parentVm
)
{
return
parentVm
}
}
}
function
initBehavior
(
options
)
{
return
Behavior
(
options
)
}
function
handleLink
(
event
)
{
const
{
vuePid
,
vueOptions
}
=
event
.
detail
||
event
.
value
;
// detail 是微信,value 是百度(dipatch)
let
parentVm
;
if
(
vuePid
)
{
parentVm
=
findVmByVueId
(
this
.
$vm
,
vuePid
);
}
if
(
!
parentVm
)
{
parentVm
=
this
.
$vm
;
}
vueOptions
.
parent
=
parentVm
;
}
function
parseBaseComponent
(
vueComponentOptions
,
{
isPage
,
initRelation
...
...
@@ -1847,27 +1770,27 @@ function parseBaseComponent (vueComponentOptions, {
lifetimes
:
{
attached
()
{
const
properties
=
this
.
properties
;
const
options
=
{
mpType
:
isPage
.
call
(
this
)
?
'
page
'
:
'
component
'
,
mpInstance
:
this
,
propsData
:
properties
};
initVueIds
(
properties
.
vueId
,
this
);
// 处理父子关系
initRelation
.
call
(
this
,
{
vuePid
:
this
.
_$vuePid
,
vueOptions
:
options
});
// 初始化 vue 实例
this
.
$vm
=
new
VueComponent
(
options
);
// 处理$slots,$scopedSlots(暂不支持动态变化$slots)
initSlots
(
this
.
$vm
,
properties
.
vueSlots
);
// 触发首次 setData
this
.
$vm
.
$mount
();
},
...
...
@@ -1882,7 +1805,7 @@ function parseBaseComponent (vueComponentOptions, {
},
detached
()
{
this
.
$vm
&&
this
.
$vm
.
$destroy
();
}
,
}
},
pageLifetimes
:
{
show
(
args
)
{
...
...
@@ -1895,44 +1818,6 @@ function parseBaseComponent (vueComponentOptions, {
this
.
$vm
&&
this
.
$vm
.
__call_hook
(
'
onPageResize
'
,
size
);
}
},
attached
()
{
const
properties
=
this
.
properties
;
const
options
=
{
mpType
:
isPage
.
call
(
this
)
?
'
page
'
:
'
component
'
,
mpInstance
:
this
,
propsData
:
properties
};
initVueIds
(
properties
.
vueId
,
this
);
// 处理父子关系
initRelation
.
call
(
this
,
{
vuePid
:
this
.
_$vuePid
,
vueOptions
:
options
});
// 初始化 vue 实例
this
.
$vm
=
new
VueComponent
(
options
);
// 处理$slots,$scopedSlots(暂不支持动态变化$slots)
initSlots
(
this
.
$vm
,
properties
.
vueSlots
);
// 触发首次 setData
this
.
$vm
.
$mount
();
},
ready
()
{
// 当组件 props 默认值为 true,初始化时传入 false 会导致 created,ready 触发, 但 attached 不触发
// https://developers.weixin.qq.com/community/develop/doc/00066ae2844cc0f8eb883e2a557800
if
(
this
.
$vm
)
{
this
.
$vm
.
_isMounted
=
true
;
this
.
$vm
.
__call_hook
(
'
mounted
'
);
this
.
$vm
.
__call_hook
(
'
onReady
'
);
}
},
detached
()
{
this
.
$vm
&&
this
.
$vm
.
$destroy
();
},
methods
:
{
__l
:
handleLink
,
__e
:
handleEvent
...
...
@@ -1957,6 +1842,23 @@ function parseBaseComponent (vueComponentOptions, {
return
[
componentOptions
,
VueComponent
]
}
function
parseComponent
(
vueComponentOptions
)
{
return
parseBaseComponent
(
vueComponentOptions
,
{
isPage
,
initRelation
})
}
function
parseComponent$1
(
vueComponentOptions
)
{
const
componentOptions
=
parseComponent
(
vueComponentOptions
);
// 京东小程序 lifetimes 存在兼容问题
const
lifetimes
=
componentOptions
.
lifetimes
;
Object
.
keys
(
lifetimes
).
forEach
(
key
=>
{
componentOptions
[
key
]
=
lifetimes
[
key
];
});
return
componentOptions
}
const
hooks$1
=
[
'
onShow
'
,
'
onHide
'
,
...
...
@@ -1969,10 +1871,7 @@ function parseBasePage (vuePageOptions, {
isPage
,
initRelation
})
{
const
pageOptions
=
parseBaseComponent
(
vuePageOptions
,
{
isPage
,
initRelation
});
const
pageOptions
=
parseComponent$1
(
vuePageOptions
);
initHooks
(
pageOptions
.
methods
,
hooks$1
,
vuePageOptions
);
...
...
@@ -2009,7 +1908,7 @@ function createPage (vuePageOptions) {
function
createComponent
(
vueOptions
)
{
{
return
Component
(
parse
BaseComponent
(
vueOptions
))
return
Component
(
parse
Component$1
(
vueOptions
))
}
}
...
...
@@ -2053,17 +1952,17 @@ function createPlugin (vm) {
const
appOptions
=
parseApp$1
(
vm
);
if
(
isFn
(
appOptions
.
onShow
)
&&
jd
.
onAppShow
)
{
jd
.
onAppShow
((...
args
)
=>
{
appOptions
.
onShow
.
apply
(
vm
,
args
);
vm
.
__call_hook
(
'
onShow
'
,
args
);
});
}
if
(
isFn
(
appOptions
.
onHide
)
&&
jd
.
onAppHide
)
{
jd
.
onAppHide
((...
args
)
=>
{
appOptions
.
onHide
.
apply
(
vm
,
args
);
vm
.
__call_hook
(
'
onHide
'
,
args
);
});
}
if
(
isFn
(
appOptions
.
onLaunch
))
{
const
args
=
jd
.
getLaunchOptionsSync
&&
jd
.
getLaunchOptionsSync
();
appOptions
.
onLaunch
.
call
(
vm
,
args
);
vm
.
__call_hook
(
'
onLaunch
'
,
args
);
}
return
vm
}
...
...
packages/uni-mp-kuaishou/dist/index.js
浏览文件 @
a17ee303
...
...
@@ -314,7 +314,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|getLocale|setLocale/
;
/^
\$
|Window$|WindowStyle$|send
HostEvent|send
NativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64|getLocale|setLocale/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
...
...
@@ -903,9 +903,15 @@ const customize = cached((str) => {
function
initTriggerEvent
(
mpInstance
)
{
const
oldTriggerEvent
=
mpInstance
.
triggerEvent
;
mpInstance
.
t
riggerEvent
=
function
(
event
,
...
args
)
{
const
newT
riggerEvent
=
function
(
event
,
...
args
)
{
return
oldTriggerEvent
.
apply
(
mpInstance
,
[
customize
(
event
),
...
args
])
};
try
{
// 京东小程序 triggerEvent 为只读
mpInstance
.
triggerEvent
=
newTriggerEvent
;
}
catch
(
error
)
{
mpInstance
.
_triggerEvent
=
newTriggerEvent
;
}
}
function
initHook
(
name
,
options
,
isComponent
)
{
...
...
@@ -1478,12 +1484,34 @@ function handleEvent (event) {
}
}
const
messages
=
{};
let
locale
;
{
locale
=
ks
.
getSystemInfoSync
().
language
;
}
function
initI18nMessages
()
{
if
(
!
isEnableLocale
())
{
return
}
const
localeKeys
=
Object
.
keys
(
__uniConfig
.
locales
);
if
(
localeKeys
.
length
)
{
localeKeys
.
forEach
((
locale
)
=>
{
const
curMessages
=
messages
[
locale
];
const
userMessages
=
__uniConfig
.
locales
[
locale
];
if
(
curMessages
)
{
Object
.
assign
(
curMessages
,
userMessages
);
}
else
{
messages
[
locale
]
=
userMessages
;
}
});
}
}
initI18nMessages
();
const
i18n
=
initVueI18n
(
locale
,
{}
...
...
@@ -1524,7 +1552,20 @@ function initAppLocale (Vue, appVm, locale) {
localeWatchers
.
forEach
(
watch
=>
watch
(
v
));
}
});
}
}
function
isEnableLocale
()
{
return
typeof
__uniConfig
!==
'
undefined
'
&&
__uniConfig
.
locales
&&
!!
Object
.
keys
(
__uniConfig
.
locales
).
length
}
// export function initI18n() {
// const localeKeys = Object.keys(__uniConfig.locales || {})
// if (localeKeys.length) {
// localeKeys.forEach((locale) =>
// i18n.add(locale, __uniConfig.locales[locale])
// )
// }
// }
const
hooks
=
[
'
onShow
'
,
...
...
@@ -1560,7 +1601,7 @@ function initScopedSlotsParams () {
const
has
=
center
[
vueId
];
if
(
!
has
)
{
parents
[
vueId
]
=
this
;
this
.
$on
(
'
hook:dest
ory
'
,
()
=>
{
this
.
$on
(
'
hook:dest
royed
'
,
()
=>
{
delete
parents
[
vueId
];
});
}
...
...
@@ -1574,7 +1615,7 @@ function initScopedSlotsParams () {
return
key
?
object
[
key
]
:
object
}
else
{
parents
[
vueId
]
=
this
;
this
.
$on
(
'
hook:dest
ory
'
,
()
=>
{
this
.
$on
(
'
hook:dest
royed
'
,
()
=>
{
delete
parents
[
vueId
];
});
}
...
...
@@ -2075,17 +2116,17 @@ function createPlugin (vm) {
const
appOptions
=
parseApp$1
(
vm
);
if
(
isFn
(
appOptions
.
onShow
)
&&
ks
.
onAppShow
)
{
ks
.
onAppShow
((...
args
)
=>
{
appOptions
.
onShow
.
apply
(
vm
,
args
);
vm
.
__call_hook
(
'
onShow
'
,
args
);
});
}
if
(
isFn
(
appOptions
.
onHide
)
&&
ks
.
onAppHide
)
{
ks
.
onAppHide
((...
args
)
=>
{
appOptions
.
onHide
.
apply
(
vm
,
args
);
vm
.
__call_hook
(
'
onHide
'
,
args
);
});
}
if
(
isFn
(
appOptions
.
onLaunch
))
{
const
args
=
ks
.
getLaunchOptionsSync
&&
ks
.
getLaunchOptionsSync
();
appOptions
.
onLaunch
.
call
(
vm
,
args
);
vm
.
__call_hook
(
'
onLaunch
'
,
args
);
}
return
vm
}
...
...
packages/uni-mp-lark/dist/index.js
浏览文件 @
a17ee303
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
(
a
tob
(
str
).
split
(
''
).
map
(
function
(
c
)
{
return
decodeURIComponent
(
realA
tob
(
str
).
split
(
''
).
map
(
function
(
c
)
{
return
'
%
'
+
(
'
00
'
+
c
.
charCodeAt
(
0
).
toString
(
16
)).
slice
(
-
2
)
}).
join
(
''
))
}
...
...
@@ -286,7 +314,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|getLocale|setLocale/
;
/^
\$
|Window$|WindowStyle$|send
HostEvent|send
NativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64|getLocale|setLocale/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
...
...
@@ -431,6 +459,10 @@ function onLocaleChange (fn) {
if
(
onLocaleChangeCallbacks
.
indexOf
(
fn
)
===
-
1
)
{
onLocaleChangeCallbacks
.
push
(
fn
);
}
}
if
(
typeof
global
!==
'
undefined
'
)
{
global
.
getLocale
=
getLocale
;
}
const
interceptors
=
{
...
...
@@ -921,9 +953,15 @@ const customize = cached((str) => {
function
initTriggerEvent
(
mpInstance
)
{
const
oldTriggerEvent
=
mpInstance
.
triggerEvent
;
mpInstance
.
t
riggerEvent
=
function
(
event
,
...
args
)
{
const
newT
riggerEvent
=
function
(
event
,
...
args
)
{
return
oldTriggerEvent
.
apply
(
mpInstance
,
[
customize
(
event
),
...
args
])
};
try
{
// 京东小程序 triggerEvent 为只读
mpInstance
.
triggerEvent
=
newTriggerEvent
;
}
catch
(
error
)
{
mpInstance
.
_triggerEvent
=
newTriggerEvent
;
}
}
function
initHook
(
name
,
options
,
isComponent
)
{
...
...
@@ -1496,12 +1534,34 @@ function handleEvent (event) {
}
}
const
messages
=
{};
let
locale
;
{
locale
=
tt
.
getSystemInfoSync
().
language
;
}
function
initI18nMessages
()
{
if
(
!
isEnableLocale
())
{
return
}
const
localeKeys
=
Object
.
keys
(
__uniConfig
.
locales
);
if
(
localeKeys
.
length
)
{
localeKeys
.
forEach
((
locale
)
=>
{
const
curMessages
=
messages
[
locale
];
const
userMessages
=
__uniConfig
.
locales
[
locale
];
if
(
curMessages
)
{
Object
.
assign
(
curMessages
,
userMessages
);
}
else
{
messages
[
locale
]
=
userMessages
;
}
});
}
}
initI18nMessages
();
const
i18n
=
initVueI18n
(
locale
,
{}
...
...
@@ -1542,7 +1602,20 @@ function initAppLocale (Vue, appVm, locale) {
localeWatchers
.
forEach
(
watch
=>
watch
(
v
));
}
});
}
}
function
isEnableLocale
()
{
return
typeof
__uniConfig
!==
'
undefined
'
&&
__uniConfig
.
locales
&&
!!
Object
.
keys
(
__uniConfig
.
locales
).
length
}
// export function initI18n() {
// const localeKeys = Object.keys(__uniConfig.locales || {})
// if (localeKeys.length) {
// localeKeys.forEach((locale) =>
// i18n.add(locale, __uniConfig.locales[locale])
// )
// }
// }
const
hooks
=
[
'
onShow
'
,
...
...
@@ -1578,7 +1651,7 @@ function initScopedSlotsParams () {
const
has
=
center
[
vueId
];
if
(
!
has
)
{
parents
[
vueId
]
=
this
;
this
.
$on
(
'
hook:dest
ory
'
,
()
=>
{
this
.
$on
(
'
hook:dest
royed
'
,
()
=>
{
delete
parents
[
vueId
];
});
}
...
...
@@ -1592,7 +1665,7 @@ function initScopedSlotsParams () {
return
key
?
object
[
key
]
:
object
}
else
{
parents
[
vueId
]
=
this
;
this
.
$on
(
'
hook:dest
ory
'
,
()
=>
{
this
.
$on
(
'
hook:dest
royed
'
,
()
=>
{
delete
parents
[
vueId
];
});
}
...
...
@@ -2152,17 +2225,17 @@ function createPlugin (vm) {
const
appOptions
=
parseApp
(
vm
);
if
(
isFn
(
appOptions
.
onShow
)
&&
tt
.
onAppShow
)
{
tt
.
onAppShow
((...
args
)
=>
{
appOptions
.
onShow
.
apply
(
vm
,
args
);
vm
.
__call_hook
(
'
onShow
'
,
args
);
});
}
if
(
isFn
(
appOptions
.
onHide
)
&&
tt
.
onAppHide
)
{
tt
.
onAppHide
((...
args
)
=>
{
appOptions
.
onHide
.
apply
(
vm
,
args
);
vm
.
__call_hook
(
'
onHide
'
,
args
);
});
}
if
(
isFn
(
appOptions
.
onLaunch
))
{
const
args
=
tt
.
getLaunchOptionsSync
&&
tt
.
getLaunchOptionsSync
();
appOptions
.
onLaunch
.
call
(
vm
,
args
);
vm
.
__call_hook
(
'
onLaunch
'
,
args
);
}
return
vm
}
...
...
packages/uni-mp-qq/dist/index.js
浏览文件 @
a17ee303
...
...
@@ -314,7 +314,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|getLocale|setLocale/
;
/^
\$
|Window$|WindowStyle$|send
HostEvent|send
NativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64|getLocale|setLocale/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
...
...
@@ -1064,9 +1064,15 @@ const customize = cached((str) => {
function
initTriggerEvent
(
mpInstance
)
{
const
oldTriggerEvent
=
mpInstance
.
triggerEvent
;
mpInstance
.
t
riggerEvent
=
function
(
event
,
...
args
)
{
const
newT
riggerEvent
=
function
(
event
,
...
args
)
{
return
oldTriggerEvent
.
apply
(
mpInstance
,
[
customize
(
event
),
...
args
])
};
try
{
// 京东小程序 triggerEvent 为只读
mpInstance
.
triggerEvent
=
newTriggerEvent
;
}
catch
(
error
)
{
mpInstance
.
_triggerEvent
=
newTriggerEvent
;
}
}
function
initHook
(
name
,
options
,
isComponent
)
{
...
...
@@ -1639,12 +1645,34 @@ function handleEvent (event) {
}
}
const
messages
=
{};
let
locale
;
{
locale
=
wx
.
getSystemInfoSync
().
language
;
}
function
initI18nMessages
()
{
if
(
!
isEnableLocale
())
{
return
}
const
localeKeys
=
Object
.
keys
(
__uniConfig
.
locales
);
if
(
localeKeys
.
length
)
{
localeKeys
.
forEach
((
locale
)
=>
{
const
curMessages
=
messages
[
locale
];
const
userMessages
=
__uniConfig
.
locales
[
locale
];
if
(
curMessages
)
{
Object
.
assign
(
curMessages
,
userMessages
);
}
else
{
messages
[
locale
]
=
userMessages
;
}
});
}
}
initI18nMessages
();
const
i18n
=
initVueI18n
(
locale
,
{}
...
...
@@ -1685,7 +1713,20 @@ function initAppLocale (Vue, appVm, locale) {
localeWatchers
.
forEach
(
watch
=>
watch
(
v
));
}
});
}
}
function
isEnableLocale
()
{
return
typeof
__uniConfig
!==
'
undefined
'
&&
__uniConfig
.
locales
&&
!!
Object
.
keys
(
__uniConfig
.
locales
).
length
}
// export function initI18n() {
// const localeKeys = Object.keys(__uniConfig.locales || {})
// if (localeKeys.length) {
// localeKeys.forEach((locale) =>
// i18n.add(locale, __uniConfig.locales[locale])
// )
// }
// }
const
hooks
=
[
'
onShow
'
,
...
...
@@ -1721,7 +1762,7 @@ function initScopedSlotsParams () {
const
has
=
center
[
vueId
];
if
(
!
has
)
{
parents
[
vueId
]
=
this
;
this
.
$on
(
'
hook:dest
ory
'
,
()
=>
{
this
.
$on
(
'
hook:dest
royed
'
,
()
=>
{
delete
parents
[
vueId
];
});
}
...
...
@@ -1735,7 +1776,7 @@ function initScopedSlotsParams () {
return
key
?
object
[
key
]
:
object
}
else
{
parents
[
vueId
]
=
this
;
this
.
$on
(
'
hook:dest
ory
'
,
()
=>
{
this
.
$on
(
'
hook:dest
royed
'
,
()
=>
{
delete
parents
[
vueId
];
});
}
...
...
@@ -2197,17 +2238,17 @@ function createPlugin (vm) {
const
appOptions
=
parseApp$1
(
vm
);
if
(
isFn
(
appOptions
.
onShow
)
&&
wx
.
onAppShow
)
{
wx
.
onAppShow
((...
args
)
=>
{
appOptions
.
onShow
.
apply
(
vm
,
args
);
vm
.
__call_hook
(
'
onShow
'
,
args
);
});
}
if
(
isFn
(
appOptions
.
onHide
)
&&
wx
.
onAppHide
)
{
wx
.
onAppHide
((...
args
)
=>
{
appOptions
.
onHide
.
apply
(
vm
,
args
);
vm
.
__call_hook
(
'
onHide
'
,
args
);
});
}
if
(
isFn
(
appOptions
.
onLaunch
))
{
const
args
=
wx
.
getLaunchOptionsSync
&&
wx
.
getLaunchOptionsSync
();
appOptions
.
onLaunch
.
call
(
vm
,
args
);
vm
.
__call_hook
(
'
onLaunch
'
,
args
);
}
return
vm
}
...
...
packages/uni-mp-toutiao/dist/index.js
浏览文件 @
a17ee303
...
...
@@ -314,7 +314,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|getLocale|setLocale/
;
/^
\$
|Window$|WindowStyle$|send
HostEvent|send
NativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64|getLocale|setLocale/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
...
...
@@ -1156,9 +1156,15 @@ const customize = cached((str) => {
function
initTriggerEvent
(
mpInstance
)
{
const
oldTriggerEvent
=
mpInstance
.
triggerEvent
;
mpInstance
.
t
riggerEvent
=
function
(
event
,
...
args
)
{
const
newT
riggerEvent
=
function
(
event
,
...
args
)
{
return
oldTriggerEvent
.
apply
(
mpInstance
,
[
customize
(
event
),
...
args
])
};
try
{
// 京东小程序 triggerEvent 为只读
mpInstance
.
triggerEvent
=
newTriggerEvent
;
}
catch
(
error
)
{
mpInstance
.
_triggerEvent
=
newTriggerEvent
;
}
}
function
initHook
(
name
,
options
,
isComponent
)
{
...
...
@@ -1735,12 +1741,34 @@ function handleEvent (event) {
}
}
const
messages
=
{};
let
locale
;
{
locale
=
tt
.
getSystemInfoSync
().
language
;
}
function
initI18nMessages
()
{
if
(
!
isEnableLocale
())
{
return
}
const
localeKeys
=
Object
.
keys
(
__uniConfig
.
locales
);
if
(
localeKeys
.
length
)
{
localeKeys
.
forEach
((
locale
)
=>
{
const
curMessages
=
messages
[
locale
];
const
userMessages
=
__uniConfig
.
locales
[
locale
];
if
(
curMessages
)
{
Object
.
assign
(
curMessages
,
userMessages
);
}
else
{
messages
[
locale
]
=
userMessages
;
}
});
}
}
initI18nMessages
();
const
i18n
=
initVueI18n
(
locale
,
{}
...
...
@@ -1781,7 +1809,20 @@ function initAppLocale (Vue, appVm, locale) {
localeWatchers
.
forEach
(
watch
=>
watch
(
v
));
}
});
}
}
function
isEnableLocale
()
{
return
typeof
__uniConfig
!==
'
undefined
'
&&
__uniConfig
.
locales
&&
!!
Object
.
keys
(
__uniConfig
.
locales
).
length
}
// export function initI18n() {
// const localeKeys = Object.keys(__uniConfig.locales || {})
// if (localeKeys.length) {
// localeKeys.forEach((locale) =>
// i18n.add(locale, __uniConfig.locales[locale])
// )
// }
// }
const
hooks
=
[
'
onShow
'
,
...
...
@@ -1817,7 +1858,7 @@ function initScopedSlotsParams () {
const
has
=
center
[
vueId
];
if
(
!
has
)
{
parents
[
vueId
]
=
this
;
this
.
$on
(
'
hook:dest
ory
'
,
()
=>
{
this
.
$on
(
'
hook:dest
royed
'
,
()
=>
{
delete
parents
[
vueId
];
});
}
...
...
@@ -1831,7 +1872,7 @@ function initScopedSlotsParams () {
return
key
?
object
[
key
]
:
object
}
else
{
parents
[
vueId
]
=
this
;
this
.
$on
(
'
hook:dest
ory
'
,
()
=>
{
this
.
$on
(
'
hook:dest
royed
'
,
()
=>
{
delete
parents
[
vueId
];
});
}
...
...
@@ -2425,17 +2466,17 @@ function createPlugin (vm) {
const
appOptions
=
parseApp
(
vm
);
if
(
isFn
(
appOptions
.
onShow
)
&&
tt
.
onAppShow
)
{
tt
.
onAppShow
((...
args
)
=>
{
appOptions
.
onShow
.
apply
(
vm
,
args
);
vm
.
__call_hook
(
'
onShow
'
,
args
);
});
}
if
(
isFn
(
appOptions
.
onHide
)
&&
tt
.
onAppHide
)
{
tt
.
onAppHide
((...
args
)
=>
{
appOptions
.
onHide
.
apply
(
vm
,
args
);
vm
.
__call_hook
(
'
onHide
'
,
args
);
});
}
if
(
isFn
(
appOptions
.
onLaunch
))
{
const
args
=
tt
.
getLaunchOptionsSync
&&
tt
.
getLaunchOptionsSync
();
appOptions
.
onLaunch
.
call
(
vm
,
args
);
vm
.
__call_hook
(
'
onLaunch
'
,
args
);
}
return
vm
}
...
...
packages/uni-mp-weixin/dist/index.js
浏览文件 @
a17ee303
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
(
realAtob
(
str
).
split
(
''
).
map
(
function
(
c
)
{
return
'
%
'
+
(
'
00
'
+
c
.
charCodeAt
(
0
).
toString
(
16
)).
slice
(
-
2
)
}).
join
(
''
))
}
function
getCurrentUserInfo
()
{
const
token
=
(
wx
).
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
()
};
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
(
realAtob
(
str
).
split
(
''
).
map
(
function
(
c
)
{
return
'
%
'
+
(
'
00
'
+
c
.
charCodeAt
(
0
).
toString
(
16
)).
slice
(
-
2
)
}).
join
(
''
))
}
function
getCurrentUserInfo
()
{
const
token
=
(
wx
).
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
;
...
...
@@ -314,7 +314,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|getLocale|setLocale/
;
/^
\$
|Window$|WindowStyle$|send
HostEvent|send
NativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64|getLocale|setLocale/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
...
...
@@ -546,37 +546,37 @@ var previewImage = {
}
};
const
UUID_KEY
=
'
__DC_STAT_UUID
'
;
let
deviceId
;
function
addUuid
(
result
)
{
deviceId
=
deviceId
||
wx
.
getStorageSync
(
UUID_KEY
);
if
(
!
deviceId
)
{
deviceId
=
Date
.
now
()
+
''
+
Math
.
floor
(
Math
.
random
()
*
1
e7
);
wx
.
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
||
wx
.
getStorageSync
(
UUID_KEY
);
if
(
!
deviceId
)
{
deviceId
=
Date
.
now
()
+
''
+
Math
.
floor
(
Math
.
random
()
*
1
e7
);
wx
.
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
);
}
};
// import navigateTo from 'uni-helpers/navigate-to'
...
...
@@ -795,9 +795,15 @@ const customize = cached((str) => {
function
initTriggerEvent
(
mpInstance
)
{
const
oldTriggerEvent
=
mpInstance
.
triggerEvent
;
mpInstance
.
t
riggerEvent
=
function
(
event
,
...
args
)
{
const
newT
riggerEvent
=
function
(
event
,
...
args
)
{
return
oldTriggerEvent
.
apply
(
mpInstance
,
[
customize
(
event
),
...
args
])
};
try
{
// 京东小程序 triggerEvent 为只读
mpInstance
.
triggerEvent
=
newTriggerEvent
;
}
catch
(
error
)
{
mpInstance
.
_triggerEvent
=
newTriggerEvent
;
}
}
function
initHook
(
name
,
options
,
isComponent
)
{
...
...
@@ -1370,12 +1376,34 @@ function handleEvent (event) {
}
}
const
messages
=
{};
let
locale
;
{
locale
=
wx
.
getSystemInfoSync
().
language
;
}
function
initI18nMessages
()
{
if
(
!
isEnableLocale
())
{
return
}
const
localeKeys
=
Object
.
keys
(
__uniConfig
.
locales
);
if
(
localeKeys
.
length
)
{
localeKeys
.
forEach
((
locale
)
=>
{
const
curMessages
=
messages
[
locale
];
const
userMessages
=
__uniConfig
.
locales
[
locale
];
if
(
curMessages
)
{
Object
.
assign
(
curMessages
,
userMessages
);
}
else
{
messages
[
locale
]
=
userMessages
;
}
});
}
}
initI18nMessages
();
const
i18n
=
initVueI18n
(
locale
,
{}
...
...
@@ -1416,7 +1444,20 @@ function initAppLocale (Vue, appVm, locale) {
localeWatchers
.
forEach
(
watch
=>
watch
(
v
));
}
});
}
}
function
isEnableLocale
()
{
return
typeof
__uniConfig
!==
'
undefined
'
&&
__uniConfig
.
locales
&&
!!
Object
.
keys
(
__uniConfig
.
locales
).
length
}
// export function initI18n() {
// const localeKeys = Object.keys(__uniConfig.locales || {})
// if (localeKeys.length) {
// localeKeys.forEach((locale) =>
// i18n.add(locale, __uniConfig.locales[locale])
// )
// }
// }
const
eventChannels
=
{};
...
...
@@ -1431,172 +1472,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:dest
ory
'
,
()
=>
{
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:dest
ory
'
,
()
=>
{
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:dest
royed
'
,
()
=>
{
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:dest
royed
'
,
()
=>
{
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__
'
];
...
...
@@ -1932,23 +1973,23 @@ function createSubpackageApp (vm) {
return
vm
}
function
createPlugin
(
vm
)
{
const
appOptions
=
parseApp
(
vm
);
if
(
isFn
(
appOptions
.
onShow
)
&&
wx
.
onAppShow
)
{
wx
.
onAppShow
((...
args
)
=>
{
appOptions
.
onShow
.
apply
(
vm
,
args
);
});
}
if
(
isFn
(
appOptions
.
onHide
)
&&
wx
.
onAppHide
)
{
wx
.
onAppHide
((...
args
)
=>
{
appOptions
.
onHide
.
apply
(
vm
,
args
);
});
}
if
(
isFn
(
appOptions
.
onLaunch
))
{
const
args
=
wx
.
getLaunchOptionsSync
&&
wx
.
getLaunchOptionsSync
();
appOptions
.
onLaunch
.
call
(
vm
,
args
);
}
return
vm
function
createPlugin
(
vm
)
{
const
appOptions
=
parseApp
(
vm
);
if
(
isFn
(
appOptions
.
onShow
)
&&
wx
.
onAppShow
)
{
wx
.
onAppShow
((...
args
)
=>
{
vm
.
__call_hook
(
'
onShow
'
,
args
);
});
}
if
(
isFn
(
appOptions
.
onHide
)
&&
wx
.
onAppHide
)
{
wx
.
onAppHide
((...
args
)
=>
{
vm
.
__call_hook
(
'
onHide
'
,
args
);
});
}
if
(
isFn
(
appOptions
.
onLaunch
))
{
const
args
=
wx
.
getLaunchOptionsSync
&&
wx
.
getLaunchOptionsSync
();
vm
.
__call_hook
(
'
onLaunch
'
,
args
);
}
return
vm
}
todos
.
forEach
(
todoApi
=>
{
...
...
packages/uni-quickapp-native/dist/vue.dev.js
浏览文件 @
a17ee303
此差异已折叠。
点击以展开。
packages/uni-quickapp-native/dist/vue.prod.js
浏览文件 @
a17ee303
此差异已折叠。
点击以展开。
packages/uni-quickapp-webview/dist/index.js
浏览文件 @
a17ee303
...
...
@@ -314,7 +314,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|getLocale|setLocale/
;
/^
\$
|Window$|WindowStyle$|send
HostEvent|send
NativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64|getLocale|setLocale/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
...
...
@@ -870,9 +870,15 @@ const customize = cached((str) => {
function
initTriggerEvent
(
mpInstance
)
{
const
oldTriggerEvent
=
mpInstance
.
triggerEvent
;
mpInstance
.
t
riggerEvent
=
function
(
event
,
...
args
)
{
const
newT
riggerEvent
=
function
(
event
,
...
args
)
{
return
oldTriggerEvent
.
apply
(
mpInstance
,
[
customize
(
event
),
...
args
])
};
try
{
// 京东小程序 triggerEvent 为只读
mpInstance
.
triggerEvent
=
newTriggerEvent
;
}
catch
(
error
)
{
mpInstance
.
_triggerEvent
=
newTriggerEvent
;
}
}
function
initHook
(
name
,
options
,
isComponent
)
{
...
...
@@ -1445,12 +1451,34 @@ function handleEvent (event) {
}
}
const
messages
=
{};
let
locale
;
{
locale
=
qa
.
getSystemInfoSync
().
language
;
}
function
initI18nMessages
()
{
if
(
!
isEnableLocale
())
{
return
}
const
localeKeys
=
Object
.
keys
(
__uniConfig
.
locales
);
if
(
localeKeys
.
length
)
{
localeKeys
.
forEach
((
locale
)
=>
{
const
curMessages
=
messages
[
locale
];
const
userMessages
=
__uniConfig
.
locales
[
locale
];
if
(
curMessages
)
{
Object
.
assign
(
curMessages
,
userMessages
);
}
else
{
messages
[
locale
]
=
userMessages
;
}
});
}
}
initI18nMessages
();
const
i18n
=
initVueI18n
(
locale
,
{}
...
...
@@ -1491,7 +1519,20 @@ function initAppLocale (Vue, appVm, locale) {
localeWatchers
.
forEach
(
watch
=>
watch
(
v
));
}
});
}
}
function
isEnableLocale
()
{
return
typeof
__uniConfig
!==
'
undefined
'
&&
__uniConfig
.
locales
&&
!!
Object
.
keys
(
__uniConfig
.
locales
).
length
}
// export function initI18n() {
// const localeKeys = Object.keys(__uniConfig.locales || {})
// if (localeKeys.length) {
// localeKeys.forEach((locale) =>
// i18n.add(locale, __uniConfig.locales[locale])
// )
// }
// }
const
hooks
=
[
'
onShow
'
,
...
...
@@ -2053,17 +2094,17 @@ function createPlugin (vm) {
const
appOptions
=
parseApp
(
vm
);
if
(
isFn
(
appOptions
.
onShow
)
&&
qa
.
onAppShow
)
{
qa
.
onAppShow
((...
args
)
=>
{
appOptions
.
onShow
.
apply
(
vm
,
args
);
vm
.
__call_hook
(
'
onShow
'
,
args
);
});
}
if
(
isFn
(
appOptions
.
onHide
)
&&
qa
.
onAppHide
)
{
qa
.
onAppHide
((...
args
)
=>
{
appOptions
.
onHide
.
apply
(
vm
,
args
);
vm
.
__call_hook
(
'
onHide
'
,
args
);
});
}
if
(
isFn
(
appOptions
.
onLaunch
))
{
const
args
=
qa
.
getLaunchOptionsSync
&&
qa
.
getLaunchOptionsSync
();
appOptions
.
onLaunch
.
call
(
vm
,
args
);
vm
.
__call_hook
(
'
onLaunch
'
,
args
);
}
return
vm
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录