Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
genary
uni-app
提交
52382584
U
uni-app
项目概览
genary
/
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,发现更多精彩内容 >>
提交
52382584
编写于
9月 02, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wip(i18n): mp
上级
5da9c336
变更
26
显示空白变更内容
内联
并排
Showing
26 changed file
with
353 addition
and
29 deletion
+353
-29
packages/uni-cloud/lib/uni.plugin.js
packages/uni-cloud/lib/uni.plugin.js
+2
-2
packages/uni-mp-alipay/build.json
packages/uni-mp-alipay/build.json
+2
-1
packages/uni-mp-alipay/dist/uni.api.esm.js
packages/uni-mp-alipay/dist/uni.api.esm.js
+30
-3
packages/uni-mp-alipay/dist/uni.mp.esm.js
packages/uni-mp-alipay/dist/uni.mp.esm.js
+13
-1
packages/uni-mp-baidu/build.json
packages/uni-mp-baidu/build.json
+2
-1
packages/uni-mp-baidu/dist/uni.api.esm.js
packages/uni-mp-baidu/dist/uni.api.esm.js
+30
-3
packages/uni-mp-baidu/dist/uni.mp.esm.js
packages/uni-mp-baidu/dist/uni.mp.esm.js
+13
-1
packages/uni-mp-core/src/api/index.ts
packages/uni-mp-core/src/api/index.ts
+4
-0
packages/uni-mp-core/src/api/locale.ts
packages/uni-mp-core/src/api/locale.ts
+26
-0
packages/uni-mp-core/src/api/promise.ts
packages/uni-mp-core/src/api/promise.ts
+1
-1
packages/uni-mp-core/src/runtime/app.ts
packages/uni-mp-core/src/runtime/app.ts
+15
-1
packages/uni-mp-kuaishou/build.json
packages/uni-mp-kuaishou/build.json
+2
-1
packages/uni-mp-kuaishou/dist/uni.api.esm.js
packages/uni-mp-kuaishou/dist/uni.api.esm.js
+28
-1
packages/uni-mp-kuaishou/dist/uni.mp.esm.js
packages/uni-mp-kuaishou/dist/uni.mp.esm.js
+13
-1
packages/uni-mp-qq/build.json
packages/uni-mp-qq/build.json
+2
-1
packages/uni-mp-qq/dist/uni.api.esm.js
packages/uni-mp-qq/dist/uni.api.esm.js
+28
-1
packages/uni-mp-qq/dist/uni.mp.esm.js
packages/uni-mp-qq/dist/uni.mp.esm.js
+13
-1
packages/uni-mp-toutiao/build.json
packages/uni-mp-toutiao/build.json
+2
-1
packages/uni-mp-toutiao/dist/uni.api.esm.js
packages/uni-mp-toutiao/dist/uni.api.esm.js
+28
-1
packages/uni-mp-toutiao/dist/uni.mp.esm.js
packages/uni-mp-toutiao/dist/uni.mp.esm.js
+13
-1
packages/uni-mp-weixin/build.json
packages/uni-mp-weixin/build.json
+2
-1
packages/uni-mp-weixin/dist/uni.api.esm.js
packages/uni-mp-weixin/dist/uni.api.esm.js
+28
-1
packages/uni-mp-weixin/dist/uni.mp.esm.js
packages/uni-mp-weixin/dist/uni.mp.esm.js
+13
-1
packages/uni-quickapp-webview/build.json
packages/uni-quickapp-webview/build.json
+2
-1
packages/uni-quickapp-webview/dist/uni.api.esm.js
packages/uni-quickapp-webview/dist/uni.api.esm.js
+28
-1
packages/uni-quickapp-webview/dist/uni.mp.esm.js
packages/uni-quickapp-webview/dist/uni.mp.esm.js
+13
-1
未找到文件。
packages/uni-cloud/lib/uni.plugin.js
浏览文件 @
52382584
...
@@ -67,7 +67,7 @@ function initUniCloudEnv() {
...
@@ -67,7 +67,7 @@ function initUniCloudEnv() {
process
.
env
.
UNI_CLOUD_PROVIDER
=
JSON
.
stringify
(
uniCloudSpaces
.
map
((
space
)
=>
{
process
.
env
.
UNI_CLOUD_PROVIDER
=
JSON
.
stringify
(
uniCloudSpaces
.
map
((
space
)
=>
{
if
(
space
.
clientSecret
)
{
if
(
space
.
clientSecret
)
{
return
{
return
{
provider
:
'
aliyun
'
,
provider
:
space
.
provider
||
'
aliyun
'
,
spaceName
:
space
.
name
,
spaceName
:
space
.
name
,
spaceId
:
space
.
id
,
spaceId
:
space
.
id
,
clientSecret
:
space
.
clientSecret
,
clientSecret
:
space
.
clientSecret
,
...
@@ -76,7 +76,7 @@ function initUniCloudEnv() {
...
@@ -76,7 +76,7 @@ function initUniCloudEnv() {
}
}
else
{
else
{
return
{
return
{
provider
:
'
tencent
'
,
provider
:
space
.
provider
||
'
tencent
'
,
spaceName
:
space
.
name
,
spaceName
:
space
.
name
,
spaceId
:
space
.
id
,
spaceId
:
space
.
id
,
};
};
...
...
packages/uni-mp-alipay/build.json
浏览文件 @
52382584
...
@@ -19,5 +19,6 @@
...
@@ -19,5 +19,6 @@
"__GLOBAL__"
:
"my"
,
"__GLOBAL__"
:
"my"
,
"__PLATFORM__"
:
"
\"
mp-alipay
\"
"
,
"__PLATFORM__"
:
"
\"
mp-alipay
\"
"
,
"__PLATFORM_TITLE__"
:
"支付宝小程序"
"__PLATFORM_TITLE__"
:
"支付宝小程序"
}
},
"external"
:
[
"@dcloudio/uni-i18n"
,
"@vue/shared"
,
"vue"
]
}
}
packages/uni-mp-alipay/dist/uni.api.esm.js
浏览文件 @
52382584
...
@@ -583,7 +583,7 @@ const $emit = defineSyncApi(API_EMIT, (name, ...args) => {
...
@@ -583,7 +583,7 @@ const $emit = defineSyncApi(API_EMIT, (name, ...args) => {
emitter
.
emit
(
name
,
...
args
);
emitter
.
emit
(
name
,
...
args
);
},
EmitProtocol
);
},
EmitProtocol
);
const
SYNC_API_RE
=
/^
\$
|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
;
const
SYNC_API_RE
=
/^
\$
|
getLocale|setLocale|
sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
// Context例外情况
// Context例外情况
const
CONTEXT_API_RE_EXC
=
[
'
createBLEConnection
'
];
const
CONTEXT_API_RE_EXC
=
[
'
createBLEConnection
'
];
...
@@ -727,6 +727,30 @@ function initWrapper(protocols) {
...
@@ -727,6 +727,30 @@ function initWrapper(protocols) {
};
};
}
}
const
getLocale
=
()
=>
{
// 优先使用 $locale
const
app
=
getApp
({
allowDefault
:
true
});
if
(
app
&&
app
.
$vm
)
{
return
app
.
$vm
.
$locale
;
}
return
uni
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
;
};
const
setLocale
=
(
locale
)
=>
{
const
oldLocale
=
getApp
().
$vm
.
$locale
;
if
(
oldLocale
!==
locale
)
{
getApp
().
$vm
.
$locale
=
locale
;
onLocaleChangeCallbacks
.
forEach
((
fn
)
=>
fn
({
locale
}));
return
true
;
}
return
false
;
};
const
onLocaleChangeCallbacks
=
[];
const
onLocaleChange
=
(
fn
)
=>
{
if
(
onLocaleChangeCallbacks
.
indexOf
(
fn
)
===
-
1
)
{
onLocaleChangeCallbacks
.
push
(
fn
);
}
};
const
baseApis
=
{
const
baseApis
=
{
$on
,
$on
,
$off
,
$off
,
...
@@ -736,6 +760,9 @@ const baseApis = {
...
@@ -736,6 +760,9 @@ const baseApis = {
addInterceptor
,
addInterceptor
,
removeInterceptor
,
removeInterceptor
,
onAppLaunch
,
onAppLaunch
,
getLocale
,
setLocale
,
onLocaleChange
,
};
};
function
initUni
(
api
,
protocols
)
{
function
initUni
(
api
,
protocols
)
{
const
wrapper
=
initWrapper
(
protocols
);
const
wrapper
=
initWrapper
(
protocols
);
...
...
packages/uni-mp-alipay/dist/uni.mp.esm.js
浏览文件 @
52382584
import
{
isPlainObject
,
isArray
,
extend
,
hyphenate
,
isObject
,
hasOwn
,
toNumber
,
capitalize
,
isFunction
,
NOOP
,
EMPTY_OBJ
,
camelize
}
from
'
@vue/shared
'
;
import
{
isPlainObject
,
isArray
,
extend
,
hyphenate
,
isObject
,
hasOwn
,
toNumber
,
capitalize
,
isFunction
,
NOOP
,
EMPTY_OBJ
,
camelize
}
from
'
@vue/shared
'
;
import
{
onUnmounted
,
injectHook
}
from
'
vue
'
;
import
{
onUnmounted
,
injectHook
,
ref
}
from
'
vue
'
;
const
encode
=
encodeURIComponent
;
const
encode
=
encodeURIComponent
;
function
stringifyQuery
(
obj
,
encodeStr
=
encode
)
{
function
stringifyQuery
(
obj
,
encodeStr
=
encode
)
{
...
@@ -578,6 +578,7 @@ function parseApp(instance, parseAppOptions) {
...
@@ -578,6 +578,7 @@ function parseApp(instance, parseAppOptions) {
instance
.
$callHook
(
ON_LAUNCH
,
extend
({
app
:
this
},
options
));
instance
.
$callHook
(
ON_LAUNCH
,
extend
({
app
:
this
},
options
));
},
},
};
};
initLocale
(
instance
);
const
vueOptions
=
instance
.
$
.
type
;
const
vueOptions
=
instance
.
$
.
type
;
initHooks
(
appOptions
,
HOOKS
);
initHooks
(
appOptions
,
HOOKS
);
initUnknownHooks
(
appOptions
,
vueOptions
);
initUnknownHooks
(
appOptions
,
vueOptions
);
...
@@ -595,6 +596,17 @@ function initCreateApp(parseAppOptions) {
...
@@ -595,6 +596,17 @@ function initCreateApp(parseAppOptions) {
return
App
(
parseApp
(
vm
,
parseAppOptions
));
return
App
(
parseApp
(
vm
,
parseAppOptions
));
};
};
}
}
function
initLocale
(
appVm
)
{
const
locale
=
ref
(
uni
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
);
Object
.
defineProperty
(
appVm
,
'
$locale
'
,
{
get
()
{
return
locale
.
value
;
},
set
(
v
)
{
locale
.
value
=
v
;
},
});
}
const
PROP_TYPES
=
[
String
,
Number
,
Boolean
,
Object
,
Array
,
null
];
const
PROP_TYPES
=
[
String
,
Number
,
Boolean
,
Object
,
Array
,
null
];
function
parsePropType
(
key
,
type
,
defaultValue
)
{
function
parsePropType
(
key
,
type
,
defaultValue
)
{
...
...
packages/uni-mp-baidu/build.json
浏览文件 @
52382584
...
@@ -19,5 +19,6 @@
...
@@ -19,5 +19,6 @@
"__GLOBAL__"
:
"swan"
,
"__GLOBAL__"
:
"swan"
,
"__PLATFORM__"
:
"
\"
mp-baidu
\"
"
,
"__PLATFORM__"
:
"
\"
mp-baidu
\"
"
,
"__PLATFORM_TITLE__"
:
"百度小程序"
"__PLATFORM_TITLE__"
:
"百度小程序"
}
},
"external"
:
[
"@dcloudio/uni-i18n"
,
"@vue/shared"
,
"vue"
]
}
}
packages/uni-mp-baidu/dist/uni.api.esm.js
浏览文件 @
52382584
...
@@ -583,7 +583,7 @@ const $emit = defineSyncApi(API_EMIT, (name, ...args) => {
...
@@ -583,7 +583,7 @@ const $emit = defineSyncApi(API_EMIT, (name, ...args) => {
emitter
.
emit
(
name
,
...
args
);
emitter
.
emit
(
name
,
...
args
);
},
EmitProtocol
);
},
EmitProtocol
);
const
SYNC_API_RE
=
/^
\$
|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
;
const
SYNC_API_RE
=
/^
\$
|
getLocale|setLocale|
sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
// Context例外情况
// Context例外情况
const
CONTEXT_API_RE_EXC
=
[
'
createBLEConnection
'
];
const
CONTEXT_API_RE_EXC
=
[
'
createBLEConnection
'
];
...
@@ -727,6 +727,30 @@ function initWrapper(protocols) {
...
@@ -727,6 +727,30 @@ function initWrapper(protocols) {
};
};
}
}
const
getLocale
=
()
=>
{
// 优先使用 $locale
const
app
=
getApp
({
allowDefault
:
true
});
if
(
app
&&
app
.
$vm
)
{
return
app
.
$vm
.
$locale
;
}
return
uni
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
;
};
const
setLocale
=
(
locale
)
=>
{
const
oldLocale
=
getApp
().
$vm
.
$locale
;
if
(
oldLocale
!==
locale
)
{
getApp
().
$vm
.
$locale
=
locale
;
onLocaleChangeCallbacks
.
forEach
((
fn
)
=>
fn
({
locale
}));
return
true
;
}
return
false
;
};
const
onLocaleChangeCallbacks
=
[];
const
onLocaleChange
=
(
fn
)
=>
{
if
(
onLocaleChangeCallbacks
.
indexOf
(
fn
)
===
-
1
)
{
onLocaleChangeCallbacks
.
push
(
fn
);
}
};
const
baseApis
=
{
const
baseApis
=
{
$on
,
$on
,
$off
,
$off
,
...
@@ -736,6 +760,9 @@ const baseApis = {
...
@@ -736,6 +760,9 @@ const baseApis = {
addInterceptor
,
addInterceptor
,
removeInterceptor
,
removeInterceptor
,
onAppLaunch
,
onAppLaunch
,
getLocale
,
setLocale
,
onLocaleChange
,
};
};
function
initUni
(
api
,
protocols
)
{
function
initUni
(
api
,
protocols
)
{
const
wrapper
=
initWrapper
(
protocols
);
const
wrapper
=
initWrapper
(
protocols
);
...
...
packages/uni-mp-baidu/dist/uni.mp.esm.js
浏览文件 @
52382584
import
{
isPlainObject
,
hasOwn
,
isArray
,
extend
,
hyphenate
,
isObject
,
toNumber
,
isFunction
,
NOOP
,
camelize
}
from
'
@vue/shared
'
;
import
{
isPlainObject
,
hasOwn
,
isArray
,
extend
,
hyphenate
,
isObject
,
toNumber
,
isFunction
,
NOOP
,
camelize
}
from
'
@vue/shared
'
;
import
{
onUnmounted
,
injectHook
}
from
'
vue
'
;
import
{
onUnmounted
,
injectHook
,
ref
}
from
'
vue
'
;
const
encode
=
encodeURIComponent
;
const
encode
=
encodeURIComponent
;
function
stringifyQuery
(
obj
,
encodeStr
=
encode
)
{
function
stringifyQuery
(
obj
,
encodeStr
=
encode
)
{
...
@@ -603,6 +603,7 @@ function parseApp(instance, parseAppOptions) {
...
@@ -603,6 +603,7 @@ function parseApp(instance, parseAppOptions) {
instance
.
$callHook
(
ON_LAUNCH
,
extend
({
app
:
this
},
options
));
instance
.
$callHook
(
ON_LAUNCH
,
extend
({
app
:
this
},
options
));
},
},
};
};
initLocale
(
instance
);
const
vueOptions
=
instance
.
$
.
type
;
const
vueOptions
=
instance
.
$
.
type
;
initHooks
(
appOptions
,
HOOKS
);
initHooks
(
appOptions
,
HOOKS
);
initUnknownHooks
(
appOptions
,
vueOptions
);
initUnknownHooks
(
appOptions
,
vueOptions
);
...
@@ -620,6 +621,17 @@ function initCreateApp(parseAppOptions) {
...
@@ -620,6 +621,17 @@ function initCreateApp(parseAppOptions) {
return
App
(
parseApp
(
vm
,
parseAppOptions
));
return
App
(
parseApp
(
vm
,
parseAppOptions
));
};
};
}
}
function
initLocale
(
appVm
)
{
const
locale
=
ref
(
uni
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
);
Object
.
defineProperty
(
appVm
,
'
$locale
'
,
{
get
()
{
return
locale
.
value
;
},
set
(
v
)
{
locale
.
value
=
v
;
},
});
}
const
PROP_TYPES
=
[
String
,
Number
,
Boolean
,
Object
,
Array
,
null
];
const
PROP_TYPES
=
[
String
,
Number
,
Boolean
,
Object
,
Array
,
null
];
function
createObserver
(
name
)
{
function
createObserver
(
name
)
{
...
...
packages/uni-mp-core/src/api/index.ts
浏览文件 @
52382584
...
@@ -16,6 +16,7 @@ import { initWrapper } from './wrapper'
...
@@ -16,6 +16,7 @@ import { initWrapper } from './wrapper'
import
{
MPProtocols
}
from
'
./protocols
'
import
{
MPProtocols
}
from
'
./protocols
'
import
{
onAppLaunch
}
from
'
./hook
'
import
{
onAppLaunch
}
from
'
./hook
'
import
{
getLocale
,
setLocale
,
onLocaleChange
}
from
'
./locale
'
const
baseApis
=
{
const
baseApis
=
{
$on
,
$on
,
...
@@ -26,6 +27,9 @@ const baseApis = {
...
@@ -26,6 +27,9 @@ const baseApis = {
addInterceptor
,
addInterceptor
,
removeInterceptor
,
removeInterceptor
,
onAppLaunch
,
onAppLaunch
,
getLocale
,
setLocale
,
onLocaleChange
,
}
}
export
function
initUni
(
api
:
Record
<
string
,
any
>
,
protocols
:
MPProtocols
)
{
export
function
initUni
(
api
:
Record
<
string
,
any
>
,
protocols
:
MPProtocols
)
{
...
...
packages/uni-mp-core/src/api/locale.ts
0 → 100644
浏览文件 @
52382584
export
const
getLocale
:
typeof
uni
.
getLocale
=
()
=>
{
// 优先使用 $locale
const
app
=
getApp
({
allowDefault
:
true
})
if
(
app
&&
app
.
$vm
)
{
return
app
.
$vm
.
$locale
}
return
uni
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
}
export
const
setLocale
:
typeof
uni
.
setLocale
=
(
locale
)
=>
{
const
oldLocale
=
getApp
().
$vm
.
$locale
if
(
oldLocale
!==
locale
)
{
getApp
().
$vm
.
$locale
=
locale
onLocaleChangeCallbacks
.
forEach
((
fn
)
=>
fn
({
locale
}))
return
true
}
return
false
}
type
OnLocaleCHangeCallback
=
Parameters
<
typeof
uni
.
onLocaleChange
>
[
0
]
const
onLocaleChangeCallbacks
:
OnLocaleCHangeCallback
[]
=
[]
export
const
onLocaleChange
:
typeof
uni
.
onLocaleChange
=
(
fn
)
=>
{
if
(
onLocaleChangeCallbacks
.
indexOf
(
fn
)
===
-
1
)
{
onLocaleChangeCallbacks
.
push
(
fn
)
}
}
packages/uni-mp-core/src/api/promise.ts
浏览文件 @
52382584
...
@@ -7,7 +7,7 @@ import {
...
@@ -7,7 +7,7 @@ import {
}
from
'
@dcloudio/uni-api/src/helpers/interceptor
'
}
from
'
@dcloudio/uni-api/src/helpers/interceptor
'
const
SYNC_API_RE
=
const
SYNC_API_RE
=
/^
\$
|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
/^
\$
|
getLocale|setLocale|
sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
const
CONTEXT_API_RE
=
/^create|Manager$/
const
CONTEXT_API_RE
=
/^create|Manager$/
...
...
packages/uni-mp-core/src/runtime/app.ts
浏览文件 @
52382584
import
{
extend
}
from
'
@vue/shared
'
import
{
extend
}
from
'
@vue/shared
'
import
{
ComponentPublicInstance
,
ComponentOptions
}
from
'
vue
'
import
{
ComponentPublicInstance
,
ComponentOptions
,
ref
}
from
'
vue
'
import
{
initBaseInstance
}
from
'
./componentInstance
'
import
{
initBaseInstance
}
from
'
./componentInstance
'
import
{
initHooks
,
initUnknownHooks
}
from
'
./componentHooks
'
import
{
initHooks
,
initUnknownHooks
}
from
'
./componentHooks
'
...
@@ -65,6 +65,8 @@ function parseApp(
...
@@ -65,6 +65,8 @@ function parseApp(
},
},
}
}
initLocale
(
instance
)
const
vueOptions
=
instance
.
$
.
type
as
ComponentOptions
const
vueOptions
=
instance
.
$
.
type
as
ComponentOptions
initHooks
(
appOptions
,
HOOKS
)
initHooks
(
appOptions
,
HOOKS
)
...
@@ -87,3 +89,15 @@ export function initCreateApp(parseAppOptions?: ParseAppOptions) {
...
@@ -87,3 +89,15 @@ export function initCreateApp(parseAppOptions?: ParseAppOptions) {
return
App
(
parseApp
(
vm
,
parseAppOptions
))
return
App
(
parseApp
(
vm
,
parseAppOptions
))
}
}
}
}
function
initLocale
(
appVm
:
ComponentPublicInstance
)
{
const
locale
=
ref
<
string
>
(
uni
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
)
Object
.
defineProperty
(
appVm
,
'
$locale
'
,
{
get
()
{
return
locale
.
value
},
set
(
v
)
{
locale
.
value
=
v
},
})
}
packages/uni-mp-kuaishou/build.json
浏览文件 @
52382584
...
@@ -19,5 +19,6 @@
...
@@ -19,5 +19,6 @@
"__GLOBAL__"
:
"ks"
,
"__GLOBAL__"
:
"ks"
,
"__PLATFORM__"
:
"
\"
mp-kuaishou
\"
"
,
"__PLATFORM__"
:
"
\"
mp-kuaishou
\"
"
,
"__PLATFORM_TITLE__"
:
"快手小程序"
"__PLATFORM_TITLE__"
:
"快手小程序"
}
},
"external"
:
[
"@dcloudio/uni-i18n"
,
"@vue/shared"
,
"vue"
]
}
}
packages/uni-mp-kuaishou/dist/uni.api.esm.js
浏览文件 @
52382584
...
@@ -583,7 +583,7 @@ const $emit = defineSyncApi(API_EMIT, (name, ...args) => {
...
@@ -583,7 +583,7 @@ const $emit = defineSyncApi(API_EMIT, (name, ...args) => {
emitter
.
emit
(
name
,
...
args
);
emitter
.
emit
(
name
,
...
args
);
},
EmitProtocol
);
},
EmitProtocol
);
const
SYNC_API_RE
=
/^
\$
|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
;
const
SYNC_API_RE
=
/^
\$
|
getLocale|setLocale|
sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
// Context例外情况
// Context例外情况
const
CONTEXT_API_RE_EXC
=
[
'
createBLEConnection
'
];
const
CONTEXT_API_RE_EXC
=
[
'
createBLEConnection
'
];
...
@@ -727,6 +727,30 @@ function initWrapper(protocols) {
...
@@ -727,6 +727,30 @@ function initWrapper(protocols) {
};
};
}
}
const
getLocale
=
()
=>
{
// 优先使用 $locale
const
app
=
getApp
({
allowDefault
:
true
});
if
(
app
&&
app
.
$vm
)
{
return
app
.
$vm
.
$locale
;
}
return
uni
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
;
};
const
setLocale
=
(
locale
)
=>
{
const
oldLocale
=
getApp
().
$vm
.
$locale
;
if
(
oldLocale
!==
locale
)
{
getApp
().
$vm
.
$locale
=
locale
;
onLocaleChangeCallbacks
.
forEach
((
fn
)
=>
fn
({
locale
}));
return
true
;
}
return
false
;
};
const
onLocaleChangeCallbacks
=
[];
const
onLocaleChange
=
(
fn
)
=>
{
if
(
onLocaleChangeCallbacks
.
indexOf
(
fn
)
===
-
1
)
{
onLocaleChangeCallbacks
.
push
(
fn
);
}
};
const
baseApis
=
{
const
baseApis
=
{
$on
,
$on
,
$off
,
$off
,
...
@@ -736,6 +760,9 @@ const baseApis = {
...
@@ -736,6 +760,9 @@ const baseApis = {
addInterceptor
,
addInterceptor
,
removeInterceptor
,
removeInterceptor
,
onAppLaunch
,
onAppLaunch
,
getLocale
,
setLocale
,
onLocaleChange
,
};
};
function
initUni
(
api
,
protocols
)
{
function
initUni
(
api
,
protocols
)
{
const
wrapper
=
initWrapper
(
protocols
);
const
wrapper
=
initWrapper
(
protocols
);
...
...
packages/uni-mp-kuaishou/dist/uni.mp.esm.js
浏览文件 @
52382584
import
{
isPlainObject
,
hasOwn
,
isArray
,
extend
,
hyphenate
,
isObject
,
toNumber
,
isFunction
,
NOOP
,
camelize
}
from
'
@vue/shared
'
;
import
{
isPlainObject
,
hasOwn
,
isArray
,
extend
,
hyphenate
,
isObject
,
toNumber
,
isFunction
,
NOOP
,
camelize
}
from
'
@vue/shared
'
;
import
{
onUnmounted
,
injectHook
}
from
'
vue
'
;
import
{
onUnmounted
,
injectHook
,
ref
}
from
'
vue
'
;
const
encode
=
encodeURIComponent
;
const
encode
=
encodeURIComponent
;
function
stringifyQuery
(
obj
,
encodeStr
=
encode
)
{
function
stringifyQuery
(
obj
,
encodeStr
=
encode
)
{
...
@@ -603,6 +603,7 @@ function parseApp(instance, parseAppOptions) {
...
@@ -603,6 +603,7 @@ function parseApp(instance, parseAppOptions) {
instance
.
$callHook
(
ON_LAUNCH
,
extend
({
app
:
this
},
options
));
instance
.
$callHook
(
ON_LAUNCH
,
extend
({
app
:
this
},
options
));
},
},
};
};
initLocale
(
instance
);
const
vueOptions
=
instance
.
$
.
type
;
const
vueOptions
=
instance
.
$
.
type
;
initHooks
(
appOptions
,
HOOKS
);
initHooks
(
appOptions
,
HOOKS
);
initUnknownHooks
(
appOptions
,
vueOptions
);
initUnknownHooks
(
appOptions
,
vueOptions
);
...
@@ -620,6 +621,17 @@ function initCreateApp(parseAppOptions) {
...
@@ -620,6 +621,17 @@ function initCreateApp(parseAppOptions) {
return
App
(
parseApp
(
vm
,
parseAppOptions
));
return
App
(
parseApp
(
vm
,
parseAppOptions
));
};
};
}
}
function
initLocale
(
appVm
)
{
const
locale
=
ref
(
uni
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
);
Object
.
defineProperty
(
appVm
,
'
$locale
'
,
{
get
()
{
return
locale
.
value
;
},
set
(
v
)
{
locale
.
value
=
v
;
},
});
}
const
PROP_TYPES
=
[
String
,
Number
,
Boolean
,
Object
,
Array
,
null
];
const
PROP_TYPES
=
[
String
,
Number
,
Boolean
,
Object
,
Array
,
null
];
function
createObserver
(
name
)
{
function
createObserver
(
name
)
{
...
...
packages/uni-mp-qq/build.json
浏览文件 @
52382584
...
@@ -19,5 +19,6 @@
...
@@ -19,5 +19,6 @@
"__GLOBAL__"
:
"qq"
,
"__GLOBAL__"
:
"qq"
,
"__PLATFORM__"
:
"
\"
mp-qq
\"
"
,
"__PLATFORM__"
:
"
\"
mp-qq
\"
"
,
"__PLATFORM_TITLE__"
:
"QQ小程序"
"__PLATFORM_TITLE__"
:
"QQ小程序"
}
},
"external"
:
[
"@dcloudio/uni-i18n"
,
"@vue/shared"
,
"vue"
]
}
}
packages/uni-mp-qq/dist/uni.api.esm.js
浏览文件 @
52382584
...
@@ -583,7 +583,7 @@ const $emit = defineSyncApi(API_EMIT, (name, ...args) => {
...
@@ -583,7 +583,7 @@ const $emit = defineSyncApi(API_EMIT, (name, ...args) => {
emitter
.
emit
(
name
,
...
args
);
emitter
.
emit
(
name
,
...
args
);
},
EmitProtocol
);
},
EmitProtocol
);
const
SYNC_API_RE
=
/^
\$
|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
;
const
SYNC_API_RE
=
/^
\$
|
getLocale|setLocale|
sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
// Context例外情况
// Context例外情况
const
CONTEXT_API_RE_EXC
=
[
'
createBLEConnection
'
];
const
CONTEXT_API_RE_EXC
=
[
'
createBLEConnection
'
];
...
@@ -727,6 +727,30 @@ function initWrapper(protocols) {
...
@@ -727,6 +727,30 @@ function initWrapper(protocols) {
};
};
}
}
const
getLocale
=
()
=>
{
// 优先使用 $locale
const
app
=
getApp
({
allowDefault
:
true
});
if
(
app
&&
app
.
$vm
)
{
return
app
.
$vm
.
$locale
;
}
return
uni
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
;
};
const
setLocale
=
(
locale
)
=>
{
const
oldLocale
=
getApp
().
$vm
.
$locale
;
if
(
oldLocale
!==
locale
)
{
getApp
().
$vm
.
$locale
=
locale
;
onLocaleChangeCallbacks
.
forEach
((
fn
)
=>
fn
({
locale
}));
return
true
;
}
return
false
;
};
const
onLocaleChangeCallbacks
=
[];
const
onLocaleChange
=
(
fn
)
=>
{
if
(
onLocaleChangeCallbacks
.
indexOf
(
fn
)
===
-
1
)
{
onLocaleChangeCallbacks
.
push
(
fn
);
}
};
const
baseApis
=
{
const
baseApis
=
{
$on
,
$on
,
$off
,
$off
,
...
@@ -736,6 +760,9 @@ const baseApis = {
...
@@ -736,6 +760,9 @@ const baseApis = {
addInterceptor
,
addInterceptor
,
removeInterceptor
,
removeInterceptor
,
onAppLaunch
,
onAppLaunch
,
getLocale
,
setLocale
,
onLocaleChange
,
};
};
function
initUni
(
api
,
protocols
)
{
function
initUni
(
api
,
protocols
)
{
const
wrapper
=
initWrapper
(
protocols
);
const
wrapper
=
initWrapper
(
protocols
);
...
...
packages/uni-mp-qq/dist/uni.mp.esm.js
浏览文件 @
52382584
import
{
isPlainObject
,
hasOwn
,
isArray
,
extend
,
hyphenate
,
isObject
,
toNumber
,
isFunction
,
NOOP
,
camelize
}
from
'
@vue/shared
'
;
import
{
isPlainObject
,
hasOwn
,
isArray
,
extend
,
hyphenate
,
isObject
,
toNumber
,
isFunction
,
NOOP
,
camelize
}
from
'
@vue/shared
'
;
import
{
onUnmounted
,
injectHook
}
from
'
vue
'
;
import
{
onUnmounted
,
injectHook
,
ref
}
from
'
vue
'
;
const
encode
=
encodeURIComponent
;
const
encode
=
encodeURIComponent
;
function
stringifyQuery
(
obj
,
encodeStr
=
encode
)
{
function
stringifyQuery
(
obj
,
encodeStr
=
encode
)
{
...
@@ -603,6 +603,7 @@ function parseApp(instance, parseAppOptions) {
...
@@ -603,6 +603,7 @@ function parseApp(instance, parseAppOptions) {
instance
.
$callHook
(
ON_LAUNCH
,
extend
({
app
:
this
},
options
));
instance
.
$callHook
(
ON_LAUNCH
,
extend
({
app
:
this
},
options
));
},
},
};
};
initLocale
(
instance
);
const
vueOptions
=
instance
.
$
.
type
;
const
vueOptions
=
instance
.
$
.
type
;
initHooks
(
appOptions
,
HOOKS
);
initHooks
(
appOptions
,
HOOKS
);
initUnknownHooks
(
appOptions
,
vueOptions
);
initUnknownHooks
(
appOptions
,
vueOptions
);
...
@@ -620,6 +621,17 @@ function initCreateApp(parseAppOptions) {
...
@@ -620,6 +621,17 @@ function initCreateApp(parseAppOptions) {
return
App
(
parseApp
(
vm
,
parseAppOptions
));
return
App
(
parseApp
(
vm
,
parseAppOptions
));
};
};
}
}
function
initLocale
(
appVm
)
{
const
locale
=
ref
(
uni
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
);
Object
.
defineProperty
(
appVm
,
'
$locale
'
,
{
get
()
{
return
locale
.
value
;
},
set
(
v
)
{
locale
.
value
=
v
;
},
});
}
const
PROP_TYPES
=
[
String
,
Number
,
Boolean
,
Object
,
Array
,
null
];
const
PROP_TYPES
=
[
String
,
Number
,
Boolean
,
Object
,
Array
,
null
];
function
createObserver
(
name
)
{
function
createObserver
(
name
)
{
...
...
packages/uni-mp-toutiao/build.json
浏览文件 @
52382584
...
@@ -19,5 +19,6 @@
...
@@ -19,5 +19,6 @@
"__GLOBAL__"
:
"tt"
,
"__GLOBAL__"
:
"tt"
,
"__PLATFORM__"
:
"
\"
mp-toutiao
\"
"
,
"__PLATFORM__"
:
"
\"
mp-toutiao
\"
"
,
"__PLATFORM_TITLE__"
:
"字节跳动小程序"
"__PLATFORM_TITLE__"
:
"字节跳动小程序"
}
},
"external"
:
[
"@dcloudio/uni-i18n"
,
"@vue/shared"
,
"vue"
]
}
}
packages/uni-mp-toutiao/dist/uni.api.esm.js
浏览文件 @
52382584
...
@@ -583,7 +583,7 @@ const $emit = defineSyncApi(API_EMIT, (name, ...args) => {
...
@@ -583,7 +583,7 @@ const $emit = defineSyncApi(API_EMIT, (name, ...args) => {
emitter
.
emit
(
name
,
...
args
);
emitter
.
emit
(
name
,
...
args
);
},
EmitProtocol
);
},
EmitProtocol
);
const
SYNC_API_RE
=
/^
\$
|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
;
const
SYNC_API_RE
=
/^
\$
|
getLocale|setLocale|
sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
// Context例外情况
// Context例外情况
const
CONTEXT_API_RE_EXC
=
[
'
createBLEConnection
'
];
const
CONTEXT_API_RE_EXC
=
[
'
createBLEConnection
'
];
...
@@ -727,6 +727,30 @@ function initWrapper(protocols) {
...
@@ -727,6 +727,30 @@ function initWrapper(protocols) {
};
};
}
}
const
getLocale
=
()
=>
{
// 优先使用 $locale
const
app
=
getApp
({
allowDefault
:
true
});
if
(
app
&&
app
.
$vm
)
{
return
app
.
$vm
.
$locale
;
}
return
uni
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
;
};
const
setLocale
=
(
locale
)
=>
{
const
oldLocale
=
getApp
().
$vm
.
$locale
;
if
(
oldLocale
!==
locale
)
{
getApp
().
$vm
.
$locale
=
locale
;
onLocaleChangeCallbacks
.
forEach
((
fn
)
=>
fn
({
locale
}));
return
true
;
}
return
false
;
};
const
onLocaleChangeCallbacks
=
[];
const
onLocaleChange
=
(
fn
)
=>
{
if
(
onLocaleChangeCallbacks
.
indexOf
(
fn
)
===
-
1
)
{
onLocaleChangeCallbacks
.
push
(
fn
);
}
};
const
baseApis
=
{
const
baseApis
=
{
$on
,
$on
,
$off
,
$off
,
...
@@ -736,6 +760,9 @@ const baseApis = {
...
@@ -736,6 +760,9 @@ const baseApis = {
addInterceptor
,
addInterceptor
,
removeInterceptor
,
removeInterceptor
,
onAppLaunch
,
onAppLaunch
,
getLocale
,
setLocale
,
onLocaleChange
,
};
};
function
initUni
(
api
,
protocols
)
{
function
initUni
(
api
,
protocols
)
{
const
wrapper
=
initWrapper
(
protocols
);
const
wrapper
=
initWrapper
(
protocols
);
...
...
packages/uni-mp-toutiao/dist/uni.mp.esm.js
浏览文件 @
52382584
import
{
isPlainObject
,
hasOwn
,
isArray
,
extend
,
hyphenate
,
isObject
,
toNumber
,
isFunction
,
NOOP
,
camelize
}
from
'
@vue/shared
'
;
import
{
isPlainObject
,
hasOwn
,
isArray
,
extend
,
hyphenate
,
isObject
,
toNumber
,
isFunction
,
NOOP
,
camelize
}
from
'
@vue/shared
'
;
import
{
onUnmounted
,
injectHook
}
from
'
vue
'
;
import
{
onUnmounted
,
injectHook
,
ref
}
from
'
vue
'
;
const
encode
=
encodeURIComponent
;
const
encode
=
encodeURIComponent
;
function
stringifyQuery
(
obj
,
encodeStr
=
encode
)
{
function
stringifyQuery
(
obj
,
encodeStr
=
encode
)
{
...
@@ -606,6 +606,7 @@ function parseApp(instance, parseAppOptions) {
...
@@ -606,6 +606,7 @@ function parseApp(instance, parseAppOptions) {
instance
.
$callHook
(
ON_LAUNCH
,
extend
({
app
:
this
},
options
));
instance
.
$callHook
(
ON_LAUNCH
,
extend
({
app
:
this
},
options
));
},
},
};
};
initLocale
(
instance
);
const
vueOptions
=
instance
.
$
.
type
;
const
vueOptions
=
instance
.
$
.
type
;
initHooks
(
appOptions
,
HOOKS
);
initHooks
(
appOptions
,
HOOKS
);
initUnknownHooks
(
appOptions
,
vueOptions
);
initUnknownHooks
(
appOptions
,
vueOptions
);
...
@@ -623,6 +624,17 @@ function initCreateApp(parseAppOptions) {
...
@@ -623,6 +624,17 @@ function initCreateApp(parseAppOptions) {
return
App
(
parseApp
(
vm
,
parseAppOptions
));
return
App
(
parseApp
(
vm
,
parseAppOptions
));
};
};
}
}
function
initLocale
(
appVm
)
{
const
locale
=
ref
(
uni
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
);
Object
.
defineProperty
(
appVm
,
'
$locale
'
,
{
get
()
{
return
locale
.
value
;
},
set
(
v
)
{
locale
.
value
=
v
;
},
});
}
const
PROP_TYPES
=
[
String
,
Number
,
Boolean
,
Object
,
Array
,
null
];
const
PROP_TYPES
=
[
String
,
Number
,
Boolean
,
Object
,
Array
,
null
];
function
createObserver
(
name
)
{
function
createObserver
(
name
)
{
...
...
packages/uni-mp-weixin/build.json
浏览文件 @
52382584
...
@@ -19,5 +19,6 @@
...
@@ -19,5 +19,6 @@
"__GLOBAL__"
:
"wx"
,
"__GLOBAL__"
:
"wx"
,
"__PLATFORM__"
:
"
\"
mp-weixin
\"
"
,
"__PLATFORM__"
:
"
\"
mp-weixin
\"
"
,
"__PLATFORM_TITLE__"
:
"微信小程序"
"__PLATFORM_TITLE__"
:
"微信小程序"
}
},
"external"
:
[
"@dcloudio/uni-i18n"
,
"@vue/shared"
,
"vue"
]
}
}
packages/uni-mp-weixin/dist/uni.api.esm.js
浏览文件 @
52382584
...
@@ -547,7 +547,7 @@ const $emit = defineSyncApi(API_EMIT, (name, ...args) => {
...
@@ -547,7 +547,7 @@ const $emit = defineSyncApi(API_EMIT, (name, ...args) => {
emitter
.
emit
(
name
,
...
args
);
emitter
.
emit
(
name
,
...
args
);
},
EmitProtocol
);
},
EmitProtocol
);
const
SYNC_API_RE
=
/^
\$
|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
;
const
SYNC_API_RE
=
/^
\$
|
getLocale|setLocale|
sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
// Context例外情况
// Context例外情况
const
CONTEXT_API_RE_EXC
=
[
'
createBLEConnection
'
];
const
CONTEXT_API_RE_EXC
=
[
'
createBLEConnection
'
];
...
@@ -691,6 +691,30 @@ function initWrapper(protocols) {
...
@@ -691,6 +691,30 @@ function initWrapper(protocols) {
};
};
}
}
const
getLocale
=
()
=>
{
// 优先使用 $locale
const
app
=
getApp
({
allowDefault
:
true
});
if
(
app
&&
app
.
$vm
)
{
return
app
.
$vm
.
$locale
;
}
return
uni
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
;
};
const
setLocale
=
(
locale
)
=>
{
const
oldLocale
=
getApp
().
$vm
.
$locale
;
if
(
oldLocale
!==
locale
)
{
getApp
().
$vm
.
$locale
=
locale
;
onLocaleChangeCallbacks
.
forEach
((
fn
)
=>
fn
({
locale
}));
return
true
;
}
return
false
;
};
const
onLocaleChangeCallbacks
=
[];
const
onLocaleChange
=
(
fn
)
=>
{
if
(
onLocaleChangeCallbacks
.
indexOf
(
fn
)
===
-
1
)
{
onLocaleChangeCallbacks
.
push
(
fn
);
}
};
const
baseApis
=
{
const
baseApis
=
{
$on
,
$on
,
$off
,
$off
,
...
@@ -700,6 +724,9 @@ const baseApis = {
...
@@ -700,6 +724,9 @@ const baseApis = {
addInterceptor
,
addInterceptor
,
removeInterceptor
,
removeInterceptor
,
onAppLaunch
,
onAppLaunch
,
getLocale
,
setLocale
,
onLocaleChange
,
};
};
function
initUni
(
api
,
protocols
)
{
function
initUni
(
api
,
protocols
)
{
const
wrapper
=
initWrapper
(
protocols
);
const
wrapper
=
initWrapper
(
protocols
);
...
...
packages/uni-mp-weixin/dist/uni.mp.esm.js
浏览文件 @
52382584
import
{
isPlainObject
,
hasOwn
,
isArray
,
extend
,
hyphenate
,
isObject
,
toNumber
,
isFunction
,
NOOP
,
camelize
}
from
'
@vue/shared
'
;
import
{
isPlainObject
,
hasOwn
,
isArray
,
extend
,
hyphenate
,
isObject
,
toNumber
,
isFunction
,
NOOP
,
camelize
}
from
'
@vue/shared
'
;
import
{
onUnmounted
,
injectHook
}
from
'
vue
'
;
import
{
onUnmounted
,
injectHook
,
ref
}
from
'
vue
'
;
const
encode
=
encodeURIComponent
;
const
encode
=
encodeURIComponent
;
function
stringifyQuery
(
obj
,
encodeStr
=
encode
)
{
function
stringifyQuery
(
obj
,
encodeStr
=
encode
)
{
...
@@ -549,6 +549,7 @@ function parseApp(instance, parseAppOptions) {
...
@@ -549,6 +549,7 @@ function parseApp(instance, parseAppOptions) {
instance
.
$callHook
(
ON_LAUNCH
,
extend
({
app
:
this
},
options
));
instance
.
$callHook
(
ON_LAUNCH
,
extend
({
app
:
this
},
options
));
},
},
};
};
initLocale
(
instance
);
const
vueOptions
=
instance
.
$
.
type
;
const
vueOptions
=
instance
.
$
.
type
;
initHooks
(
appOptions
,
HOOKS
);
initHooks
(
appOptions
,
HOOKS
);
initUnknownHooks
(
appOptions
,
vueOptions
);
initUnknownHooks
(
appOptions
,
vueOptions
);
...
@@ -566,6 +567,17 @@ function initCreateApp(parseAppOptions) {
...
@@ -566,6 +567,17 @@ function initCreateApp(parseAppOptions) {
return
App
(
parseApp
(
vm
,
parseAppOptions
));
return
App
(
parseApp
(
vm
,
parseAppOptions
));
};
};
}
}
function
initLocale
(
appVm
)
{
const
locale
=
ref
(
uni
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
);
Object
.
defineProperty
(
appVm
,
'
$locale
'
,
{
get
()
{
return
locale
.
value
;
},
set
(
v
)
{
locale
.
value
=
v
;
},
});
}
const
PROP_TYPES
=
[
String
,
Number
,
Boolean
,
Object
,
Array
,
null
];
const
PROP_TYPES
=
[
String
,
Number
,
Boolean
,
Object
,
Array
,
null
];
function
createObserver
(
name
)
{
function
createObserver
(
name
)
{
...
...
packages/uni-quickapp-webview/build.json
浏览文件 @
52382584
...
@@ -19,5 +19,6 @@
...
@@ -19,5 +19,6 @@
"__GLOBAL__"
:
"qa"
,
"__GLOBAL__"
:
"qa"
,
"__PLATFORM__"
:
"
\"
quickapp-webview
\"
"
,
"__PLATFORM__"
:
"
\"
quickapp-webview
\"
"
,
"__PLATFORM_TITLE__"
:
"快应用(Webview)版"
"__PLATFORM_TITLE__"
:
"快应用(Webview)版"
}
},
"external"
:
[
"@dcloudio/uni-i18n"
,
"@vue/shared"
,
"vue"
]
}
}
packages/uni-quickapp-webview/dist/uni.api.esm.js
浏览文件 @
52382584
...
@@ -583,7 +583,7 @@ const $emit = defineSyncApi(API_EMIT, (name, ...args) => {
...
@@ -583,7 +583,7 @@ const $emit = defineSyncApi(API_EMIT, (name, ...args) => {
emitter
.
emit
(
name
,
...
args
);
emitter
.
emit
(
name
,
...
args
);
},
EmitProtocol
);
},
EmitProtocol
);
const
SYNC_API_RE
=
/^
\$
|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
;
const
SYNC_API_RE
=
/^
\$
|
getLocale|setLocale|
sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
// Context例外情况
// Context例外情况
const
CONTEXT_API_RE_EXC
=
[
'
createBLEConnection
'
];
const
CONTEXT_API_RE_EXC
=
[
'
createBLEConnection
'
];
...
@@ -727,6 +727,30 @@ function initWrapper(protocols) {
...
@@ -727,6 +727,30 @@ function initWrapper(protocols) {
};
};
}
}
const
getLocale
=
()
=>
{
// 优先使用 $locale
const
app
=
getApp
({
allowDefault
:
true
});
if
(
app
&&
app
.
$vm
)
{
return
app
.
$vm
.
$locale
;
}
return
uni
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
;
};
const
setLocale
=
(
locale
)
=>
{
const
oldLocale
=
getApp
().
$vm
.
$locale
;
if
(
oldLocale
!==
locale
)
{
getApp
().
$vm
.
$locale
=
locale
;
onLocaleChangeCallbacks
.
forEach
((
fn
)
=>
fn
({
locale
}));
return
true
;
}
return
false
;
};
const
onLocaleChangeCallbacks
=
[];
const
onLocaleChange
=
(
fn
)
=>
{
if
(
onLocaleChangeCallbacks
.
indexOf
(
fn
)
===
-
1
)
{
onLocaleChangeCallbacks
.
push
(
fn
);
}
};
const
baseApis
=
{
const
baseApis
=
{
$on
,
$on
,
$off
,
$off
,
...
@@ -736,6 +760,9 @@ const baseApis = {
...
@@ -736,6 +760,9 @@ const baseApis = {
addInterceptor
,
addInterceptor
,
removeInterceptor
,
removeInterceptor
,
onAppLaunch
,
onAppLaunch
,
getLocale
,
setLocale
,
onLocaleChange
,
};
};
function
initUni
(
api
,
protocols
)
{
function
initUni
(
api
,
protocols
)
{
const
wrapper
=
initWrapper
(
protocols
);
const
wrapper
=
initWrapper
(
protocols
);
...
...
packages/uni-quickapp-webview/dist/uni.mp.esm.js
浏览文件 @
52382584
import
{
isPlainObject
,
hasOwn
,
isArray
,
extend
,
hyphenate
,
isObject
,
toNumber
,
isFunction
,
NOOP
,
camelize
}
from
'
@vue/shared
'
;
import
{
isPlainObject
,
hasOwn
,
isArray
,
extend
,
hyphenate
,
isObject
,
toNumber
,
isFunction
,
NOOP
,
camelize
}
from
'
@vue/shared
'
;
import
{
injectHook
}
from
'
vue
'
;
import
{
injectHook
,
ref
}
from
'
vue
'
;
const
encode
=
encodeURIComponent
;
const
encode
=
encodeURIComponent
;
function
stringifyQuery
(
obj
,
encodeStr
=
encode
)
{
function
stringifyQuery
(
obj
,
encodeStr
=
encode
)
{
...
@@ -534,6 +534,7 @@ function parseApp(instance, parseAppOptions) {
...
@@ -534,6 +534,7 @@ function parseApp(instance, parseAppOptions) {
instance
.
$callHook
(
ON_LAUNCH
,
extend
({
app
:
this
},
options
));
instance
.
$callHook
(
ON_LAUNCH
,
extend
({
app
:
this
},
options
));
},
},
};
};
initLocale
(
instance
);
const
vueOptions
=
instance
.
$
.
type
;
const
vueOptions
=
instance
.
$
.
type
;
initHooks
(
appOptions
,
HOOKS
);
initHooks
(
appOptions
,
HOOKS
);
initUnknownHooks
(
appOptions
,
vueOptions
);
initUnknownHooks
(
appOptions
,
vueOptions
);
...
@@ -551,6 +552,17 @@ function initCreateApp(parseAppOptions) {
...
@@ -551,6 +552,17 @@ function initCreateApp(parseAppOptions) {
return
App
(
parseApp
(
vm
,
parseAppOptions
));
return
App
(
parseApp
(
vm
,
parseAppOptions
));
};
};
}
}
function
initLocale
(
appVm
)
{
const
locale
=
ref
(
uni
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
);
Object
.
defineProperty
(
appVm
,
'
$locale
'
,
{
get
()
{
return
locale
.
value
;
},
set
(
v
)
{
locale
.
value
=
v
;
},
});
}
const
PROP_TYPES
=
[
String
,
Number
,
Boolean
,
Object
,
Array
,
null
];
const
PROP_TYPES
=
[
String
,
Number
,
Boolean
,
Object
,
Array
,
null
];
function
createObserver
(
name
)
{
function
createObserver
(
name
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录