Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MuGuiLin
uni-app
提交
df9fc217
U
uni-app
项目概览
MuGuiLin
/
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,发现更多精彩内容 >>
提交
df9fc217
编写于
9月 28, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(mp): i18n
上级
ce314ac1
变更
22
展开全部
隐藏空白更改
内联
并排
Showing
22 changed file
with
1730 addition
and
1316 deletion
+1730
-1316
packages/uni-app-plus/dist/index.js
packages/uni-app-plus/dist/index.js
+163
-116
packages/uni-i18n/dist/uni-i18n.cjs.js
packages/uni-i18n/dist/uni-i18n.cjs.js
+69
-33
packages/uni-i18n/dist/uni-i18n.d.ts
packages/uni-i18n/dist/uni-i18n.d.ts
+4
-0
packages/uni-i18n/dist/uni-i18n.es.js
packages/uni-i18n/dist/uni-i18n.es.js
+69
-34
packages/uni-mp-alipay/dist/index.js
packages/uni-mp-alipay/dist/index.js
+205
-166
packages/uni-mp-alipay/dist/uni.api.esm.js
packages/uni-mp-alipay/dist/uni.api.esm.js
+7
-2
packages/uni-mp-alipay/dist/uni.mp.esm.js
packages/uni-mp-alipay/dist/uni.mp.esm.js
+4
-0
packages/uni-mp-baidu/dist/index.js
packages/uni-mp-baidu/dist/index.js
+201
-166
packages/uni-mp-baidu/dist/uni.api.esm.js
packages/uni-mp-baidu/dist/uni.api.esm.js
+7
-2
packages/uni-mp-kuaishou/dist/index.js
packages/uni-mp-kuaishou/dist/index.js
+201
-166
packages/uni-mp-kuaishou/dist/uni.api.esm.js
packages/uni-mp-kuaishou/dist/uni.api.esm.js
+7
-2
packages/uni-mp-qq/dist/index.js
packages/uni-mp-qq/dist/index.js
+206
-171
packages/uni-mp-qq/dist/uni.api.esm.js
packages/uni-mp-qq/dist/uni.api.esm.js
+7
-2
packages/uni-mp-toutiao/dist/index.js
packages/uni-mp-toutiao/dist/index.js
+201
-166
packages/uni-mp-toutiao/dist/uni.api.esm.js
packages/uni-mp-toutiao/dist/uni.api.esm.js
+7
-2
packages/uni-mp-weixin/dist/index.js
packages/uni-mp-weixin/dist/index.js
+206
-171
packages/uni-mp-weixin/dist/uni.api.esm.js
packages/uni-mp-weixin/dist/uni.api.esm.js
+7
-2
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
+146
-111
packages/uni-quickapp-webview/dist/uni.api.esm.js
packages/uni-quickapp-webview/dist/uni.api.esm.js
+7
-2
src/core/runtime/locale.js
src/core/runtime/locale.js
+4
-0
未找到文件。
packages/uni-app-plus/dist/index.js
浏览文件 @
df9fc217
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
(
''
))
}
...
...
@@ -431,6 +459,10 @@ function onLocaleChange (fn) {
if
(
onLocaleChangeCallbacks
.
indexOf
(
fn
)
===
-
1
)
{
onLocaleChangeCallbacks
.
push
(
fn
);
}
}
if
(
typeof
global
!==
'
undefined
'
)
{
global
.
getLocale
=
getLocale
;
}
const
interceptors
=
{
...
...
@@ -1304,7 +1336,9 @@ var en = {
"
uni.video.danmu
"
:
"
Danmu
"
,
"
uni.video.volume
"
:
"
Volume
"
,
"
uni.button.feedback.title
"
:
"
feedback
"
,
"
uni.button.feedback.send
"
:
"
send
"
"
uni.button.feedback.send
"
:
"
send
"
,
"
uni.chooseLocation.search
"
:
"
Find Place
"
,
"
uni.chooseLocation.cancel
"
:
"
Cancel
"
};
var
es
=
{
...
...
@@ -1337,7 +1371,9 @@ var es = {
"
uni.video.danmu
"
:
"
Danmu
"
,
"
uni.video.volume
"
:
"
Volumen
"
,
"
uni.button.feedback.title
"
:
"
realimentación
"
,
"
uni.button.feedback.send
"
:
"
enviar
"
"
uni.button.feedback.send
"
:
"
enviar
"
,
"
uni.chooseLocation.search
"
:
"
Encontrar
"
,
"
uni.chooseLocation.cancel
"
:
"
Cancelar
"
};
var
fr
=
{
...
...
@@ -1370,7 +1406,9 @@ var fr = {
"
uni.video.danmu
"
:
"
Danmu
"
,
"
uni.video.volume
"
:
"
Le Volume
"
,
"
uni.button.feedback.title
"
:
"
retour d'information
"
,
"
uni.button.feedback.send
"
:
"
envoyer
"
"
uni.button.feedback.send
"
:
"
envoyer
"
,
"
uni.chooseLocation.search
"
:
"
Trouve
"
,
"
uni.chooseLocation.cancel
"
:
"
Annuler
"
};
var
zhHans
=
{
...
...
@@ -1403,7 +1441,9 @@ var zhHans = {
"
uni.video.danmu
"
:
"
弹幕
"
,
"
uni.video.volume
"
:
"
音量
"
,
"
uni.button.feedback.title
"
:
"
问题反馈
"
,
"
uni.button.feedback.send
"
:
"
发送
"
"
uni.button.feedback.send
"
:
"
发送
"
,
"
uni.chooseLocation.search
"
:
"
搜索地点
"
,
"
uni.chooseLocation.cancel
"
:
"
取消
"
};
var
zhHant
=
{
...
...
@@ -1436,7 +1476,9 @@ var zhHant = {
"
uni.video.danmu
"
:
"
彈幕
"
,
"
uni.video.volume
"
:
"
音量
"
,
"
uni.button.feedback.title
"
:
"
問題反饋
"
,
"
uni.button.feedback.send
"
:
"
發送
"
"
uni.button.feedback.send
"
:
"
發送
"
,
"
uni.chooseLocation.search
"
:
"
搜索地點
"
,
"
uni.chooseLocation.cancel
"
:
"
取消
"
};
const
messages
=
{
...
...
@@ -1452,12 +1494,17 @@ let locale;
{
if
(
typeof
weex
===
'
object
'
)
{
locale
=
weex
.
requireModule
(
'
plus
'
).
getLanguage
();
}
else
{
locale
=
''
;
}
}
const
i18n
=
initVueI18n
(
locale
,
messages
);
const
i18n
=
initVueI18n
(
locale
,
messages
);
const
t
=
i18n
.
t
;
const
i18nMixin
=
i18n
.
mixin
=
{
const
i18nMixin
=
(
i18n
.
mixin
=
{
beforeCreate
()
{
const
unwatch
=
i18n
.
i18n
.
watchLocale
(()
=>
{
this
.
$forceUpdate
();
...
...
@@ -1471,7 +1518,7 @@ const i18nMixin = i18n.mixin = {
return
t
(
key
,
values
)
}
}
};
}
)
;
const
setLocale$1
=
i18n
.
setLocale
;
const
getLocale$1
=
i18n
.
getLocale
;
...
...
@@ -1480,7 +1527,7 @@ function initAppLocale (Vue, appVm, locale) {
locale
:
locale
||
i18n
.
getLocale
()
});
const
localeWatchers
=
[];
appVm
.
$watchLocale
=
(
fn
)
=>
{
appVm
.
$watchLocale
=
fn
=>
{
localeWatchers
.
push
(
fn
);
};
Object
.
defineProperty
(
appVm
,
'
$locale
'
,
{
...
...
@@ -1575,112 +1622,112 @@ function getEventChannel (id) {
return
eventChannelStack
.
shift
()
}
const
hooks
=
[
'
onShow
'
,
'
onHide
'
,
'
onError
'
,
'
onPageNotFound
'
,
'
onThemeChange
'
,
'
onUnhandledRejection
'
];
function
initEventChannel
()
{
Vue
.
prototype
.
getOpenerEventChannel
=
function
()
{
if
(
!
this
.
__eventChannel__
)
{
this
.
__eventChannel__
=
new
EventChannel
();
}
return
this
.
__eventChannel__
};
const
callHook
=
Vue
.
prototype
.
__call_hook
;
Vue
.
prototype
.
__call_hook
=
function
(
hook
,
args
)
{
if
(
hook
===
'
onLoad
'
&&
args
&&
args
.
__id__
)
{
this
.
__eventChannel__
=
getEventChannel
(
args
.
__id__
);
delete
args
.
__id__
;
}
return
callHook
.
call
(
this
,
hook
,
args
)
};
}
function
parseBaseApp
(
vm
,
{
mocks
,
initRefs
})
{
initEventChannel
();
if
(
vm
.
$options
.
store
)
{
Vue
.
prototype
.
$store
=
vm
.
$options
.
store
;
}
uniIdMixin
(
Vue
);
Vue
.
prototype
.
mpHost
=
"
app-plus
"
;
Vue
.
mixin
({
beforeCreate
()
{
if
(
!
this
.
$options
.
mpType
)
{
return
}
this
.
mpType
=
this
.
$options
.
mpType
;
this
.
$mp
=
{
data
:
{},
[
this
.
mpType
]:
this
.
$options
.
mpInstance
};
this
.
$scope
=
this
.
$options
.
mpInstance
;
delete
this
.
$options
.
mpType
;
delete
this
.
$options
.
mpInstance
;
if
(
this
.
mpType
===
'
page
'
&&
typeof
getApp
===
'
function
'
)
{
// hack vue-i18n
const
app
=
getApp
();
if
(
app
.
$vm
&&
app
.
$vm
.
$i18n
)
{
this
.
_i18n
=
app
.
$vm
.
$i18n
;
}
}
if
(
this
.
mpType
!==
'
app
'
)
{
initRefs
(
this
);
initMocks
(
this
,
mocks
);
}
}
});
const
appOptions
=
{
onLaunch
(
args
)
{
if
(
this
.
$vm
)
{
// 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return
}
this
.
$vm
=
vm
;
this
.
$vm
.
$mp
=
{
app
:
this
};
this
.
$vm
.
$scope
=
this
;
// vm 上也挂载 globalData
this
.
$vm
.
globalData
=
this
.
globalData
;
this
.
$vm
.
_isMounted
=
true
;
this
.
$vm
.
__call_hook
(
'
mounted
'
,
args
);
this
.
$vm
.
__call_hook
(
'
onLaunch
'
,
args
);
}
};
// 兼容旧版本 globalData
appOptions
.
globalData
=
vm
.
$options
.
globalData
||
{};
// 将 methods 中的方法挂在 getApp() 中
const
methods
=
vm
.
$options
.
methods
;
if
(
methods
)
{
Object
.
keys
(
methods
).
forEach
(
name
=>
{
appOptions
[
name
]
=
methods
[
name
];
});
}
initAppLocale
(
Vue
,
vm
,
wx
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
);
initHooks
(
appOptions
,
hooks
);
return
appOptions
const
hooks
=
[
'
onShow
'
,
'
onHide
'
,
'
onError
'
,
'
onPageNotFound
'
,
'
onThemeChange
'
,
'
onUnhandledRejection
'
];
function
initEventChannel
()
{
Vue
.
prototype
.
getOpenerEventChannel
=
function
()
{
if
(
!
this
.
__eventChannel__
)
{
this
.
__eventChannel__
=
new
EventChannel
();
}
return
this
.
__eventChannel__
};
const
callHook
=
Vue
.
prototype
.
__call_hook
;
Vue
.
prototype
.
__call_hook
=
function
(
hook
,
args
)
{
if
(
hook
===
'
onLoad
'
&&
args
&&
args
.
__id__
)
{
this
.
__eventChannel__
=
getEventChannel
(
args
.
__id__
);
delete
args
.
__id__
;
}
return
callHook
.
call
(
this
,
hook
,
args
)
};
}
function
parseBaseApp
(
vm
,
{
mocks
,
initRefs
})
{
initEventChannel
();
if
(
vm
.
$options
.
store
)
{
Vue
.
prototype
.
$store
=
vm
.
$options
.
store
;
}
uniIdMixin
(
Vue
);
Vue
.
prototype
.
mpHost
=
"
app-plus
"
;
Vue
.
mixin
({
beforeCreate
()
{
if
(
!
this
.
$options
.
mpType
)
{
return
}
this
.
mpType
=
this
.
$options
.
mpType
;
this
.
$mp
=
{
data
:
{},
[
this
.
mpType
]:
this
.
$options
.
mpInstance
};
this
.
$scope
=
this
.
$options
.
mpInstance
;
delete
this
.
$options
.
mpType
;
delete
this
.
$options
.
mpInstance
;
if
(
this
.
mpType
===
'
page
'
&&
typeof
getApp
===
'
function
'
)
{
// hack vue-i18n
const
app
=
getApp
();
if
(
app
.
$vm
&&
app
.
$vm
.
$i18n
)
{
this
.
_i18n
=
app
.
$vm
.
$i18n
;
}
}
if
(
this
.
mpType
!==
'
app
'
)
{
initRefs
(
this
);
initMocks
(
this
,
mocks
);
}
}
});
const
appOptions
=
{
onLaunch
(
args
)
{
if
(
this
.
$vm
)
{
// 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return
}
this
.
$vm
=
vm
;
this
.
$vm
.
$mp
=
{
app
:
this
};
this
.
$vm
.
$scope
=
this
;
// vm 上也挂载 globalData
this
.
$vm
.
globalData
=
this
.
globalData
;
this
.
$vm
.
_isMounted
=
true
;
this
.
$vm
.
__call_hook
(
'
mounted
'
,
args
);
this
.
$vm
.
__call_hook
(
'
onLaunch
'
,
args
);
}
};
// 兼容旧版本 globalData
appOptions
.
globalData
=
vm
.
$options
.
globalData
||
{};
// 将 methods 中的方法挂在 getApp() 中
const
methods
=
vm
.
$options
.
methods
;
if
(
methods
)
{
Object
.
keys
(
methods
).
forEach
(
name
=>
{
appOptions
[
name
]
=
methods
[
name
];
});
}
initAppLocale
(
Vue
,
vm
,
wx
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
);
initHooks
(
appOptions
,
hooks
);
return
appOptions
}
const
mocks
=
[
'
__route__
'
,
'
__wxExparserNodeId__
'
,
'
__wxWebviewId__
'
];
...
...
packages/uni-i18n/dist/uni-i18n.cjs.js
浏览文件 @
df9fc217
...
...
@@ -126,10 +126,10 @@ function normalizeLocale(locale, messages) {
}
locale
=
locale
.
toLowerCase
();
if
(
locale
.
indexOf
(
'
zh
'
)
===
0
)
{
if
(
locale
.
indexOf
(
'
-hans
'
)
!==
-
1
)
{
if
(
locale
.
indexOf
(
'
-hans
'
)
>
-
1
)
{
return
LOCALE_ZH_HANS
;
}
if
(
locale
.
indexOf
(
'
-hant
'
)
!==
-
1
)
{
if
(
locale
.
indexOf
(
'
-hant
'
)
>
-
1
)
{
return
LOCALE_ZH_HANT
;
}
if
(
include
(
locale
,
[
'
-tw
'
,
'
-hk
'
,
'
-mo
'
,
'
-cht
'
]))
{
...
...
@@ -221,11 +221,29 @@ class I18n {
}
}
const
ignoreVueI18n
=
true
;
function
watchAppLocale
(
appVm
,
i18n
)
{
appVm
.
$watch
(()
=>
appVm
.
$locale
,
(
newLocale
)
=>
{
i18n
.
setLocale
(
newLocale
);
});
// 需要保证 watch 的触发在组件渲染之前
if
(
appVm
.
$watchLocale
)
{
// vue2
appVm
.
$watchLocale
((
newLocale
)
=>
{
i18n
.
setLocale
(
newLocale
);
});
}
else
{
appVm
.
$watch
(()
=>
appVm
.
$locale
,
(
newLocale
)
=>
{
i18n
.
setLocale
(
newLocale
);
});
}
}
function
getDefaultLocale
()
{
if
(
typeof
uni
!==
'
undefined
'
&&
uni
.
getLocale
)
{
return
uni
.
getLocale
();
}
// 小程序平台,uni 和 uni-i18n 互相引用,导致访问不到 uni,故在 global 上挂了 getLocale
if
(
typeof
global
!==
'
undefined
'
&&
global
.
getLocale
)
{
return
global
.
getLocale
();
}
return
LOCALE_EN
;
}
function
initVueI18n
(
locale
,
messages
=
{},
fallbackLocale
,
watcher
)
{
// 兼容旧版本入参
...
...
@@ -236,9 +254,8 @@ function initVueI18n(locale, messages = {}, fallbackLocale, watcher) {
];
}
if
(
typeof
locale
!==
'
string
'
)
{
locale
=
(
typeof
uni
!==
'
undefined
'
&&
uni
.
getLocale
&&
uni
.
getLocale
())
||
LOCALE_EN
;
// 因为小程序平台,uni-i18n 和 uni 互相引用,导致此时访问 uni 时,为 undefined
locale
=
getDefaultLocale
();
}
if
(
typeof
fallbackLocale
!==
'
string
'
)
{
fallbackLocale
=
...
...
@@ -260,33 +277,32 @@ function initVueI18n(locale, messages = {}, fallbackLocale, watcher) {
};
}
else
{
const
appVm
=
getApp
().
$vm
;
watchAppLocale
(
appVm
,
i18n
);
if
(
!
appVm
.
$t
||
!
appVm
.
$i18n
||
ignoreVueI18n
)
{
// if (!locale) {
// i18n.setLocale(getDefaultLocale())
// }
/* eslint-disable no-func-assign */
t
=
function
(
key
,
values
)
{
let
isWatchedAppLocale
=
false
;
t
=
function
(
key
,
values
)
{
const
appVm
=
getApp
().
$vm
;
// 可能$vm还不存在,比如在支付宝小程序中,组件定义较早,在props的default里使用了t()函数(如uni-goods-nav),此时app还未初始化
// options: {
// type: Array,
// default () {
// return [{
// icon: 'shop',
// text: t("uni-goods-nav.options.shop"),
// }, {
// icon: 'cart',
// text: t("uni-goods-nav.options.cart")
// }]
// }
// },
if
(
appVm
)
{
// 触发响应式
appVm
.
$locale
;
return
i18n
.
t
(
key
,
values
);
};
}
else
{
/* eslint-disable no-func-assign */
t
=
function
(
key
,
values
)
{
const
$i18n
=
appVm
.
$i18n
;
const
silentTranslationWarn
=
$i18n
.
silentTranslationWarn
;
$i18n
.
silentTranslationWarn
=
true
;
const
msg
=
appVm
.
$t
(
key
,
values
);
$i18n
.
silentTranslationWarn
=
silentTranslationWarn
;
if
(
msg
!==
key
)
{
return
msg
;
if
(
!
isWatchedAppLocale
)
{
isWatchedAppLocale
=
true
;
watchAppLocale
(
appVm
,
i18n
);
}
return
i18n
.
t
(
key
,
$i18n
.
locale
,
values
);
}
;
}
}
return
i18n
.
t
(
key
,
values
)
;
}
;
}
return
t
(
key
,
values
);
};
...
...
@@ -420,6 +436,25 @@ function walkJsonObj(jsonObj, walk) {
return
false
;
}
function
resolveLocale
(
locales
)
{
return
(
locale
)
=>
{
if
(
!
locale
)
{
return
locale
;
}
locale
=
normalizeLocale
(
locale
)
||
locale
;
return
resolveLocaleChain
(
locale
).
find
((
locale
)
=>
locales
.
indexOf
(
locale
)
>
-
1
);
};
}
function
resolveLocaleChain
(
locale
)
{
const
chain
=
[];
const
tokens
=
locale
.
split
(
'
-
'
);
while
(
tokens
.
length
)
{
chain
.
push
(
tokens
.
join
(
'
-
'
));
tokens
.
pop
();
}
return
chain
;
}
exports
.
Formatter
=
BaseFormatter
;
exports
.
I18n
=
I18n
;
exports
.
LOCALE_EN
=
LOCALE_EN
;
...
...
@@ -434,3 +469,4 @@ exports.isI18nStr = isI18nStr;
exports
.
isString
=
isString
;
exports
.
normalizeLocale
=
normalizeLocale
;
exports
.
parseI18nJson
=
parseI18nJson
;
exports
.
resolveLocale
=
resolveLocale
;
packages/uni-i18n/dist/uni-i18n.d.ts
浏览文件 @
df9fc217
...
...
@@ -59,6 +59,8 @@ export declare function isI18nStr(value: string, delimiters: [string, string]):
export
declare
const
isString
:
(
val
:
unknown
)
=>
val
is
string
;
declare
type
Locale
=
string
;
export
declare
const
LOCALE_EN
=
"
en
"
;
export
declare
const
LOCALE_ES
=
"
es
"
;
...
...
@@ -77,6 +79,8 @@ export declare function normalizeLocale(locale: string, messages?: LocaleMessage
export
declare
function
parseI18nJson
(
jsonObj
:
unknown
,
values
:
Record
<
string
,
string
>
,
delimiters
:
[
string
,
string
]):
unknown
;
export
declare
function
resolveLocale
(
locales
:
Locale
[]):
(
locale
:
Locale
)
=>
string
|
undefined
;
declare
type
Token
=
{
type
:
'
text
'
|
'
named
'
|
'
list
'
|
'
unknown
'
;
value
:
string
;
...
...
packages/uni-i18n/dist/uni-i18n.es.js
浏览文件 @
df9fc217
...
...
@@ -122,10 +122,10 @@ function normalizeLocale(locale, messages) {
}
locale
=
locale
.
toLowerCase
();
if
(
locale
.
indexOf
(
'
zh
'
)
===
0
)
{
if
(
locale
.
indexOf
(
'
-hans
'
)
!==
-
1
)
{
if
(
locale
.
indexOf
(
'
-hans
'
)
>
-
1
)
{
return
LOCALE_ZH_HANS
;
}
if
(
locale
.
indexOf
(
'
-hant
'
)
!==
-
1
)
{
if
(
locale
.
indexOf
(
'
-hant
'
)
>
-
1
)
{
return
LOCALE_ZH_HANT
;
}
if
(
include
(
locale
,
[
'
-tw
'
,
'
-hk
'
,
'
-mo
'
,
'
-cht
'
]))
{
...
...
@@ -217,11 +217,29 @@ class I18n {
}
}
const
ignoreVueI18n
=
true
;
function
watchAppLocale
(
appVm
,
i18n
)
{
appVm
.
$watch
(()
=>
appVm
.
$locale
,
(
newLocale
)
=>
{
i18n
.
setLocale
(
newLocale
);
});
// 需要保证 watch 的触发在组件渲染之前
if
(
appVm
.
$watchLocale
)
{
// vue2
appVm
.
$watchLocale
((
newLocale
)
=>
{
i18n
.
setLocale
(
newLocale
);
});
}
else
{
appVm
.
$watch
(()
=>
appVm
.
$locale
,
(
newLocale
)
=>
{
i18n
.
setLocale
(
newLocale
);
});
}
}
function
getDefaultLocale
()
{
if
(
typeof
uni
!==
'
undefined
'
&&
uni
.
getLocale
)
{
return
uni
.
getLocale
();
}
// 小程序平台,uni 和 uni-i18n 互相引用,导致访问不到 uni,故在 global 上挂了 getLocale
if
(
typeof
global
!==
'
undefined
'
&&
global
.
getLocale
)
{
return
global
.
getLocale
();
}
return
LOCALE_EN
;
}
function
initVueI18n
(
locale
,
messages
=
{},
fallbackLocale
,
watcher
)
{
// 兼容旧版本入参
...
...
@@ -232,9 +250,8 @@ function initVueI18n(locale, messages = {}, fallbackLocale, watcher) {
];
}
if
(
typeof
locale
!==
'
string
'
)
{
locale
=
(
typeof
uni
!==
'
undefined
'
&&
uni
.
getLocale
&&
uni
.
getLocale
())
||
LOCALE_EN
;
// 因为小程序平台,uni-i18n 和 uni 互相引用,导致此时访问 uni 时,为 undefined
locale
=
getDefaultLocale
();
}
if
(
typeof
fallbackLocale
!==
'
string
'
)
{
fallbackLocale
=
...
...
@@ -256,33 +273,32 @@ function initVueI18n(locale, messages = {}, fallbackLocale, watcher) {
};
}
else
{
const
appVm
=
getApp
().
$vm
;
watchAppLocale
(
appVm
,
i18n
);
if
(
!
appVm
.
$t
||
!
appVm
.
$i18n
||
ignoreVueI18n
)
{
// if (!locale) {
// i18n.setLocale(getDefaultLocale())
// }
/* eslint-disable no-func-assign */
t
=
function
(
key
,
values
)
{
let
isWatchedAppLocale
=
false
;
t
=
function
(
key
,
values
)
{
const
appVm
=
getApp
().
$vm
;
// 可能$vm还不存在,比如在支付宝小程序中,组件定义较早,在props的default里使用了t()函数(如uni-goods-nav),此时app还未初始化
// options: {
// type: Array,
// default () {
// return [{
// icon: 'shop',
// text: t("uni-goods-nav.options.shop"),
// }, {
// icon: 'cart',
// text: t("uni-goods-nav.options.cart")
// }]
// }
// },
if
(
appVm
)
{
// 触发响应式
appVm
.
$locale
;
return
i18n
.
t
(
key
,
values
);
};
}
else
{
/* eslint-disable no-func-assign */
t
=
function
(
key
,
values
)
{
const
$i18n
=
appVm
.
$i18n
;
const
silentTranslationWarn
=
$i18n
.
silentTranslationWarn
;
$i18n
.
silentTranslationWarn
=
true
;
const
msg
=
appVm
.
$t
(
key
,
values
);
$i18n
.
silentTranslationWarn
=
silentTranslationWarn
;
if
(
msg
!==
key
)
{
return
msg
;
if
(
!
isWatchedAppLocale
)
{
isWatchedAppLocale
=
true
;
watchAppLocale
(
appVm
,
i18n
);
}
return
i18n
.
t
(
key
,
$i18n
.
locale
,
values
);
}
;
}
}
return
i18n
.
t
(
key
,
values
)
;
}
;
}
return
t
(
key
,
values
);
};
...
...
@@ -416,4 +432,23 @@ function walkJsonObj(jsonObj, walk) {
return
false
;
}
export
{
BaseFormatter
as
Formatter
,
I18n
,
LOCALE_EN
,
LOCALE_ES
,
LOCALE_FR
,
LOCALE_ZH_HANS
,
LOCALE_ZH_HANT
,
compileI18nJsonStr
,
hasI18nJson
,
initVueI18n
,
isI18nStr
,
isString
,
normalizeLocale
,
parseI18nJson
};
function
resolveLocale
(
locales
)
{
return
(
locale
)
=>
{
if
(
!
locale
)
{
return
locale
;
}
locale
=
normalizeLocale
(
locale
)
||
locale
;
return
resolveLocaleChain
(
locale
).
find
((
locale
)
=>
locales
.
indexOf
(
locale
)
>
-
1
);
};
}
function
resolveLocaleChain
(
locale
)
{
const
chain
=
[];
const
tokens
=
locale
.
split
(
'
-
'
);
while
(
tokens
.
length
)
{
chain
.
push
(
tokens
.
join
(
'
-
'
));
tokens
.
pop
();
}
return
chain
;
}
export
{
BaseFormatter
as
Formatter
,
I18n
,
LOCALE_EN
,
LOCALE_ES
,
LOCALE_FR
,
LOCALE_ZH_HANS
,
LOCALE_ZH_HANT
,
compileI18nJsonStr
,
hasI18nJson
,
initVueI18n
,
isI18nStr
,
isString
,
normalizeLocale
,
parseI18nJson
,
resolveLocale
};
packages/uni-mp-alipay/dist/index.js
浏览文件 @
df9fc217
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
(
''
))
}
...
...
@@ -431,6 +459,10 @@ function onLocaleChange (fn) {
if
(
onLocaleChangeCallbacks
.
indexOf
(
fn
)
===
-
1
)
{
onLocaleChangeCallbacks
.
push
(
fn
);
}
}
if
(
typeof
global
!==
'
undefined
'
)
{
global
.
getLocale
=
getLocale
;
}
const
interceptors
=
{
...
...
@@ -2025,9 +2057,12 @@ let locale;
locale
=
my
.
getSystemInfoSync
().
language
;
}
const
i18n
=
initVueI18n
(
locale
,
{});
const
i18n
=
initVueI18n
(
locale
,
{}
);
const
t
=
i18n
.
t
;
const
i18nMixin
=
i18n
.
mixin
=
{
const
i18nMixin
=
(
i18n
.
mixin
=
{
beforeCreate
()
{
const
unwatch
=
i18n
.
i18n
.
watchLocale
(()
=>
{
this
.
$forceUpdate
();
...
...
@@ -2041,7 +2076,7 @@ const i18nMixin = i18n.mixin = {
return
t
(
key
,
values
)
}
}
};
}
)
;
const
setLocale$1
=
i18n
.
setLocale
;
const
getLocale$1
=
i18n
.
getLocale
;
...
...
@@ -2050,7 +2085,7 @@ function initAppLocale (Vue, appVm, locale) {
locale
:
locale
||
i18n
.
getLocale
()
});
const
localeWatchers
=
[];
appVm
.
$watchLocale
=
(
fn
)
=>
{
appVm
.
$watchLocale
=
fn
=>
{
localeWatchers
.
push
(
fn
);
};
Object
.
defineProperty
(
appVm
,
'
$locale
'
,
{
...
...
@@ -2064,167 +2099,171 @@ function initAppLocale (Vue, appVm, locale) {
});
}
const
hooks
=
[
'
onShow
'
,
'
onHide
'
,
'
onError
'
,
'
onPageNotFound
'
,
'
onThemeChange
'
,
'
onUnhandledRejection
'
];
function
initEventChannel$1
()
{
Vue
.
prototype
.
getOpenerEventChannel
=
function
()
{
if
(
!
this
.
__eventChannel__
)
{
this
.
__eventChannel__
=
new
EventChannel
();
}
return
this
.
__eventChannel__
};
const
callHook
=
Vue
.
prototype
.
__call_hook
;
Vue
.
prototype
.
__call_hook
=
function
(
hook
,
args
)
{
if
(
hook
===
'
onLoad
'
&&
args
&&
args
.
__id__
)
{
this
.
__eventChannel__
=
getEventChannel
(
args
.
__id__
);
delete
args
.
__id__
;
}
return
callHook
.
call
(
this
,
hook
,
args
)
};
}
function
initScopedSlotsParams
()
{
const
center
=
{};
const
parents
=
{};
Vue
.
prototype
.
$hasScopedSlotsParams
=
function
(
vueId
)
{
const
has
=
center
[
vueId
];
if
(
!
has
)
{
parents
[
vueId
]
=
this
;
this
.
$on
(
'
hook:destory
'
,
()
=>
{
delete
parents
[
vueId
];
});
}
return
has
};
Vue
.
prototype
.
$getScopedSlotsParams
=
function
(
vueId
,
name
,
key
)
{
const
data
=
center
[
vueId
];
if
(
data
)
{
const
object
=
data
[
name
]
||
{};
return
key
?
object
[
key
]
:
object
}
else
{
parents
[
vueId
]
=
this
;
this
.
$on
(
'
hook:destory
'
,
()
=>
{
delete
parents
[
vueId
];
});
}
};
Vue
.
prototype
.
$setScopedSlotsParams
=
function
(
name
,
value
)
{
const
vueIds
=
this
.
$options
.
propsData
.
vueId
;
if
(
vueIds
)
{
const
vueId
=
vueIds
.
split
(
'
,
'
)[
0
];
const
object
=
center
[
vueId
]
=
center
[
vueId
]
||
{};
object
[
name
]
=
value
;
if
(
parents
[
vueId
])
{
parents
[
vueId
].
$forceUpdate
();
}
}
};
Vue
.
mixin
({
destroyed
()
{
const
propsData
=
this
.
$options
.
propsData
;
const
vueId
=
propsData
&&
propsData
.
vueId
;
if
(
vueId
)
{
delete
center
[
vueId
];
delete
parents
[
vueId
];
}
}
});
}
function
parseBaseApp
(
vm
,
{
mocks
,
initRefs
})
{
initEventChannel$1
();
{
initScopedSlotsParams
();
}
if
(
vm
.
$options
.
store
)
{
Vue
.
prototype
.
$store
=
vm
.
$options
.
store
;
}
uniIdMixin
(
Vue
);
Vue
.
prototype
.
mpHost
=
"
mp-alipay
"
;
Vue
.
mixin
({
beforeCreate
()
{
if
(
!
this
.
$options
.
mpType
)
{
return
}
this
.
mpType
=
this
.
$options
.
mpType
;
this
.
$mp
=
{
data
:
{},
[
this
.
mpType
]:
this
.
$options
.
mpInstance
};
this
.
$scope
=
this
.
$options
.
mpInstance
;
delete
this
.
$options
.
mpType
;
delete
this
.
$options
.
mpInstance
;
if
(
this
.
mpType
===
'
page
'
&&
typeof
getApp
===
'
function
'
)
{
// hack vue-i18n
const
app
=
getApp
();
if
(
app
.
$vm
&&
app
.
$vm
.
$i18n
)
{
this
.
_i18n
=
app
.
$vm
.
$i18n
;
}
}
if
(
this
.
mpType
!==
'
app
'
)
{
initRefs
(
this
);
initMocks
(
this
,
mocks
);
}
}
});
const
appOptions
=
{
onLaunch
(
args
)
{
if
(
this
.
$vm
)
{
// 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return
}
this
.
$vm
=
vm
;
this
.
$vm
.
$mp
=
{
app
:
this
};
this
.
$vm
.
$scope
=
this
;
// vm 上也挂载 globalData
this
.
$vm
.
globalData
=
this
.
globalData
;
this
.
$vm
.
_isMounted
=
true
;
this
.
$vm
.
__call_hook
(
'
mounted
'
,
args
);
this
.
$vm
.
__call_hook
(
'
onLaunch
'
,
args
);
}
};
// 兼容旧版本 globalData
appOptions
.
globalData
=
vm
.
$options
.
globalData
||
{};
// 将 methods 中的方法挂在 getApp() 中
const
methods
=
vm
.
$options
.
methods
;
if
(
methods
)
{
Object
.
keys
(
methods
).
forEach
(
name
=>
{
appOptions
[
name
]
=
methods
[
name
];
});
}
initAppLocale
(
Vue
,
vm
,
my
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
);
initHooks
(
appOptions
,
hooks
);
return
appOptions
const
hooks
=
[
'
onShow
'
,
'
onHide
'
,
'
onError
'
,
'
onPageNotFound
'
,
'
onThemeChange
'
,
'
onUnhandledRejection
'
];
{
hooks
.
push
(
'
onShareAppMessage
'
);
}
function
initEventChannel$1
()
{
Vue
.
prototype
.
getOpenerEventChannel
=
function
()
{
if
(
!
this
.
__eventChannel__
)
{
this
.
__eventChannel__
=
new
EventChannel
();
}
return
this
.
__eventChannel__
};
const
callHook
=
Vue
.
prototype
.
__call_hook
;
Vue
.
prototype
.
__call_hook
=
function
(
hook
,
args
)
{
if
(
hook
===
'
onLoad
'
&&
args
&&
args
.
__id__
)
{
this
.
__eventChannel__
=
getEventChannel
(
args
.
__id__
);
delete
args
.
__id__
;
}
return
callHook
.
call
(
this
,
hook
,
args
)
};
}
function
initScopedSlotsParams
()
{
const
center
=
{};
const
parents
=
{};
Vue
.
prototype
.
$hasScopedSlotsParams
=
function
(
vueId
)
{
const
has
=
center
[
vueId
];
if
(
!
has
)
{
parents
[
vueId
]
=
this
;
this
.
$on
(
'
hook:destory
'
,
()
=>
{
delete
parents
[
vueId
];
});
}
return
has
};
Vue
.
prototype
.
$getScopedSlotsParams
=
function
(
vueId
,
name
,
key
)
{
const
data
=
center
[
vueId
];
if
(
data
)
{
const
object
=
data
[
name
]
||
{};
return
key
?
object
[
key
]
:
object
}
else
{
parents
[
vueId
]
=
this
;
this
.
$on
(
'
hook:destory
'
,
()
=>
{
delete
parents
[
vueId
];
});
}
};
Vue
.
prototype
.
$setScopedSlotsParams
=
function
(
name
,
value
)
{
const
vueIds
=
this
.
$options
.
propsData
.
vueId
;
if
(
vueIds
)
{
const
vueId
=
vueIds
.
split
(
'
,
'
)[
0
];
const
object
=
center
[
vueId
]
=
center
[
vueId
]
||
{};
object
[
name
]
=
value
;
if
(
parents
[
vueId
])
{
parents
[
vueId
].
$forceUpdate
();
}
}
};
Vue
.
mixin
({
destroyed
()
{
const
propsData
=
this
.
$options
.
propsData
;
const
vueId
=
propsData
&&
propsData
.
vueId
;
if
(
vueId
)
{
delete
center
[
vueId
];
delete
parents
[
vueId
];
}
}
});
}
function
parseBaseApp
(
vm
,
{
mocks
,
initRefs
})
{
initEventChannel$1
();
{
initScopedSlotsParams
();
}
if
(
vm
.
$options
.
store
)
{
Vue
.
prototype
.
$store
=
vm
.
$options
.
store
;
}
uniIdMixin
(
Vue
);
Vue
.
prototype
.
mpHost
=
"
mp-alipay
"
;
Vue
.
mixin
({
beforeCreate
()
{
if
(
!
this
.
$options
.
mpType
)
{
return
}
this
.
mpType
=
this
.
$options
.
mpType
;
this
.
$mp
=
{
data
:
{},
[
this
.
mpType
]:
this
.
$options
.
mpInstance
};
this
.
$scope
=
this
.
$options
.
mpInstance
;
delete
this
.
$options
.
mpType
;
delete
this
.
$options
.
mpInstance
;
if
(
this
.
mpType
===
'
page
'
&&
typeof
getApp
===
'
function
'
)
{
// hack vue-i18n
const
app
=
getApp
();
if
(
app
.
$vm
&&
app
.
$vm
.
$i18n
)
{
this
.
_i18n
=
app
.
$vm
.
$i18n
;
}
}
if
(
this
.
mpType
!==
'
app
'
)
{
initRefs
(
this
);
initMocks
(
this
,
mocks
);
}
}
});
const
appOptions
=
{
onLaunch
(
args
)
{
if
(
this
.
$vm
)
{
// 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return
}
this
.
$vm
=
vm
;
this
.
$vm
.
$mp
=
{
app
:
this
};
this
.
$vm
.
$scope
=
this
;
// vm 上也挂载 globalData
this
.
$vm
.
globalData
=
this
.
globalData
;
this
.
$vm
.
_isMounted
=
true
;
this
.
$vm
.
__call_hook
(
'
mounted
'
,
args
);
this
.
$vm
.
__call_hook
(
'
onLaunch
'
,
args
);
}
};
// 兼容旧版本 globalData
appOptions
.
globalData
=
vm
.
$options
.
globalData
||
{};
// 将 methods 中的方法挂在 getApp() 中
const
methods
=
vm
.
$options
.
methods
;
if
(
methods
)
{
Object
.
keys
(
methods
).
forEach
(
name
=>
{
appOptions
[
name
]
=
methods
[
name
];
});
}
initAppLocale
(
Vue
,
vm
,
my
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
);
initHooks
(
appOptions
,
hooks
);
return
appOptions
}
function
findVmByVueId
(
vm
,
vuePid
)
{
...
...
packages/uni-mp-alipay/dist/uni.api.esm.js
浏览文件 @
df9fc217
...
...
@@ -473,7 +473,8 @@ const removeInterceptor = defineSyncApi(API_REMOVE_INTERCEPTOR, (method, interce
else
if
(
isPlainObject
(
method
))
{
removeInterceptorHook
(
globalInterceptors
,
method
);
}
},
RemoveInterceptorProtocol
);
},
RemoveInterceptorProtocol
);
const
interceptors
=
{};
const
API_ON
=
'
$on
'
;
const
OnProtocol
=
[
...
...
@@ -753,7 +754,10 @@ const onLocaleChange = (fn) => {
if
(
onLocaleChangeCallbacks
.
indexOf
(
fn
)
===
-
1
)
{
onLocaleChangeCallbacks
.
push
(
fn
);
}
};
};
if
(
typeof
global
!==
'
undefined
'
)
{
global
.
getLocale
=
getLocale
;
}
const
baseApis
=
{
$on
,
...
...
@@ -761,6 +765,7 @@ const baseApis = {
$once
,
$emit
,
upx2px
,
interceptors
,
addInterceptor
,
removeInterceptor
,
onAppLaunch
,
...
...
packages/uni-mp-alipay/dist/uni.mp.esm.js
浏览文件 @
df9fc217
...
...
@@ -55,6 +55,7 @@ const ON_TAB_ITEM_TAP = 'onTabItemTap';
const
ON_REACH_BOTTOM
=
'
onReachBottom
'
;
const
ON_PULL_DOWN_REFRESH
=
'
onPullDownRefresh
'
;
const
ON_ADD_TO_FAVORITES
=
'
onAddToFavorites
'
;
const
ON_SHARE_APP_MESSAGE
=
'
onShareAppMessage
'
;
class
EventChannel
{
constructor
(
id
,
events
)
{
...
...
@@ -557,6 +558,9 @@ const HOOKS = [
ON_PAGE_NOT_FOUND
,
ON_UNHANDLE_REJECTION
,
];
{
HOOKS
.
push
(
ON_SHARE_APP_MESSAGE
);
}
function
parseApp
(
instance
,
parseAppOptions
)
{
const
internalInstance
=
instance
.
$
;
const
appOptions
=
{
...
...
packages/uni-mp-baidu/dist/index.js
浏览文件 @
df9fc217
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
(
''
))
}
...
...
@@ -431,6 +459,10 @@ function onLocaleChange (fn) {
if
(
onLocaleChangeCallbacks
.
indexOf
(
fn
)
===
-
1
)
{
onLocaleChangeCallbacks
.
push
(
fn
);
}
}
if
(
typeof
global
!==
'
undefined
'
)
{
global
.
getLocale
=
getLocale
;
}
const
interceptors
=
{
...
...
@@ -1703,9 +1735,12 @@ let locale;
locale
=
swan
.
getSystemInfoSync
().
language
;
}
const
i18n
=
initVueI18n
(
locale
,
{});
const
i18n
=
initVueI18n
(
locale
,
{}
);
const
t
=
i18n
.
t
;
const
i18nMixin
=
i18n
.
mixin
=
{
const
i18nMixin
=
(
i18n
.
mixin
=
{
beforeCreate
()
{
const
unwatch
=
i18n
.
i18n
.
watchLocale
(()
=>
{
this
.
$forceUpdate
();
...
...
@@ -1719,7 +1754,7 @@ const i18nMixin = i18n.mixin = {
return
t
(
key
,
values
)
}
}
};
}
)
;
const
setLocale$1
=
i18n
.
setLocale
;
const
getLocale$1
=
i18n
.
getLocale
;
...
...
@@ -1728,7 +1763,7 @@ function initAppLocale (Vue, appVm, locale) {
locale
:
locale
||
i18n
.
getLocale
()
});
const
localeWatchers
=
[];
appVm
.
$watchLocale
=
(
fn
)
=>
{
appVm
.
$watchLocale
=
fn
=>
{
localeWatchers
.
push
(
fn
);
};
Object
.
defineProperty
(
appVm
,
'
$locale
'
,
{
...
...
@@ -1742,167 +1777,167 @@ function initAppLocale (Vue, appVm, locale) {
});
}
const
hooks
=
[
'
onShow
'
,
'
onHide
'
,
'
onError
'
,
'
onPageNotFound
'
,
'
onThemeChange
'
,
'
onUnhandledRejection
'
];
function
initEventChannel$1
()
{
Vue
.
prototype
.
getOpenerEventChannel
=
function
()
{
if
(
!
this
.
__eventChannel__
)
{
this
.
__eventChannel__
=
new
EventChannel
();
}
return
this
.
__eventChannel__
};
const
callHook
=
Vue
.
prototype
.
__call_hook
;
Vue
.
prototype
.
__call_hook
=
function
(
hook
,
args
)
{
if
(
hook
===
'
onLoad
'
&&
args
&&
args
.
__id__
)
{
this
.
__eventChannel__
=
getEventChannel
(
args
.
__id__
);
delete
args
.
__id__
;
}
return
callHook
.
call
(
this
,
hook
,
args
)
};
}
function
initScopedSlotsParams
()
{
const
center
=
{};
const
parents
=
{};
Vue
.
prototype
.
$hasScopedSlotsParams
=
function
(
vueId
)
{
const
has
=
center
[
vueId
];
if
(
!
has
)
{
parents
[
vueId
]
=
this
;
this
.
$on
(
'
hook:destory
'
,
()
=>
{
delete
parents
[
vueId
];
});
}
return
has
};
Vue
.
prototype
.
$getScopedSlotsParams
=
function
(
vueId
,
name
,
key
)
{
const
data
=
center
[
vueId
];
if
(
data
)
{
const
object
=
data
[
name
]
||
{};
return
key
?
object
[
key
]
:
object
}
else
{
parents
[
vueId
]
=
this
;
this
.
$on
(
'
hook:destory
'
,
()
=>
{
delete
parents
[
vueId
];
});
}
};
Vue
.
prototype
.
$setScopedSlotsParams
=
function
(
name
,
value
)
{
const
vueIds
=
this
.
$options
.
propsData
.
vueId
;
if
(
vueIds
)
{
const
vueId
=
vueIds
.
split
(
'
,
'
)[
0
];
const
object
=
center
[
vueId
]
=
center
[
vueId
]
||
{};
object
[
name
]
=
value
;
if
(
parents
[
vueId
])
{
parents
[
vueId
].
$forceUpdate
();
}
}
};
Vue
.
mixin
({
destroyed
()
{
const
propsData
=
this
.
$options
.
propsData
;
const
vueId
=
propsData
&&
propsData
.
vueId
;
if
(
vueId
)
{
delete
center
[
vueId
];
delete
parents
[
vueId
];
}
}
});
}
function
parseBaseApp
(
vm
,
{
mocks
,
initRefs
})
{
initEventChannel$1
();
{
initScopedSlotsParams
();
}
if
(
vm
.
$options
.
store
)
{
Vue
.
prototype
.
$store
=
vm
.
$options
.
store
;
}
uniIdMixin
(
Vue
);
Vue
.
prototype
.
mpHost
=
"
mp-baidu
"
;
Vue
.
mixin
({
beforeCreate
()
{
if
(
!
this
.
$options
.
mpType
)
{
return
}
this
.
mpType
=
this
.
$options
.
mpType
;
this
.
$mp
=
{
data
:
{},
[
this
.
mpType
]:
this
.
$options
.
mpInstance
};
this
.
$scope
=
this
.
$options
.
mpInstance
;
delete
this
.
$options
.
mpType
;
delete
this
.
$options
.
mpInstance
;
if
(
this
.
mpType
===
'
page
'
&&
typeof
getApp
===
'
function
'
)
{
// hack vue-i18n
const
app
=
getApp
();
if
(
app
.
$vm
&&
app
.
$vm
.
$i18n
)
{
this
.
_i18n
=
app
.
$vm
.
$i18n
;
}
}
if
(
this
.
mpType
!==
'
app
'
)
{
initRefs
(
this
);
initMocks
(
this
,
mocks
);
}
}
});
const
appOptions
=
{
onLaunch
(
args
)
{
if
(
this
.
$vm
)
{
// 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return
}
this
.
$vm
=
vm
;
this
.
$vm
.
$mp
=
{
app
:
this
};
this
.
$vm
.
$scope
=
this
;
// vm 上也挂载 globalData
this
.
$vm
.
globalData
=
this
.
globalData
;
this
.
$vm
.
_isMounted
=
true
;
this
.
$vm
.
__call_hook
(
'
mounted
'
,
args
);
this
.
$vm
.
__call_hook
(
'
onLaunch
'
,
args
);
}
};
// 兼容旧版本 globalData
appOptions
.
globalData
=
vm
.
$options
.
globalData
||
{};
// 将 methods 中的方法挂在 getApp() 中
const
methods
=
vm
.
$options
.
methods
;
if
(
methods
)
{
Object
.
keys
(
methods
).
forEach
(
name
=>
{
appOptions
[
name
]
=
methods
[
name
];
});
}
initAppLocale
(
Vue
,
vm
,
swan
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
);
initHooks
(
appOptions
,
hooks
);
return
appOptions
const
hooks
=
[
'
onShow
'
,
'
onHide
'
,
'
onError
'
,
'
onPageNotFound
'
,
'
onThemeChange
'
,
'
onUnhandledRejection
'
];
function
initEventChannel$1
()
{
Vue
.
prototype
.
getOpenerEventChannel
=
function
()
{
if
(
!
this
.
__eventChannel__
)
{
this
.
__eventChannel__
=
new
EventChannel
();
}
return
this
.
__eventChannel__
};
const
callHook
=
Vue
.
prototype
.
__call_hook
;
Vue
.
prototype
.
__call_hook
=
function
(
hook
,
args
)
{
if
(
hook
===
'
onLoad
'
&&
args
&&
args
.
__id__
)
{
this
.
__eventChannel__
=
getEventChannel
(
args
.
__id__
);
delete
args
.
__id__
;
}
return
callHook
.
call
(
this
,
hook
,
args
)
};
}
function
initScopedSlotsParams
()
{
const
center
=
{};
const
parents
=
{};
Vue
.
prototype
.
$hasScopedSlotsParams
=
function
(
vueId
)
{
const
has
=
center
[
vueId
];
if
(
!
has
)
{
parents
[
vueId
]
=
this
;
this
.
$on
(
'
hook:destory
'
,
()
=>
{
delete
parents
[
vueId
];
});
}
return
has
};
Vue
.
prototype
.
$getScopedSlotsParams
=
function
(
vueId
,
name
,
key
)
{
const
data
=
center
[
vueId
];
if
(
data
)
{
const
object
=
data
[
name
]
||
{};
return
key
?
object
[
key
]
:
object
}
else
{
parents
[
vueId
]
=
this
;
this
.
$on
(
'
hook:destory
'
,
()
=>
{
delete
parents
[
vueId
];
});
}
};
Vue
.
prototype
.
$setScopedSlotsParams
=
function
(
name
,
value
)
{
const
vueIds
=
this
.
$options
.
propsData
.
vueId
;
if
(
vueIds
)
{
const
vueId
=
vueIds
.
split
(
'
,
'
)[
0
];
const
object
=
center
[
vueId
]
=
center
[
vueId
]
||
{};
object
[
name
]
=
value
;
if
(
parents
[
vueId
])
{
parents
[
vueId
].
$forceUpdate
();
}
}
};
Vue
.
mixin
({
destroyed
()
{
const
propsData
=
this
.
$options
.
propsData
;
const
vueId
=
propsData
&&
propsData
.
vueId
;
if
(
vueId
)
{
delete
center
[
vueId
];
delete
parents
[
vueId
];
}
}
});
}
function
parseBaseApp
(
vm
,
{
mocks
,
initRefs
})
{
initEventChannel$1
();
{
initScopedSlotsParams
();
}
if
(
vm
.
$options
.
store
)
{
Vue
.
prototype
.
$store
=
vm
.
$options
.
store
;
}
uniIdMixin
(
Vue
);
Vue
.
prototype
.
mpHost
=
"
mp-baidu
"
;
Vue
.
mixin
({
beforeCreate
()
{
if
(
!
this
.
$options
.
mpType
)
{
return
}
this
.
mpType
=
this
.
$options
.
mpType
;
this
.
$mp
=
{
data
:
{},
[
this
.
mpType
]:
this
.
$options
.
mpInstance
};
this
.
$scope
=
this
.
$options
.
mpInstance
;
delete
this
.
$options
.
mpType
;
delete
this
.
$options
.
mpInstance
;
if
(
this
.
mpType
===
'
page
'
&&
typeof
getApp
===
'
function
'
)
{
// hack vue-i18n
const
app
=
getApp
();
if
(
app
.
$vm
&&
app
.
$vm
.
$i18n
)
{
this
.
_i18n
=
app
.
$vm
.
$i18n
;
}
}
if
(
this
.
mpType
!==
'
app
'
)
{
initRefs
(
this
);
initMocks
(
this
,
mocks
);
}
}
});
const
appOptions
=
{
onLaunch
(
args
)
{
if
(
this
.
$vm
)
{
// 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return
}
this
.
$vm
=
vm
;
this
.
$vm
.
$mp
=
{
app
:
this
};
this
.
$vm
.
$scope
=
this
;
// vm 上也挂载 globalData
this
.
$vm
.
globalData
=
this
.
globalData
;
this
.
$vm
.
_isMounted
=
true
;
this
.
$vm
.
__call_hook
(
'
mounted
'
,
args
);
this
.
$vm
.
__call_hook
(
'
onLaunch
'
,
args
);
}
};
// 兼容旧版本 globalData
appOptions
.
globalData
=
vm
.
$options
.
globalData
||
{};
// 将 methods 中的方法挂在 getApp() 中
const
methods
=
vm
.
$options
.
methods
;
if
(
methods
)
{
Object
.
keys
(
methods
).
forEach
(
name
=>
{
appOptions
[
name
]
=
methods
[
name
];
});
}
initAppLocale
(
Vue
,
vm
,
swan
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
);
initHooks
(
appOptions
,
hooks
);
return
appOptions
}
function
findVmByVueId
(
vm
,
vuePid
)
{
...
...
packages/uni-mp-baidu/dist/uni.api.esm.js
浏览文件 @
df9fc217
...
...
@@ -473,7 +473,8 @@ const removeInterceptor = defineSyncApi(API_REMOVE_INTERCEPTOR, (method, interce
else
if
(
isPlainObject
(
method
))
{
removeInterceptorHook
(
globalInterceptors
,
method
);
}
},
RemoveInterceptorProtocol
);
},
RemoveInterceptorProtocol
);
const
interceptors
=
{};
const
API_ON
=
'
$on
'
;
const
OnProtocol
=
[
...
...
@@ -753,7 +754,10 @@ const onLocaleChange = (fn) => {
if
(
onLocaleChangeCallbacks
.
indexOf
(
fn
)
===
-
1
)
{
onLocaleChangeCallbacks
.
push
(
fn
);
}
};
};
if
(
typeof
global
!==
'
undefined
'
)
{
global
.
getLocale
=
getLocale
;
}
const
baseApis
=
{
$on
,
...
...
@@ -761,6 +765,7 @@ const baseApis = {
$once
,
$emit
,
upx2px
,
interceptors
,
addInterceptor
,
removeInterceptor
,
onAppLaunch
,
...
...
packages/uni-mp-kuaishou/dist/index.js
浏览文件 @
df9fc217
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
(
''
))
}
...
...
@@ -431,6 +459,10 @@ function onLocaleChange (fn) {
if
(
onLocaleChangeCallbacks
.
indexOf
(
fn
)
===
-
1
)
{
onLocaleChangeCallbacks
.
push
(
fn
);
}
}
if
(
typeof
global
!==
'
undefined
'
)
{
global
.
getLocale
=
getLocale
;
}
const
interceptors
=
{
...
...
@@ -1452,9 +1484,12 @@ let locale;
locale
=
ks
.
getSystemInfoSync
().
language
;
}
const
i18n
=
initVueI18n
(
locale
,
{});
const
i18n
=
initVueI18n
(
locale
,
{}
);
const
t
=
i18n
.
t
;
const
i18nMixin
=
i18n
.
mixin
=
{
const
i18nMixin
=
(
i18n
.
mixin
=
{
beforeCreate
()
{
const
unwatch
=
i18n
.
i18n
.
watchLocale
(()
=>
{
this
.
$forceUpdate
();
...
...
@@ -1468,7 +1503,7 @@ const i18nMixin = i18n.mixin = {
return
t
(
key
,
values
)
}
}
};
}
)
;
const
setLocale$1
=
i18n
.
setLocale
;
const
getLocale$1
=
i18n
.
getLocale
;
...
...
@@ -1477,7 +1512,7 @@ function initAppLocale (Vue, appVm, locale) {
locale
:
locale
||
i18n
.
getLocale
()
});
const
localeWatchers
=
[];
appVm
.
$watchLocale
=
(
fn
)
=>
{
appVm
.
$watchLocale
=
fn
=>
{
localeWatchers
.
push
(
fn
);
};
Object
.
defineProperty
(
appVm
,
'
$locale
'
,
{
...
...
@@ -1491,167 +1526,167 @@ function initAppLocale (Vue, appVm, locale) {
});
}
const
hooks
=
[
'
onShow
'
,
'
onHide
'
,
'
onError
'
,
'
onPageNotFound
'
,
'
onThemeChange
'
,
'
onUnhandledRejection
'
];
function
initEventChannel$1
()
{
Vue
.
prototype
.
getOpenerEventChannel
=
function
()
{
if
(
!
this
.
__eventChannel__
)
{
this
.
__eventChannel__
=
new
EventChannel
();
}
return
this
.
__eventChannel__
};
const
callHook
=
Vue
.
prototype
.
__call_hook
;
Vue
.
prototype
.
__call_hook
=
function
(
hook
,
args
)
{
if
(
hook
===
'
onLoad
'
&&
args
&&
args
.
__id__
)
{
this
.
__eventChannel__
=
getEventChannel
(
args
.
__id__
);
delete
args
.
__id__
;
}
return
callHook
.
call
(
this
,
hook
,
args
)
};
}
function
initScopedSlotsParams
()
{
const
center
=
{};
const
parents
=
{};
Vue
.
prototype
.
$hasScopedSlotsParams
=
function
(
vueId
)
{
const
has
=
center
[
vueId
];
if
(
!
has
)
{
parents
[
vueId
]
=
this
;
this
.
$on
(
'
hook:destory
'
,
()
=>
{
delete
parents
[
vueId
];
});
}
return
has
};
Vue
.
prototype
.
$getScopedSlotsParams
=
function
(
vueId
,
name
,
key
)
{
const
data
=
center
[
vueId
];
if
(
data
)
{
const
object
=
data
[
name
]
||
{};
return
key
?
object
[
key
]
:
object
}
else
{
parents
[
vueId
]
=
this
;
this
.
$on
(
'
hook:destory
'
,
()
=>
{
delete
parents
[
vueId
];
});
}
};
Vue
.
prototype
.
$setScopedSlotsParams
=
function
(
name
,
value
)
{
const
vueIds
=
this
.
$options
.
propsData
.
vueId
;
if
(
vueIds
)
{
const
vueId
=
vueIds
.
split
(
'
,
'
)[
0
];
const
object
=
center
[
vueId
]
=
center
[
vueId
]
||
{};
object
[
name
]
=
value
;
if
(
parents
[
vueId
])
{
parents
[
vueId
].
$forceUpdate
();
}
}
};
Vue
.
mixin
({
destroyed
()
{
const
propsData
=
this
.
$options
.
propsData
;
const
vueId
=
propsData
&&
propsData
.
vueId
;
if
(
vueId
)
{
delete
center
[
vueId
];
delete
parents
[
vueId
];
}
}
});
}
function
parseBaseApp
(
vm
,
{
mocks
,
initRefs
})
{
initEventChannel$1
();
{
initScopedSlotsParams
();
}
if
(
vm
.
$options
.
store
)
{
Vue
.
prototype
.
$store
=
vm
.
$options
.
store
;
}
uniIdMixin
(
Vue
);
Vue
.
prototype
.
mpHost
=
"
mp-kuaishou
"
;
Vue
.
mixin
({
beforeCreate
()
{
if
(
!
this
.
$options
.
mpType
)
{
return
}
this
.
mpType
=
this
.
$options
.
mpType
;
this
.
$mp
=
{
data
:
{},
[
this
.
mpType
]:
this
.
$options
.
mpInstance
};
this
.
$scope
=
this
.
$options
.
mpInstance
;
delete
this
.
$options
.
mpType
;
delete
this
.
$options
.
mpInstance
;
if
(
this
.
mpType
===
'
page
'
&&
typeof
getApp
===
'
function
'
)
{
// hack vue-i18n
const
app
=
getApp
();
if
(
app
.
$vm
&&
app
.
$vm
.
$i18n
)
{
this
.
_i18n
=
app
.
$vm
.
$i18n
;
}
}
if
(
this
.
mpType
!==
'
app
'
)
{
initRefs
(
this
);
initMocks
(
this
,
mocks
);
}
}
});
const
appOptions
=
{
onLaunch
(
args
)
{
if
(
this
.
$vm
)
{
// 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return
}
this
.
$vm
=
vm
;
this
.
$vm
.
$mp
=
{
app
:
this
};
this
.
$vm
.
$scope
=
this
;
// vm 上也挂载 globalData
this
.
$vm
.
globalData
=
this
.
globalData
;
this
.
$vm
.
_isMounted
=
true
;
this
.
$vm
.
__call_hook
(
'
mounted
'
,
args
);
this
.
$vm
.
__call_hook
(
'
onLaunch
'
,
args
);
}
};
// 兼容旧版本 globalData
appOptions
.
globalData
=
vm
.
$options
.
globalData
||
{};
// 将 methods 中的方法挂在 getApp() 中
const
methods
=
vm
.
$options
.
methods
;
if
(
methods
)
{
Object
.
keys
(
methods
).
forEach
(
name
=>
{
appOptions
[
name
]
=
methods
[
name
];
});
}
initAppLocale
(
Vue
,
vm
,
ks
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
);
initHooks
(
appOptions
,
hooks
);
return
appOptions
const
hooks
=
[
'
onShow
'
,
'
onHide
'
,
'
onError
'
,
'
onPageNotFound
'
,
'
onThemeChange
'
,
'
onUnhandledRejection
'
];
function
initEventChannel$1
()
{
Vue
.
prototype
.
getOpenerEventChannel
=
function
()
{
if
(
!
this
.
__eventChannel__
)
{
this
.
__eventChannel__
=
new
EventChannel
();
}
return
this
.
__eventChannel__
};
const
callHook
=
Vue
.
prototype
.
__call_hook
;
Vue
.
prototype
.
__call_hook
=
function
(
hook
,
args
)
{
if
(
hook
===
'
onLoad
'
&&
args
&&
args
.
__id__
)
{
this
.
__eventChannel__
=
getEventChannel
(
args
.
__id__
);
delete
args
.
__id__
;
}
return
callHook
.
call
(
this
,
hook
,
args
)
};
}
function
initScopedSlotsParams
()
{
const
center
=
{};
const
parents
=
{};
Vue
.
prototype
.
$hasScopedSlotsParams
=
function
(
vueId
)
{
const
has
=
center
[
vueId
];
if
(
!
has
)
{
parents
[
vueId
]
=
this
;
this
.
$on
(
'
hook:destory
'
,
()
=>
{
delete
parents
[
vueId
];
});
}
return
has
};
Vue
.
prototype
.
$getScopedSlotsParams
=
function
(
vueId
,
name
,
key
)
{
const
data
=
center
[
vueId
];
if
(
data
)
{
const
object
=
data
[
name
]
||
{};
return
key
?
object
[
key
]
:
object
}
else
{
parents
[
vueId
]
=
this
;
this
.
$on
(
'
hook:destory
'
,
()
=>
{
delete
parents
[
vueId
];
});
}
};
Vue
.
prototype
.
$setScopedSlotsParams
=
function
(
name
,
value
)
{
const
vueIds
=
this
.
$options
.
propsData
.
vueId
;
if
(
vueIds
)
{
const
vueId
=
vueIds
.
split
(
'
,
'
)[
0
];
const
object
=
center
[
vueId
]
=
center
[
vueId
]
||
{};
object
[
name
]
=
value
;
if
(
parents
[
vueId
])
{
parents
[
vueId
].
$forceUpdate
();
}
}
};
Vue
.
mixin
({
destroyed
()
{
const
propsData
=
this
.
$options
.
propsData
;
const
vueId
=
propsData
&&
propsData
.
vueId
;
if
(
vueId
)
{
delete
center
[
vueId
];
delete
parents
[
vueId
];
}
}
});
}
function
parseBaseApp
(
vm
,
{
mocks
,
initRefs
})
{
initEventChannel$1
();
{
initScopedSlotsParams
();
}
if
(
vm
.
$options
.
store
)
{
Vue
.
prototype
.
$store
=
vm
.
$options
.
store
;
}
uniIdMixin
(
Vue
);
Vue
.
prototype
.
mpHost
=
"
mp-kuaishou
"
;
Vue
.
mixin
({
beforeCreate
()
{
if
(
!
this
.
$options
.
mpType
)
{
return
}
this
.
mpType
=
this
.
$options
.
mpType
;
this
.
$mp
=
{
data
:
{},
[
this
.
mpType
]:
this
.
$options
.
mpInstance
};
this
.
$scope
=
this
.
$options
.
mpInstance
;
delete
this
.
$options
.
mpType
;
delete
this
.
$options
.
mpInstance
;
if
(
this
.
mpType
===
'
page
'
&&
typeof
getApp
===
'
function
'
)
{
// hack vue-i18n
const
app
=
getApp
();
if
(
app
.
$vm
&&
app
.
$vm
.
$i18n
)
{
this
.
_i18n
=
app
.
$vm
.
$i18n
;
}
}
if
(
this
.
mpType
!==
'
app
'
)
{
initRefs
(
this
);
initMocks
(
this
,
mocks
);
}
}
});
const
appOptions
=
{
onLaunch
(
args
)
{
if
(
this
.
$vm
)
{
// 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return
}
this
.
$vm
=
vm
;
this
.
$vm
.
$mp
=
{
app
:
this
};
this
.
$vm
.
$scope
=
this
;
// vm 上也挂载 globalData
this
.
$vm
.
globalData
=
this
.
globalData
;
this
.
$vm
.
_isMounted
=
true
;
this
.
$vm
.
__call_hook
(
'
mounted
'
,
args
);
this
.
$vm
.
__call_hook
(
'
onLaunch
'
,
args
);
}
};
// 兼容旧版本 globalData
appOptions
.
globalData
=
vm
.
$options
.
globalData
||
{};
// 将 methods 中的方法挂在 getApp() 中
const
methods
=
vm
.
$options
.
methods
;
if
(
methods
)
{
Object
.
keys
(
methods
).
forEach
(
name
=>
{
appOptions
[
name
]
=
methods
[
name
];
});
}
initAppLocale
(
Vue
,
vm
,
ks
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
);
initHooks
(
appOptions
,
hooks
);
return
appOptions
}
const
mocks
=
[
'
__route__
'
,
'
__wxExparserNodeId__
'
,
'
__wxWebviewId__
'
];
...
...
packages/uni-mp-kuaishou/dist/uni.api.esm.js
浏览文件 @
df9fc217
...
...
@@ -473,7 +473,8 @@ const removeInterceptor = defineSyncApi(API_REMOVE_INTERCEPTOR, (method, interce
else
if
(
isPlainObject
(
method
))
{
removeInterceptorHook
(
globalInterceptors
,
method
);
}
},
RemoveInterceptorProtocol
);
},
RemoveInterceptorProtocol
);
const
interceptors
=
{};
const
API_ON
=
'
$on
'
;
const
OnProtocol
=
[
...
...
@@ -753,7 +754,10 @@ const onLocaleChange = (fn) => {
if
(
onLocaleChangeCallbacks
.
indexOf
(
fn
)
===
-
1
)
{
onLocaleChangeCallbacks
.
push
(
fn
);
}
};
};
if
(
typeof
global
!==
'
undefined
'
)
{
global
.
getLocale
=
getLocale
;
}
const
baseApis
=
{
$on
,
...
...
@@ -761,6 +765,7 @@ const baseApis = {
$once
,
$emit
,
upx2px
,
interceptors
,
addInterceptor
,
removeInterceptor
,
onAppLaunch
,
...
...
packages/uni-mp-qq/dist/index.js
浏览文件 @
df9fc217
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
(
''
))
}
...
...
@@ -431,6 +459,10 @@ function onLocaleChange (fn) {
if
(
onLocaleChangeCallbacks
.
indexOf
(
fn
)
===
-
1
)
{
onLocaleChangeCallbacks
.
push
(
fn
);
}
}
if
(
typeof
global
!==
'
undefined
'
)
{
global
.
getLocale
=
getLocale
;
}
const
interceptors
=
{
...
...
@@ -1613,9 +1645,12 @@ let locale;
locale
=
wx
.
getSystemInfoSync
().
language
;
}
const
i18n
=
initVueI18n
(
locale
,
{});
const
i18n
=
initVueI18n
(
locale
,
{}
);
const
t
=
i18n
.
t
;
const
i18nMixin
=
i18n
.
mixin
=
{
const
i18nMixin
=
(
i18n
.
mixin
=
{
beforeCreate
()
{
const
unwatch
=
i18n
.
i18n
.
watchLocale
(()
=>
{
this
.
$forceUpdate
();
...
...
@@ -1629,7 +1664,7 @@ const i18nMixin = i18n.mixin = {
return
t
(
key
,
values
)
}
}
};
}
)
;
const
setLocale$1
=
i18n
.
setLocale
;
const
getLocale$1
=
i18n
.
getLocale
;
...
...
@@ -1638,7 +1673,7 @@ function initAppLocale (Vue, appVm, locale) {
locale
:
locale
||
i18n
.
getLocale
()
});
const
localeWatchers
=
[];
appVm
.
$watchLocale
=
(
fn
)
=>
{
appVm
.
$watchLocale
=
fn
=>
{
localeWatchers
.
push
(
fn
);
};
Object
.
defineProperty
(
appVm
,
'
$locale
'
,
{
...
...
@@ -1652,172 +1687,172 @@ function initAppLocale (Vue, appVm, locale) {
});
}
const
hooks
=
[
'
onShow
'
,
'
onHide
'
,
'
onError
'
,
'
onPageNotFound
'
,
'
onThemeChange
'
,
'
onUnhandledRejection
'
];
function
initEventChannel$1
()
{
Vue
.
prototype
.
getOpenerEventChannel
=
function
()
{
if
(
!
this
.
__eventChannel__
)
{
this
.
__eventChannel__
=
new
EventChannel
();
}
return
this
.
__eventChannel__
};
const
callHook
=
Vue
.
prototype
.
__call_hook
;
Vue
.
prototype
.
__call_hook
=
function
(
hook
,
args
)
{
if
(
hook
===
'
onLoad
'
&&
args
&&
args
.
__id__
)
{
this
.
__eventChannel__
=
getEventChannel
(
args
.
__id__
);
delete
args
.
__id__
;
}
return
callHook
.
call
(
this
,
hook
,
args
)
};
}
function
initScopedSlotsParams
()
{
const
center
=
{};
const
parents
=
{};
Vue
.
prototype
.
$hasScopedSlotsParams
=
function
(
vueId
)
{
const
has
=
center
[
vueId
];
if
(
!
has
)
{
parents
[
vueId
]
=
this
;
this
.
$on
(
'
hook:destory
'
,
()
=>
{
delete
parents
[
vueId
];
});
}
return
has
};
Vue
.
prototype
.
$getScopedSlotsParams
=
function
(
vueId
,
name
,
key
)
{
const
data
=
center
[
vueId
];
if
(
data
)
{
const
object
=
data
[
name
]
||
{};
return
key
?
object
[
key
]
:
object
}
else
{
parents
[
vueId
]
=
this
;
this
.
$on
(
'
hook:destory
'
,
()
=>
{
delete
parents
[
vueId
];
});
}
};
Vue
.
prototype
.
$setScopedSlotsParams
=
function
(
name
,
value
)
{
const
vueIds
=
this
.
$options
.
propsData
.
vueId
;
if
(
vueIds
)
{
const
vueId
=
vueIds
.
split
(
'
,
'
)[
0
];
const
object
=
center
[
vueId
]
=
center
[
vueId
]
||
{};
object
[
name
]
=
value
;
if
(
parents
[
vueId
])
{
parents
[
vueId
].
$forceUpdate
();
}
}
};
Vue
.
mixin
({
destroyed
()
{
const
propsData
=
this
.
$options
.
propsData
;
const
vueId
=
propsData
&&
propsData
.
vueId
;
if
(
vueId
)
{
delete
center
[
vueId
];
delete
parents
[
vueId
];
}
}
});
}
function
parseBaseApp
(
vm
,
{
mocks
,
initRefs
})
{
initEventChannel$1
();
{
initScopedSlotsParams
();
}
if
(
vm
.
$options
.
store
)
{
Vue
.
prototype
.
$store
=
vm
.
$options
.
store
;
}
uniIdMixin
(
Vue
);
Vue
.
prototype
.
mpHost
=
"
mp-qq
"
;
Vue
.
mixin
({
beforeCreate
()
{
if
(
!
this
.
$options
.
mpType
)
{
return
}
this
.
mpType
=
this
.
$options
.
mpType
;
this
.
$mp
=
{
data
:
{},
[
this
.
mpType
]:
this
.
$options
.
mpInstance
};
this
.
$scope
=
this
.
$options
.
mpInstance
;
delete
this
.
$options
.
mpType
;
delete
this
.
$options
.
mpInstance
;
if
(
this
.
mpType
===
'
page
'
&&
typeof
getApp
===
'
function
'
)
{
// hack vue-i18n
const
app
=
getApp
();
if
(
app
.
$vm
&&
app
.
$vm
.
$i18n
)
{
this
.
_i18n
=
app
.
$vm
.
$i18n
;
}
}
if
(
this
.
mpType
!==
'
app
'
)
{
initRefs
(
this
);
initMocks
(
this
,
mocks
);
}
}
});
const
appOptions
=
{
onLaunch
(
args
)
{
if
(
this
.
$vm
)
{
// 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return
}
{
if
(
wx
.
canIUse
&&
!
wx
.
canIUse
(
'
nextTick
'
))
{
// 事实 上2.2.3 即可,简单使用 2.3.0 的 nextTick 判断
console
.
error
(
'
当前微信基础库版本过低,请将 微信开发者工具-详情-项目设置-调试基础库版本 更换为`2.3.0`以上
'
);
}
}
this
.
$vm
=
vm
;
this
.
$vm
.
$mp
=
{
app
:
this
};
this
.
$vm
.
$scope
=
this
;
// vm 上也挂载 globalData
this
.
$vm
.
globalData
=
this
.
globalData
;
this
.
$vm
.
_isMounted
=
true
;
this
.
$vm
.
__call_hook
(
'
mounted
'
,
args
);
this
.
$vm
.
__call_hook
(
'
onLaunch
'
,
args
);
}
};
// 兼容旧版本 globalData
appOptions
.
globalData
=
vm
.
$options
.
globalData
||
{};
// 将 methods 中的方法挂在 getApp() 中
const
methods
=
vm
.
$options
.
methods
;
if
(
methods
)
{
Object
.
keys
(
methods
).
forEach
(
name
=>
{
appOptions
[
name
]
=
methods
[
name
];
});
}
initAppLocale
(
Vue
,
vm
,
wx
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
);
initHooks
(
appOptions
,
hooks
);
return
appOptions
const
hooks
=
[
'
onShow
'
,
'
onHide
'
,
'
onError
'
,
'
onPageNotFound
'
,
'
onThemeChange
'
,
'
onUnhandledRejection
'
];
function
initEventChannel$1
()
{
Vue
.
prototype
.
getOpenerEventChannel
=
function
()
{
if
(
!
this
.
__eventChannel__
)
{
this
.
__eventChannel__
=
new
EventChannel
();
}
return
this
.
__eventChannel__
};
const
callHook
=
Vue
.
prototype
.
__call_hook
;
Vue
.
prototype
.
__call_hook
=
function
(
hook
,
args
)
{
if
(
hook
===
'
onLoad
'
&&
args
&&
args
.
__id__
)
{
this
.
__eventChannel__
=
getEventChannel
(
args
.
__id__
);
delete
args
.
__id__
;
}
return
callHook
.
call
(
this
,
hook
,
args
)
};
}
function
initScopedSlotsParams
()
{
const
center
=
{};
const
parents
=
{};
Vue
.
prototype
.
$hasScopedSlotsParams
=
function
(
vueId
)
{
const
has
=
center
[
vueId
];
if
(
!
has
)
{
parents
[
vueId
]
=
this
;
this
.
$on
(
'
hook:destory
'
,
()
=>
{
delete
parents
[
vueId
];
});
}
return
has
};
Vue
.
prototype
.
$getScopedSlotsParams
=
function
(
vueId
,
name
,
key
)
{
const
data
=
center
[
vueId
];
if
(
data
)
{
const
object
=
data
[
name
]
||
{};
return
key
?
object
[
key
]
:
object
}
else
{
parents
[
vueId
]
=
this
;
this
.
$on
(
'
hook:destory
'
,
()
=>
{
delete
parents
[
vueId
];
});
}
};
Vue
.
prototype
.
$setScopedSlotsParams
=
function
(
name
,
value
)
{
const
vueIds
=
this
.
$options
.
propsData
.
vueId
;
if
(
vueIds
)
{
const
vueId
=
vueIds
.
split
(
'
,
'
)[
0
];
const
object
=
center
[
vueId
]
=
center
[
vueId
]
||
{};
object
[
name
]
=
value
;
if
(
parents
[
vueId
])
{
parents
[
vueId
].
$forceUpdate
();
}
}
};
Vue
.
mixin
({
destroyed
()
{
const
propsData
=
this
.
$options
.
propsData
;
const
vueId
=
propsData
&&
propsData
.
vueId
;
if
(
vueId
)
{
delete
center
[
vueId
];
delete
parents
[
vueId
];
}
}
});
}
function
parseBaseApp
(
vm
,
{
mocks
,
initRefs
})
{
initEventChannel$1
();
{
initScopedSlotsParams
();
}
if
(
vm
.
$options
.
store
)
{
Vue
.
prototype
.
$store
=
vm
.
$options
.
store
;
}
uniIdMixin
(
Vue
);
Vue
.
prototype
.
mpHost
=
"
mp-qq
"
;
Vue
.
mixin
({
beforeCreate
()
{
if
(
!
this
.
$options
.
mpType
)
{
return
}
this
.
mpType
=
this
.
$options
.
mpType
;
this
.
$mp
=
{
data
:
{},
[
this
.
mpType
]:
this
.
$options
.
mpInstance
};
this
.
$scope
=
this
.
$options
.
mpInstance
;
delete
this
.
$options
.
mpType
;
delete
this
.
$options
.
mpInstance
;
if
(
this
.
mpType
===
'
page
'
&&
typeof
getApp
===
'
function
'
)
{
// hack vue-i18n
const
app
=
getApp
();
if
(
app
.
$vm
&&
app
.
$vm
.
$i18n
)
{
this
.
_i18n
=
app
.
$vm
.
$i18n
;
}
}
if
(
this
.
mpType
!==
'
app
'
)
{
initRefs
(
this
);
initMocks
(
this
,
mocks
);
}
}
});
const
appOptions
=
{
onLaunch
(
args
)
{
if
(
this
.
$vm
)
{
// 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return
}
{
if
(
wx
.
canIUse
&&
!
wx
.
canIUse
(
'
nextTick
'
))
{
// 事实 上2.2.3 即可,简单使用 2.3.0 的 nextTick 判断
console
.
error
(
'
当前微信基础库版本过低,请将 微信开发者工具-详情-项目设置-调试基础库版本 更换为`2.3.0`以上
'
);
}
}
this
.
$vm
=
vm
;
this
.
$vm
.
$mp
=
{
app
:
this
};
this
.
$vm
.
$scope
=
this
;
// vm 上也挂载 globalData
this
.
$vm
.
globalData
=
this
.
globalData
;
this
.
$vm
.
_isMounted
=
true
;
this
.
$vm
.
__call_hook
(
'
mounted
'
,
args
);
this
.
$vm
.
__call_hook
(
'
onLaunch
'
,
args
);
}
};
// 兼容旧版本 globalData
appOptions
.
globalData
=
vm
.
$options
.
globalData
||
{};
// 将 methods 中的方法挂在 getApp() 中
const
methods
=
vm
.
$options
.
methods
;
if
(
methods
)
{
Object
.
keys
(
methods
).
forEach
(
name
=>
{
appOptions
[
name
]
=
methods
[
name
];
});
}
initAppLocale
(
Vue
,
vm
,
wx
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
);
initHooks
(
appOptions
,
hooks
);
return
appOptions
}
const
mocks
=
[
'
__route__
'
,
'
__wxExparserNodeId__
'
,
'
__wxWebviewId__
'
];
...
...
packages/uni-mp-qq/dist/uni.api.esm.js
浏览文件 @
df9fc217
...
...
@@ -473,7 +473,8 @@ const removeInterceptor = defineSyncApi(API_REMOVE_INTERCEPTOR, (method, interce
else
if
(
isPlainObject
(
method
))
{
removeInterceptorHook
(
globalInterceptors
,
method
);
}
},
RemoveInterceptorProtocol
);
},
RemoveInterceptorProtocol
);
const
interceptors
=
{};
const
API_ON
=
'
$on
'
;
const
OnProtocol
=
[
...
...
@@ -753,7 +754,10 @@ const onLocaleChange = (fn) => {
if
(
onLocaleChangeCallbacks
.
indexOf
(
fn
)
===
-
1
)
{
onLocaleChangeCallbacks
.
push
(
fn
);
}
};
};
if
(
typeof
global
!==
'
undefined
'
)
{
global
.
getLocale
=
getLocale
;
}
const
baseApis
=
{
$on
,
...
...
@@ -761,6 +765,7 @@ const baseApis = {
$once
,
$emit
,
upx2px
,
interceptors
,
addInterceptor
,
removeInterceptor
,
onAppLaunch
,
...
...
packages/uni-mp-toutiao/dist/index.js
浏览文件 @
df9fc217
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
(
''
))
}
...
...
@@ -431,6 +459,10 @@ function onLocaleChange (fn) {
if
(
onLocaleChangeCallbacks
.
indexOf
(
fn
)
===
-
1
)
{
onLocaleChangeCallbacks
.
push
(
fn
);
}
}
if
(
typeof
global
!==
'
undefined
'
)
{
global
.
getLocale
=
getLocale
;
}
const
interceptors
=
{
...
...
@@ -1709,9 +1741,12 @@ let locale;
locale
=
tt
.
getSystemInfoSync
().
language
;
}
const
i18n
=
initVueI18n
(
locale
,
{});
const
i18n
=
initVueI18n
(
locale
,
{}
);
const
t
=
i18n
.
t
;
const
i18nMixin
=
i18n
.
mixin
=
{
const
i18nMixin
=
(
i18n
.
mixin
=
{
beforeCreate
()
{
const
unwatch
=
i18n
.
i18n
.
watchLocale
(()
=>
{
this
.
$forceUpdate
();
...
...
@@ -1725,7 +1760,7 @@ const i18nMixin = i18n.mixin = {
return
t
(
key
,
values
)
}
}
};
}
)
;
const
setLocale$1
=
i18n
.
setLocale
;
const
getLocale$1
=
i18n
.
getLocale
;
...
...
@@ -1734,7 +1769,7 @@ function initAppLocale (Vue, appVm, locale) {
locale
:
locale
||
i18n
.
getLocale
()
});
const
localeWatchers
=
[];
appVm
.
$watchLocale
=
(
fn
)
=>
{
appVm
.
$watchLocale
=
fn
=>
{
localeWatchers
.
push
(
fn
);
};
Object
.
defineProperty
(
appVm
,
'
$locale
'
,
{
...
...
@@ -1748,167 +1783,167 @@ function initAppLocale (Vue, appVm, locale) {
});
}
const
hooks
=
[
'
onShow
'
,
'
onHide
'
,
'
onError
'
,
'
onPageNotFound
'
,
'
onThemeChange
'
,
'
onUnhandledRejection
'
];
function
initEventChannel$1
()
{
Vue
.
prototype
.
getOpenerEventChannel
=
function
()
{
if
(
!
this
.
__eventChannel__
)
{
this
.
__eventChannel__
=
new
EventChannel
();
}
return
this
.
__eventChannel__
};
const
callHook
=
Vue
.
prototype
.
__call_hook
;
Vue
.
prototype
.
__call_hook
=
function
(
hook
,
args
)
{
if
(
hook
===
'
onLoad
'
&&
args
&&
args
.
__id__
)
{
this
.
__eventChannel__
=
getEventChannel
(
args
.
__id__
);
delete
args
.
__id__
;
}
return
callHook
.
call
(
this
,
hook
,
args
)
};
}
function
initScopedSlotsParams
()
{
const
center
=
{};
const
parents
=
{};
Vue
.
prototype
.
$hasScopedSlotsParams
=
function
(
vueId
)
{
const
has
=
center
[
vueId
];
if
(
!
has
)
{
parents
[
vueId
]
=
this
;
this
.
$on
(
'
hook:destory
'
,
()
=>
{
delete
parents
[
vueId
];
});
}
return
has
};
Vue
.
prototype
.
$getScopedSlotsParams
=
function
(
vueId
,
name
,
key
)
{
const
data
=
center
[
vueId
];
if
(
data
)
{
const
object
=
data
[
name
]
||
{};
return
key
?
object
[
key
]
:
object
}
else
{
parents
[
vueId
]
=
this
;
this
.
$on
(
'
hook:destory
'
,
()
=>
{
delete
parents
[
vueId
];
});
}
};
Vue
.
prototype
.
$setScopedSlotsParams
=
function
(
name
,
value
)
{
const
vueIds
=
this
.
$options
.
propsData
.
vueId
;
if
(
vueIds
)
{
const
vueId
=
vueIds
.
split
(
'
,
'
)[
0
];
const
object
=
center
[
vueId
]
=
center
[
vueId
]
||
{};
object
[
name
]
=
value
;
if
(
parents
[
vueId
])
{
parents
[
vueId
].
$forceUpdate
();
}
}
};
Vue
.
mixin
({
destroyed
()
{
const
propsData
=
this
.
$options
.
propsData
;
const
vueId
=
propsData
&&
propsData
.
vueId
;
if
(
vueId
)
{
delete
center
[
vueId
];
delete
parents
[
vueId
];
}
}
});
}
function
parseBaseApp
(
vm
,
{
mocks
,
initRefs
})
{
initEventChannel$1
();
{
initScopedSlotsParams
();
}
if
(
vm
.
$options
.
store
)
{
Vue
.
prototype
.
$store
=
vm
.
$options
.
store
;
}
uniIdMixin
(
Vue
);
Vue
.
prototype
.
mpHost
=
"
mp-toutiao
"
;
Vue
.
mixin
({
beforeCreate
()
{
if
(
!
this
.
$options
.
mpType
)
{
return
}
this
.
mpType
=
this
.
$options
.
mpType
;
this
.
$mp
=
{
data
:
{},
[
this
.
mpType
]:
this
.
$options
.
mpInstance
};
this
.
$scope
=
this
.
$options
.
mpInstance
;
delete
this
.
$options
.
mpType
;
delete
this
.
$options
.
mpInstance
;
if
(
this
.
mpType
===
'
page
'
&&
typeof
getApp
===
'
function
'
)
{
// hack vue-i18n
const
app
=
getApp
();
if
(
app
.
$vm
&&
app
.
$vm
.
$i18n
)
{
this
.
_i18n
=
app
.
$vm
.
$i18n
;
}
}
if
(
this
.
mpType
!==
'
app
'
)
{
initRefs
(
this
);
initMocks
(
this
,
mocks
);
}
}
});
const
appOptions
=
{
onLaunch
(
args
)
{
if
(
this
.
$vm
)
{
// 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return
}
this
.
$vm
=
vm
;
this
.
$vm
.
$mp
=
{
app
:
this
};
this
.
$vm
.
$scope
=
this
;
// vm 上也挂载 globalData
this
.
$vm
.
globalData
=
this
.
globalData
;
this
.
$vm
.
_isMounted
=
true
;
this
.
$vm
.
__call_hook
(
'
mounted
'
,
args
);
this
.
$vm
.
__call_hook
(
'
onLaunch
'
,
args
);
}
};
// 兼容旧版本 globalData
appOptions
.
globalData
=
vm
.
$options
.
globalData
||
{};
// 将 methods 中的方法挂在 getApp() 中
const
methods
=
vm
.
$options
.
methods
;
if
(
methods
)
{
Object
.
keys
(
methods
).
forEach
(
name
=>
{
appOptions
[
name
]
=
methods
[
name
];
});
}
initAppLocale
(
Vue
,
vm
,
tt
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
);
initHooks
(
appOptions
,
hooks
);
return
appOptions
const
hooks
=
[
'
onShow
'
,
'
onHide
'
,
'
onError
'
,
'
onPageNotFound
'
,
'
onThemeChange
'
,
'
onUnhandledRejection
'
];
function
initEventChannel$1
()
{
Vue
.
prototype
.
getOpenerEventChannel
=
function
()
{
if
(
!
this
.
__eventChannel__
)
{
this
.
__eventChannel__
=
new
EventChannel
();
}
return
this
.
__eventChannel__
};
const
callHook
=
Vue
.
prototype
.
__call_hook
;
Vue
.
prototype
.
__call_hook
=
function
(
hook
,
args
)
{
if
(
hook
===
'
onLoad
'
&&
args
&&
args
.
__id__
)
{
this
.
__eventChannel__
=
getEventChannel
(
args
.
__id__
);
delete
args
.
__id__
;
}
return
callHook
.
call
(
this
,
hook
,
args
)
};
}
function
initScopedSlotsParams
()
{
const
center
=
{};
const
parents
=
{};
Vue
.
prototype
.
$hasScopedSlotsParams
=
function
(
vueId
)
{
const
has
=
center
[
vueId
];
if
(
!
has
)
{
parents
[
vueId
]
=
this
;
this
.
$on
(
'
hook:destory
'
,
()
=>
{
delete
parents
[
vueId
];
});
}
return
has
};
Vue
.
prototype
.
$getScopedSlotsParams
=
function
(
vueId
,
name
,
key
)
{
const
data
=
center
[
vueId
];
if
(
data
)
{
const
object
=
data
[
name
]
||
{};
return
key
?
object
[
key
]
:
object
}
else
{
parents
[
vueId
]
=
this
;
this
.
$on
(
'
hook:destory
'
,
()
=>
{
delete
parents
[
vueId
];
});
}
};
Vue
.
prototype
.
$setScopedSlotsParams
=
function
(
name
,
value
)
{
const
vueIds
=
this
.
$options
.
propsData
.
vueId
;
if
(
vueIds
)
{
const
vueId
=
vueIds
.
split
(
'
,
'
)[
0
];
const
object
=
center
[
vueId
]
=
center
[
vueId
]
||
{};
object
[
name
]
=
value
;
if
(
parents
[
vueId
])
{
parents
[
vueId
].
$forceUpdate
();
}
}
};
Vue
.
mixin
({
destroyed
()
{
const
propsData
=
this
.
$options
.
propsData
;
const
vueId
=
propsData
&&
propsData
.
vueId
;
if
(
vueId
)
{
delete
center
[
vueId
];
delete
parents
[
vueId
];
}
}
});
}
function
parseBaseApp
(
vm
,
{
mocks
,
initRefs
})
{
initEventChannel$1
();
{
initScopedSlotsParams
();
}
if
(
vm
.
$options
.
store
)
{
Vue
.
prototype
.
$store
=
vm
.
$options
.
store
;
}
uniIdMixin
(
Vue
);
Vue
.
prototype
.
mpHost
=
"
mp-toutiao
"
;
Vue
.
mixin
({
beforeCreate
()
{
if
(
!
this
.
$options
.
mpType
)
{
return
}
this
.
mpType
=
this
.
$options
.
mpType
;
this
.
$mp
=
{
data
:
{},
[
this
.
mpType
]:
this
.
$options
.
mpInstance
};
this
.
$scope
=
this
.
$options
.
mpInstance
;
delete
this
.
$options
.
mpType
;
delete
this
.
$options
.
mpInstance
;
if
(
this
.
mpType
===
'
page
'
&&
typeof
getApp
===
'
function
'
)
{
// hack vue-i18n
const
app
=
getApp
();
if
(
app
.
$vm
&&
app
.
$vm
.
$i18n
)
{
this
.
_i18n
=
app
.
$vm
.
$i18n
;
}
}
if
(
this
.
mpType
!==
'
app
'
)
{
initRefs
(
this
);
initMocks
(
this
,
mocks
);
}
}
});
const
appOptions
=
{
onLaunch
(
args
)
{
if
(
this
.
$vm
)
{
// 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return
}
this
.
$vm
=
vm
;
this
.
$vm
.
$mp
=
{
app
:
this
};
this
.
$vm
.
$scope
=
this
;
// vm 上也挂载 globalData
this
.
$vm
.
globalData
=
this
.
globalData
;
this
.
$vm
.
_isMounted
=
true
;
this
.
$vm
.
__call_hook
(
'
mounted
'
,
args
);
this
.
$vm
.
__call_hook
(
'
onLaunch
'
,
args
);
}
};
// 兼容旧版本 globalData
appOptions
.
globalData
=
vm
.
$options
.
globalData
||
{};
// 将 methods 中的方法挂在 getApp() 中
const
methods
=
vm
.
$options
.
methods
;
if
(
methods
)
{
Object
.
keys
(
methods
).
forEach
(
name
=>
{
appOptions
[
name
]
=
methods
[
name
];
});
}
initAppLocale
(
Vue
,
vm
,
tt
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
);
initHooks
(
appOptions
,
hooks
);
return
appOptions
}
function
findVmByVueId
(
vm
,
vuePid
)
{
...
...
packages/uni-mp-toutiao/dist/uni.api.esm.js
浏览文件 @
df9fc217
...
...
@@ -473,7 +473,8 @@ const removeInterceptor = defineSyncApi(API_REMOVE_INTERCEPTOR, (method, interce
else
if
(
isPlainObject
(
method
))
{
removeInterceptorHook
(
globalInterceptors
,
method
);
}
},
RemoveInterceptorProtocol
);
},
RemoveInterceptorProtocol
);
const
interceptors
=
{};
const
API_ON
=
'
$on
'
;
const
OnProtocol
=
[
...
...
@@ -753,7 +754,10 @@ const onLocaleChange = (fn) => {
if
(
onLocaleChangeCallbacks
.
indexOf
(
fn
)
===
-
1
)
{
onLocaleChangeCallbacks
.
push
(
fn
);
}
};
};
if
(
typeof
global
!==
'
undefined
'
)
{
global
.
getLocale
=
getLocale
;
}
const
baseApis
=
{
$on
,
...
...
@@ -761,6 +765,7 @@ const baseApis = {
$once
,
$emit
,
upx2px
,
interceptors
,
addInterceptor
,
removeInterceptor
,
onAppLaunch
,
...
...
packages/uni-mp-weixin/dist/index.js
浏览文件 @
df9fc217
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
(
''
))
}
...
...
@@ -431,6 +459,10 @@ function onLocaleChange (fn) {
if
(
onLocaleChangeCallbacks
.
indexOf
(
fn
)
===
-
1
)
{
onLocaleChangeCallbacks
.
push
(
fn
);
}
}
if
(
typeof
global
!==
'
undefined
'
)
{
global
.
getLocale
=
getLocale
;
}
const
interceptors
=
{
...
...
@@ -1349,9 +1381,12 @@ let locale;
locale
=
wx
.
getSystemInfoSync
().
language
;
}
const
i18n
=
initVueI18n
(
locale
,
{});
const
i18n
=
initVueI18n
(
locale
,
{}
);
const
t
=
i18n
.
t
;
const
i18nMixin
=
i18n
.
mixin
=
{
const
i18nMixin
=
(
i18n
.
mixin
=
{
beforeCreate
()
{
const
unwatch
=
i18n
.
i18n
.
watchLocale
(()
=>
{
this
.
$forceUpdate
();
...
...
@@ -1365,7 +1400,7 @@ const i18nMixin = i18n.mixin = {
return
t
(
key
,
values
)
}
}
};
}
)
;
const
setLocale$1
=
i18n
.
setLocale
;
const
getLocale$1
=
i18n
.
getLocale
;
...
...
@@ -1374,7 +1409,7 @@ function initAppLocale (Vue, appVm, locale) {
locale
:
locale
||
i18n
.
getLocale
()
});
const
localeWatchers
=
[];
appVm
.
$watchLocale
=
(
fn
)
=>
{
appVm
.
$watchLocale
=
fn
=>
{
localeWatchers
.
push
(
fn
);
};
Object
.
defineProperty
(
appVm
,
'
$locale
'
,
{
...
...
@@ -1401,172 +1436,172 @@ function getEventChannel (id) {
return
eventChannelStack
.
shift
()
}
const
hooks
=
[
'
onShow
'
,
'
onHide
'
,
'
onError
'
,
'
onPageNotFound
'
,
'
onThemeChange
'
,
'
onUnhandledRejection
'
];
function
initEventChannel
()
{
Vue
.
prototype
.
getOpenerEventChannel
=
function
()
{
// 微信小程序使用自身getOpenerEventChannel
{
return
this
.
$scope
.
getOpenerEventChannel
()
}
};
const
callHook
=
Vue
.
prototype
.
__call_hook
;
Vue
.
prototype
.
__call_hook
=
function
(
hook
,
args
)
{
if
(
hook
===
'
onLoad
'
&&
args
&&
args
.
__id__
)
{
this
.
__eventChannel__
=
getEventChannel
(
args
.
__id__
);
delete
args
.
__id__
;
}
return
callHook
.
call
(
this
,
hook
,
args
)
};
}
function
initScopedSlotsParams
()
{
const
center
=
{};
const
parents
=
{};
Vue
.
prototype
.
$hasScopedSlotsParams
=
function
(
vueId
)
{
const
has
=
center
[
vueId
];
if
(
!
has
)
{
parents
[
vueId
]
=
this
;
this
.
$on
(
'
hook:destory
'
,
()
=>
{
delete
parents
[
vueId
];
});
}
return
has
};
Vue
.
prototype
.
$getScopedSlotsParams
=
function
(
vueId
,
name
,
key
)
{
const
data
=
center
[
vueId
];
if
(
data
)
{
const
object
=
data
[
name
]
||
{};
return
key
?
object
[
key
]
:
object
}
else
{
parents
[
vueId
]
=
this
;
this
.
$on
(
'
hook:destory
'
,
()
=>
{
delete
parents
[
vueId
];
});
}
};
Vue
.
prototype
.
$setScopedSlotsParams
=
function
(
name
,
value
)
{
const
vueIds
=
this
.
$options
.
propsData
.
vueId
;
if
(
vueIds
)
{
const
vueId
=
vueIds
.
split
(
'
,
'
)[
0
];
const
object
=
center
[
vueId
]
=
center
[
vueId
]
||
{};
object
[
name
]
=
value
;
if
(
parents
[
vueId
])
{
parents
[
vueId
].
$forceUpdate
();
}
}
};
Vue
.
mixin
({
destroyed
()
{
const
propsData
=
this
.
$options
.
propsData
;
const
vueId
=
propsData
&&
propsData
.
vueId
;
if
(
vueId
)
{
delete
center
[
vueId
];
delete
parents
[
vueId
];
}
}
});
}
function
parseBaseApp
(
vm
,
{
mocks
,
initRefs
})
{
initEventChannel
();
{
initScopedSlotsParams
();
}
if
(
vm
.
$options
.
store
)
{
Vue
.
prototype
.
$store
=
vm
.
$options
.
store
;
}
uniIdMixin
(
Vue
);
Vue
.
prototype
.
mpHost
=
"
mp-weixin
"
;
Vue
.
mixin
({
beforeCreate
()
{
if
(
!
this
.
$options
.
mpType
)
{
return
}
this
.
mpType
=
this
.
$options
.
mpType
;
this
.
$mp
=
{
data
:
{},
[
this
.
mpType
]:
this
.
$options
.
mpInstance
};
this
.
$scope
=
this
.
$options
.
mpInstance
;
delete
this
.
$options
.
mpType
;
delete
this
.
$options
.
mpInstance
;
if
(
this
.
mpType
===
'
page
'
&&
typeof
getApp
===
'
function
'
)
{
// hack vue-i18n
const
app
=
getApp
();
if
(
app
.
$vm
&&
app
.
$vm
.
$i18n
)
{
this
.
_i18n
=
app
.
$vm
.
$i18n
;
}
}
if
(
this
.
mpType
!==
'
app
'
)
{
initRefs
(
this
);
initMocks
(
this
,
mocks
);
}
}
});
const
appOptions
=
{
onLaunch
(
args
)
{
if
(
this
.
$vm
)
{
// 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return
}
{
if
(
wx
.
canIUse
&&
!
wx
.
canIUse
(
'
nextTick
'
))
{
// 事实 上2.2.3 即可,简单使用 2.3.0 的 nextTick 判断
console
.
error
(
'
当前微信基础库版本过低,请将 微信开发者工具-详情-项目设置-调试基础库版本 更换为`2.3.0`以上
'
);
}
}
this
.
$vm
=
vm
;
this
.
$vm
.
$mp
=
{
app
:
this
};
this
.
$vm
.
$scope
=
this
;
// vm 上也挂载 globalData
this
.
$vm
.
globalData
=
this
.
globalData
;
this
.
$vm
.
_isMounted
=
true
;
this
.
$vm
.
__call_hook
(
'
mounted
'
,
args
);
this
.
$vm
.
__call_hook
(
'
onLaunch
'
,
args
);
}
};
// 兼容旧版本 globalData
appOptions
.
globalData
=
vm
.
$options
.
globalData
||
{};
// 将 methods 中的方法挂在 getApp() 中
const
methods
=
vm
.
$options
.
methods
;
if
(
methods
)
{
Object
.
keys
(
methods
).
forEach
(
name
=>
{
appOptions
[
name
]
=
methods
[
name
];
});
}
initAppLocale
(
Vue
,
vm
,
wx
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
);
initHooks
(
appOptions
,
hooks
);
return
appOptions
const
hooks
=
[
'
onShow
'
,
'
onHide
'
,
'
onError
'
,
'
onPageNotFound
'
,
'
onThemeChange
'
,
'
onUnhandledRejection
'
];
function
initEventChannel
()
{
Vue
.
prototype
.
getOpenerEventChannel
=
function
()
{
// 微信小程序使用自身getOpenerEventChannel
{
return
this
.
$scope
.
getOpenerEventChannel
()
}
};
const
callHook
=
Vue
.
prototype
.
__call_hook
;
Vue
.
prototype
.
__call_hook
=
function
(
hook
,
args
)
{
if
(
hook
===
'
onLoad
'
&&
args
&&
args
.
__id__
)
{
this
.
__eventChannel__
=
getEventChannel
(
args
.
__id__
);
delete
args
.
__id__
;
}
return
callHook
.
call
(
this
,
hook
,
args
)
};
}
function
initScopedSlotsParams
()
{
const
center
=
{};
const
parents
=
{};
Vue
.
prototype
.
$hasScopedSlotsParams
=
function
(
vueId
)
{
const
has
=
center
[
vueId
];
if
(
!
has
)
{
parents
[
vueId
]
=
this
;
this
.
$on
(
'
hook:destory
'
,
()
=>
{
delete
parents
[
vueId
];
});
}
return
has
};
Vue
.
prototype
.
$getScopedSlotsParams
=
function
(
vueId
,
name
,
key
)
{
const
data
=
center
[
vueId
];
if
(
data
)
{
const
object
=
data
[
name
]
||
{};
return
key
?
object
[
key
]
:
object
}
else
{
parents
[
vueId
]
=
this
;
this
.
$on
(
'
hook:destory
'
,
()
=>
{
delete
parents
[
vueId
];
});
}
};
Vue
.
prototype
.
$setScopedSlotsParams
=
function
(
name
,
value
)
{
const
vueIds
=
this
.
$options
.
propsData
.
vueId
;
if
(
vueIds
)
{
const
vueId
=
vueIds
.
split
(
'
,
'
)[
0
];
const
object
=
center
[
vueId
]
=
center
[
vueId
]
||
{};
object
[
name
]
=
value
;
if
(
parents
[
vueId
])
{
parents
[
vueId
].
$forceUpdate
();
}
}
};
Vue
.
mixin
({
destroyed
()
{
const
propsData
=
this
.
$options
.
propsData
;
const
vueId
=
propsData
&&
propsData
.
vueId
;
if
(
vueId
)
{
delete
center
[
vueId
];
delete
parents
[
vueId
];
}
}
});
}
function
parseBaseApp
(
vm
,
{
mocks
,
initRefs
})
{
initEventChannel
();
{
initScopedSlotsParams
();
}
if
(
vm
.
$options
.
store
)
{
Vue
.
prototype
.
$store
=
vm
.
$options
.
store
;
}
uniIdMixin
(
Vue
);
Vue
.
prototype
.
mpHost
=
"
mp-weixin
"
;
Vue
.
mixin
({
beforeCreate
()
{
if
(
!
this
.
$options
.
mpType
)
{
return
}
this
.
mpType
=
this
.
$options
.
mpType
;
this
.
$mp
=
{
data
:
{},
[
this
.
mpType
]:
this
.
$options
.
mpInstance
};
this
.
$scope
=
this
.
$options
.
mpInstance
;
delete
this
.
$options
.
mpType
;
delete
this
.
$options
.
mpInstance
;
if
(
this
.
mpType
===
'
page
'
&&
typeof
getApp
===
'
function
'
)
{
// hack vue-i18n
const
app
=
getApp
();
if
(
app
.
$vm
&&
app
.
$vm
.
$i18n
)
{
this
.
_i18n
=
app
.
$vm
.
$i18n
;
}
}
if
(
this
.
mpType
!==
'
app
'
)
{
initRefs
(
this
);
initMocks
(
this
,
mocks
);
}
}
});
const
appOptions
=
{
onLaunch
(
args
)
{
if
(
this
.
$vm
)
{
// 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return
}
{
if
(
wx
.
canIUse
&&
!
wx
.
canIUse
(
'
nextTick
'
))
{
// 事实 上2.2.3 即可,简单使用 2.3.0 的 nextTick 判断
console
.
error
(
'
当前微信基础库版本过低,请将 微信开发者工具-详情-项目设置-调试基础库版本 更换为`2.3.0`以上
'
);
}
}
this
.
$vm
=
vm
;
this
.
$vm
.
$mp
=
{
app
:
this
};
this
.
$vm
.
$scope
=
this
;
// vm 上也挂载 globalData
this
.
$vm
.
globalData
=
this
.
globalData
;
this
.
$vm
.
_isMounted
=
true
;
this
.
$vm
.
__call_hook
(
'
mounted
'
,
args
);
this
.
$vm
.
__call_hook
(
'
onLaunch
'
,
args
);
}
};
// 兼容旧版本 globalData
appOptions
.
globalData
=
vm
.
$options
.
globalData
||
{};
// 将 methods 中的方法挂在 getApp() 中
const
methods
=
vm
.
$options
.
methods
;
if
(
methods
)
{
Object
.
keys
(
methods
).
forEach
(
name
=>
{
appOptions
[
name
]
=
methods
[
name
];
});
}
initAppLocale
(
Vue
,
vm
,
wx
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
);
initHooks
(
appOptions
,
hooks
);
return
appOptions
}
const
mocks
=
[
'
__route__
'
,
'
__wxExparserNodeId__
'
,
'
__wxWebviewId__
'
];
...
...
packages/uni-mp-weixin/dist/uni.api.esm.js
浏览文件 @
df9fc217
...
...
@@ -437,7 +437,8 @@ const removeInterceptor = defineSyncApi(API_REMOVE_INTERCEPTOR, (method, interce
else
if
(
isPlainObject
(
method
))
{
removeInterceptorHook
(
globalInterceptors
,
method
);
}
},
RemoveInterceptorProtocol
);
},
RemoveInterceptorProtocol
);
const
interceptors
=
{};
const
API_ON
=
'
$on
'
;
const
OnProtocol
=
[
...
...
@@ -717,7 +718,10 @@ const onLocaleChange = (fn) => {
if
(
onLocaleChangeCallbacks
.
indexOf
(
fn
)
===
-
1
)
{
onLocaleChangeCallbacks
.
push
(
fn
);
}
};
};
if
(
typeof
global
!==
'
undefined
'
)
{
global
.
getLocale
=
getLocale
;
}
const
baseApis
=
{
$on
,
...
...
@@ -725,6 +729,7 @@ const baseApis = {
$once
,
$emit
,
upx2px
,
interceptors
,
addInterceptor
,
removeInterceptor
,
onAppLaunch
,
...
...
packages/uni-quickapp-native/dist/vue.dev.js
浏览文件 @
df9fc217
此差异已折叠。
点击以展开。
packages/uni-quickapp-native/dist/vue.prod.js
浏览文件 @
df9fc217
此差异已折叠。
点击以展开。
packages/uni-quickapp-webview/dist/index.js
浏览文件 @
df9fc217
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
(
''
))
}
...
...
@@ -431,6 +459,10 @@ function onLocaleChange (fn) {
if
(
onLocaleChangeCallbacks
.
indexOf
(
fn
)
===
-
1
)
{
onLocaleChangeCallbacks
.
push
(
fn
);
}
}
if
(
typeof
global
!==
'
undefined
'
)
{
global
.
getLocale
=
getLocale
;
}
const
interceptors
=
{
...
...
@@ -1419,9 +1451,12 @@ let locale;
locale
=
qa
.
getSystemInfoSync
().
language
;
}
const
i18n
=
initVueI18n
(
locale
,
{});
const
i18n
=
initVueI18n
(
locale
,
{}
);
const
t
=
i18n
.
t
;
const
i18nMixin
=
i18n
.
mixin
=
{
const
i18nMixin
=
(
i18n
.
mixin
=
{
beforeCreate
()
{
const
unwatch
=
i18n
.
i18n
.
watchLocale
(()
=>
{
this
.
$forceUpdate
();
...
...
@@ -1435,7 +1470,7 @@ const i18nMixin = i18n.mixin = {
return
t
(
key
,
values
)
}
}
};
}
)
;
const
setLocale$1
=
i18n
.
setLocale
;
const
getLocale$1
=
i18n
.
getLocale
;
...
...
@@ -1444,7 +1479,7 @@ function initAppLocale (Vue, appVm, locale) {
locale
:
locale
||
i18n
.
getLocale
()
});
const
localeWatchers
=
[];
appVm
.
$watchLocale
=
(
fn
)
=>
{
appVm
.
$watchLocale
=
fn
=>
{
localeWatchers
.
push
(
fn
);
};
Object
.
defineProperty
(
appVm
,
'
$locale
'
,
{
...
...
@@ -1458,112 +1493,112 @@ function initAppLocale (Vue, appVm, locale) {
});
}
const
hooks
=
[
'
onShow
'
,
'
onHide
'
,
'
onError
'
,
'
onPageNotFound
'
,
'
onThemeChange
'
,
'
onUnhandledRejection
'
];
function
initEventChannel$1
()
{
Vue
.
prototype
.
getOpenerEventChannel
=
function
()
{
if
(
!
this
.
__eventChannel__
)
{
this
.
__eventChannel__
=
new
EventChannel
();
}
return
this
.
__eventChannel__
};
const
callHook
=
Vue
.
prototype
.
__call_hook
;
Vue
.
prototype
.
__call_hook
=
function
(
hook
,
args
)
{
if
(
hook
===
'
onLoad
'
&&
args
&&
args
.
__id__
)
{
this
.
__eventChannel__
=
getEventChannel
(
args
.
__id__
);
delete
args
.
__id__
;
}
return
callHook
.
call
(
this
,
hook
,
args
)
};
}
function
parseBaseApp
(
vm
,
{
mocks
,
initRefs
})
{
initEventChannel$1
();
if
(
vm
.
$options
.
store
)
{
Vue
.
prototype
.
$store
=
vm
.
$options
.
store
;
}
uniIdMixin
(
Vue
);
Vue
.
prototype
.
mpHost
=
"
quickapp-webview
"
;
Vue
.
mixin
({
beforeCreate
()
{
if
(
!
this
.
$options
.
mpType
)
{
return
}
this
.
mpType
=
this
.
$options
.
mpType
;
this
.
$mp
=
{
data
:
{},
[
this
.
mpType
]:
this
.
$options
.
mpInstance
};
this
.
$scope
=
this
.
$options
.
mpInstance
;
delete
this
.
$options
.
mpType
;
delete
this
.
$options
.
mpInstance
;
if
(
this
.
mpType
===
'
page
'
&&
typeof
getApp
===
'
function
'
)
{
// hack vue-i18n
const
app
=
getApp
();
if
(
app
.
$vm
&&
app
.
$vm
.
$i18n
)
{
this
.
_i18n
=
app
.
$vm
.
$i18n
;
}
}
if
(
this
.
mpType
!==
'
app
'
)
{
initRefs
(
this
);
initMocks
(
this
,
mocks
);
}
}
});
const
appOptions
=
{
onLaunch
(
args
)
{
if
(
this
.
$vm
)
{
// 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return
}
this
.
$vm
=
vm
;
this
.
$vm
.
$mp
=
{
app
:
this
};
this
.
$vm
.
$scope
=
this
;
// vm 上也挂载 globalData
this
.
$vm
.
globalData
=
this
.
globalData
;
this
.
$vm
.
_isMounted
=
true
;
this
.
$vm
.
__call_hook
(
'
mounted
'
,
args
);
this
.
$vm
.
__call_hook
(
'
onLaunch
'
,
args
);
}
};
// 兼容旧版本 globalData
appOptions
.
globalData
=
vm
.
$options
.
globalData
||
{};
// 将 methods 中的方法挂在 getApp() 中
const
methods
=
vm
.
$options
.
methods
;
if
(
methods
)
{
Object
.
keys
(
methods
).
forEach
(
name
=>
{
appOptions
[
name
]
=
methods
[
name
];
});
}
initAppLocale
(
Vue
,
vm
,
qa
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
);
initHooks
(
appOptions
,
hooks
);
return
appOptions
const
hooks
=
[
'
onShow
'
,
'
onHide
'
,
'
onError
'
,
'
onPageNotFound
'
,
'
onThemeChange
'
,
'
onUnhandledRejection
'
];
function
initEventChannel$1
()
{
Vue
.
prototype
.
getOpenerEventChannel
=
function
()
{
if
(
!
this
.
__eventChannel__
)
{
this
.
__eventChannel__
=
new
EventChannel
();
}
return
this
.
__eventChannel__
};
const
callHook
=
Vue
.
prototype
.
__call_hook
;
Vue
.
prototype
.
__call_hook
=
function
(
hook
,
args
)
{
if
(
hook
===
'
onLoad
'
&&
args
&&
args
.
__id__
)
{
this
.
__eventChannel__
=
getEventChannel
(
args
.
__id__
);
delete
args
.
__id__
;
}
return
callHook
.
call
(
this
,
hook
,
args
)
};
}
function
parseBaseApp
(
vm
,
{
mocks
,
initRefs
})
{
initEventChannel$1
();
if
(
vm
.
$options
.
store
)
{
Vue
.
prototype
.
$store
=
vm
.
$options
.
store
;
}
uniIdMixin
(
Vue
);
Vue
.
prototype
.
mpHost
=
"
quickapp-webview
"
;
Vue
.
mixin
({
beforeCreate
()
{
if
(
!
this
.
$options
.
mpType
)
{
return
}
this
.
mpType
=
this
.
$options
.
mpType
;
this
.
$mp
=
{
data
:
{},
[
this
.
mpType
]:
this
.
$options
.
mpInstance
};
this
.
$scope
=
this
.
$options
.
mpInstance
;
delete
this
.
$options
.
mpType
;
delete
this
.
$options
.
mpInstance
;
if
(
this
.
mpType
===
'
page
'
&&
typeof
getApp
===
'
function
'
)
{
// hack vue-i18n
const
app
=
getApp
();
if
(
app
.
$vm
&&
app
.
$vm
.
$i18n
)
{
this
.
_i18n
=
app
.
$vm
.
$i18n
;
}
}
if
(
this
.
mpType
!==
'
app
'
)
{
initRefs
(
this
);
initMocks
(
this
,
mocks
);
}
}
});
const
appOptions
=
{
onLaunch
(
args
)
{
if
(
this
.
$vm
)
{
// 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return
}
this
.
$vm
=
vm
;
this
.
$vm
.
$mp
=
{
app
:
this
};
this
.
$vm
.
$scope
=
this
;
// vm 上也挂载 globalData
this
.
$vm
.
globalData
=
this
.
globalData
;
this
.
$vm
.
_isMounted
=
true
;
this
.
$vm
.
__call_hook
(
'
mounted
'
,
args
);
this
.
$vm
.
__call_hook
(
'
onLaunch
'
,
args
);
}
};
// 兼容旧版本 globalData
appOptions
.
globalData
=
vm
.
$options
.
globalData
||
{};
// 将 methods 中的方法挂在 getApp() 中
const
methods
=
vm
.
$options
.
methods
;
if
(
methods
)
{
Object
.
keys
(
methods
).
forEach
(
name
=>
{
appOptions
[
name
]
=
methods
[
name
];
});
}
initAppLocale
(
Vue
,
vm
,
qa
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
);
initHooks
(
appOptions
,
hooks
);
return
appOptions
}
const
mocks
=
[
'
nodeId
'
,
'
componentName
'
,
'
_componentId
'
,
'
uniquePrefix
'
];
...
...
packages/uni-quickapp-webview/dist/uni.api.esm.js
浏览文件 @
df9fc217
...
...
@@ -473,7 +473,8 @@ const removeInterceptor = defineSyncApi(API_REMOVE_INTERCEPTOR, (method, interce
else
if
(
isPlainObject
(
method
))
{
removeInterceptorHook
(
globalInterceptors
,
method
);
}
},
RemoveInterceptorProtocol
);
},
RemoveInterceptorProtocol
);
const
interceptors
=
{};
const
API_ON
=
'
$on
'
;
const
OnProtocol
=
[
...
...
@@ -753,7 +754,10 @@ const onLocaleChange = (fn) => {
if
(
onLocaleChangeCallbacks
.
indexOf
(
fn
)
===
-
1
)
{
onLocaleChangeCallbacks
.
push
(
fn
);
}
};
};
if
(
typeof
global
!==
'
undefined
'
)
{
global
.
getLocale
=
getLocale
;
}
const
baseApis
=
{
$on
,
...
...
@@ -761,6 +765,7 @@ const baseApis = {
$once
,
$emit
,
upx2px
,
interceptors
,
addInterceptor
,
removeInterceptor
,
onAppLaunch
,
...
...
src/core/runtime/locale.js
浏览文件 @
df9fc217
...
...
@@ -30,4 +30,8 @@ export function onLocaleChange (fn) {
if
(
onLocaleChangeCallbacks
.
indexOf
(
fn
)
===
-
1
)
{
onLocaleChangeCallbacks
.
push
(
fn
)
}
}
if
(
typeof
global
!==
'
undefined
'
)
{
global
.
getLocale
=
getLocale
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录