Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
ea602d6a
U
uni-app
项目概览
DCloud
/
uni-app
6 个月 前同步成功
通知
751
Star
38709
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
8
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
8
Issue
8
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
ea602d6a
编写于
2月 06, 2023
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore: Array.isArray => isArray
上级
3c47420f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
88 addition
and
42 deletion
+88
-42
packages/uni-app-plus/dist/uni.runtime.esm.js
packages/uni-app-plus/dist/uni.runtime.esm.js
+22
-9
packages/uni-core/src/i18n/useI18n.ts
packages/uni-core/src/i18n/useI18n.ts
+3
-6
packages/uni-h5/dist/uni-h5.cjs.js
packages/uni-h5/dist/uni-h5.cjs.js
+31
-13
packages/uni-h5/dist/uni-h5.es.js
packages/uni-h5/dist/uni-h5.es.js
+32
-14
未找到文件。
packages/uni-app-plus/dist/uni.runtime.esm.js
浏览文件 @
ea602d6a
...
...
@@ -1095,6 +1095,11 @@ function formatI18n(message) {
function resolveJsonObj(jsonObj, names) {
if (names.length === 1) {
if (jsonObj) {
const _isI18nStr = (value) => isString(value) && isI18nStr(value, I18N_JSON_DELIMITERS);
const _name = names[0];
if (isArray(jsonObj) && jsonObj.some((item) => _isI18nStr(item[_name]))) {
return jsonObj;
}
const value = jsonObj[names[0]];
if (isString(value) && isI18nStr(value, I18N_JSON_DELIMITERS)) {
return jsonObj;
...
...
@@ -1114,15 +1119,22 @@ function defineI18nProperty(obj, names) {
return false;
}
const prop = names[names.length - 1];
let value = jsonObj[prop];
Object.defineProperty(jsonObj, prop, {
get() {
return formatI18n(value);
},
set(v) {
value = v;
},
});
if (isArray(jsonObj)) {
jsonObj
.filter((item) => isI18nStr(item[prop], I18N_JSON_DELIMITERS))
.forEach((item) => defineI18nProperty(item, [prop]));
}
else {
let value = jsonObj[prop];
Object.defineProperty(jsonObj, prop, {
get() {
return formatI18n(value);
},
set(v) {
value = v;
},
});
}
return true;
}
function useI18n() {
...
...
@@ -1402,6 +1414,7 @@ function initNavigationBarI18n(navigationBar) {
return defineI18nProperties(navigationBar, [
['titleText'],
['searchInput', 'placeholder'],
['buttons', 'text'],
]);
}
}
...
...
packages/uni-core/src/i18n/useI18n.ts
浏览文件 @
ea602d6a
import
{
isString
}
from
'
@vue/shared
'
import
{
is
Array
,
is
String
}
from
'
@vue/shared
'
import
{
getEnvLocale
,
I18N_JSON_DELIMITERS
,
...
...
@@ -37,10 +37,7 @@ function resolveJsonObj(
const
_isI18nStr
=
(
value
:
any
)
=>
isString
(
value
)
&&
isI18nStr
(
value
,
I18N_JSON_DELIMITERS
)
const
_name
=
names
[
0
]
if
(
Array
.
isArray
(
jsonObj
)
&&
jsonObj
.
some
((
item
)
=>
_isI18nStr
(
item
[
_name
]))
)
{
if
(
isArray
(
jsonObj
)
&&
jsonObj
.
some
((
item
)
=>
_isI18nStr
(
item
[
_name
])))
{
return
jsonObj
}
const
value
=
jsonObj
[
names
[
0
]]
...
...
@@ -67,7 +64,7 @@ export function defineI18nProperty(obj: Record<string, any>, names: string[]) {
return
false
}
const
prop
=
names
[
names
.
length
-
1
]
if
(
Array
.
isArray
(
jsonObj
))
{
if
(
isArray
(
jsonObj
))
{
jsonObj
.
filter
((
item
)
=>
isI18nStr
(
item
[
prop
],
I18N_JSON_DELIMITERS
))
.
forEach
((
item
)
=>
defineI18nProperty
(
item
,
[
prop
]))
...
...
packages/uni-h5/dist/uni-h5.cjs.js
浏览文件 @
ea602d6a
...
...
@@ -23,6 +23,11 @@ function formatI18n(message) {
function
resolveJsonObj
(
jsonObj
,
names
)
{
if
(
names
.
length
===
1
)
{
if
(
jsonObj
)
{
const
_isI18nStr
=
(
value2
)
=>
shared
.
isString
(
value2
)
&&
uniI18n
.
isI18nStr
(
value2
,
uniShared
.
I18N_JSON_DELIMITERS
);
const
_name
=
names
[
0
];
if
(
shared
.
isArray
(
jsonObj
)
&&
jsonObj
.
some
((
item
)
=>
_isI18nStr
(
item
[
_name
])))
{
return
jsonObj
;
}
const
value
=
jsonObj
[
names
[
0
]];
if
(
shared
.
isString
(
value
)
&&
uniI18n
.
isI18nStr
(
value
,
uniShared
.
I18N_JSON_DELIMITERS
))
{
return
jsonObj
;
...
...
@@ -42,15 +47,19 @@ function defineI18nProperty(obj, names) {
return
false
;
}
const
prop
=
names
[
names
.
length
-
1
];
let
value
=
jsonObj
[
prop
];
Object
.
defineProperty
(
jsonObj
,
prop
,
{
get
()
{
return
formatI18n
(
value
);
},
set
(
v2
)
{
value
=
v2
;
}
});
if
(
shared
.
isArray
(
jsonObj
))
{
jsonObj
.
filter
((
item
)
=>
uniI18n
.
isI18nStr
(
item
[
prop
],
uniShared
.
I18N_JSON_DELIMITERS
)).
forEach
((
item
)
=>
defineI18nProperty
(
item
,
[
prop
]));
}
else
{
let
value
=
jsonObj
[
prop
];
Object
.
defineProperty
(
jsonObj
,
prop
,
{
get
()
{
return
formatI18n
(
value
);
},
set
(
v2
)
{
value
=
v2
;
}
});
}
return
true
;
}
function
useI18n
()
{
...
...
@@ -207,7 +216,8 @@ function initNavigationBarI18n(navigationBar) {
if
(
isEnableLocale
())
{
return
defineI18nProperties
(
navigationBar
,
[
[
"
titleText
"
],
[
"
searchInput
"
,
"
placeholder
"
]
[
"
searchInput
"
,
"
placeholder
"
],
[
"
buttons
"
,
"
text
"
]
]);
}
}
...
...
@@ -12147,7 +12157,7 @@ function usePageHeadButton(pageId, index2, btn, isTransparent) {
if
(
btn
.
fontFamily
)
{
iconStyle
.
fontFamily
=
btn
.
fontFamily
;
}
return
{
return
new
Proxy
(
{
btnClass
:
{
// 类似这样的大量重复的字符串,会在gzip时压缩大小,无需在代码层考虑优化相同字符串
"
uni-page-head-btn
"
:
true
,
...
...
@@ -12158,7 +12168,7 @@ function usePageHeadButton(pageId, index2, btn, isTransparent) {
backgroundColor
:
isTransparent
?
btn
.
background
:
"
transparent
"
,
width
:
btn
.
width
},
btnText
:
btn
.
fontSrc
&&
btn
.
fontFamily
?
btn
.
text
.
replace
(
"
\\
u
"
,
"
&#x
"
)
:
btn
.
text
,
btnText
:
""
,
btnIconPath
:
ICON_PATHS
[
btn
.
type
],
badgeText
:
btn
.
badgeText
,
iconStyle
,
...
...
@@ -12168,7 +12178,15 @@ function usePageHeadButton(pageId, index2, btn, isTransparent) {
},
btn
));
},
btnSelect
:
btn
.
select
};
},
{
get
(
target
,
key
,
receiver
)
{
if
([
"
btnText
"
].
includes
(
key
))
{
return
btn
.
fontSrc
&&
btn
.
fontFamily
?
btn
.
text
.
replace
(
"
\\
u
"
,
"
&#x
"
)
:
btn
.
text
;
}
else
{
return
Reflect
.
get
(
target
,
key
,
receiver
);
}
}
});
}
function
usePageHeadSearchInput
({
id
,
...
...
packages/uni-h5/dist/uni-h5.es.js
浏览文件 @
ea602d6a
import { withModifiers, createVNode, getCurrentInstance, ref, defineComponent, openBlock, createElementBlock, provide, computed, watch, onUnmounted, inject, onBeforeUnmount, mergeProps, injectHook, reactive, onActivated, onMounted, nextTick, onBeforeMount, withDirectives, vShow, shallowRef, watchEffect, isVNode, Fragment, markRaw, Comment, h, createTextVNode, createBlock, onBeforeActivate, onBeforeDeactivate, renderList, onDeactivated, createApp, Transition, effectScope, withCtx, KeepAlive, resolveDynamicComponent, createElementVNode, normalizeStyle, renderSlot } from "vue";
import { is
String, extend, isArray
, remove, stringifyStyle, parseStringStyle, isPlainObject, isFunction, capitalize, camelize, hasOwn, isObject, toRawType, makeMap as makeMap$1, isPromise, hyphenate, invokeArrayFns as invokeArrayFns$1 } from "@vue/shared";
import { is
Array, isString, extend
, remove, stringifyStyle, parseStringStyle, isPlainObject, isFunction, capitalize, camelize, hasOwn, isObject, toRawType, makeMap as makeMap$1, isPromise, hyphenate, invokeArrayFns as invokeArrayFns$1 } from "@vue/shared";
import { once, UNI_STORAGE_LOCALE, I18N_JSON_DELIMITERS, Emitter, passive, initCustomDatasetOnce, resolveComponentInstance, normalizeStyles, addLeadingSlash, invokeArrayFns, removeLeadingSlash, resolveOwnerVm, resolveOwnerEl, ON_WXS_INVOKE_CALL_METHOD, normalizeTarget, ON_RESIZE, ON_APP_ENTER_FOREGROUND, ON_APP_ENTER_BACKGROUND, ON_SHOW, ON_HIDE, ON_PAGE_SCROLL, ON_REACH_BOTTOM, EventChannel, SCHEME_RE, DATA_RE, getCustomDataset, LINEFEED, ON_ERROR, callOptions, ON_UNHANDLE_REJECTION, ON_PAGE_NOT_FOUND, PRIMARY_COLOR, getLen, debounce, isUniLifecycleHook, ON_LOAD, UniLifecycleHooks, invokeCreateErrorHandler, invokeCreateVueAppHook, parseQuery, NAVBAR_HEIGHT, ON_UNLOAD, ON_REACH_BOTTOM_DISTANCE, decodedQuery, WEB_INVOKE_APPSERVICE, ON_WEB_INVOKE_APP_SERVICE, ON_THEME_CHANGE, updateElementStyle, sortObject, OFF_THEME_CHANGE, ON_BACK_PRESS, parseUrl, addFont, ON_NAVIGATION_BAR_CHANGE, scrollTo, RESPONSIVE_MIN_WIDTH, onCreateVueApp, formatDateTime, ON_NAVIGATION_BAR_BUTTON_TAP, ON_NAVIGATION_BAR_SEARCH_INPUT_CLICKED, ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED, ON_NAVIGATION_BAR_SEARCH_INPUT_CHANGED, ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED, ON_PULL_DOWN_REFRESH } from "@dcloudio/uni-shared";
import { onCreateVueApp as onCreateVueApp2 } from "@dcloudio/uni-shared";
import { initVueI18n, isI18nStr, LOCALE_EN, LOCALE_ES, LOCALE_FR, LOCALE_ZH_HANS, LOCALE_ZH_HANT } from "@dcloudio/uni-i18n";
...
...
@@ -22,6 +22,11 @@ function formatI18n(message) {
function resolveJsonObj(jsonObj, names) {
if (names.length === 1) {
if (jsonObj) {
const _isI18nStr = (value2) => isString(value2) && isI18nStr(value2, I18N_JSON_DELIMITERS);
const _name = names[0];
if (isArray(jsonObj) && jsonObj.some((item) => _isI18nStr(item[_name]))) {
return jsonObj;
}
const value = jsonObj[names[0]];
if (isString(value) && isI18nStr(value, I18N_JSON_DELIMITERS)) {
return jsonObj;
...
...
@@ -41,15 +46,19 @@ function defineI18nProperty(obj, names) {
return false;
}
const prop = names[names.length - 1];
let value = jsonObj[prop];
Object.defineProperty(jsonObj, prop, {
get() {
return formatI18n(value);
},
set(v2) {
value = v2;
}
});
if (isArray(jsonObj)) {
jsonObj.filter((item) => isI18nStr(item[prop], I18N_JSON_DELIMITERS)).forEach((item) => defineI18nProperty(item, [prop]));
} else {
let value = jsonObj[prop];
Object.defineProperty(jsonObj, prop, {
get() {
return formatI18n(value);
},
set(v2) {
value = v2;
}
});
}
return true;
}
function useI18n() {
...
...
@@ -543,7 +552,8 @@ function initNavigationBarI18n(navigationBar) {
if (isEnableLocale()) {
return defineI18nProperties(navigationBar, [
["titleText"],
["searchInput", "placeholder"]
["searchInput", "placeholder"],
["buttons", "text"]
]);
}
}
...
...
@@ -24712,7 +24722,7 @@ function usePageHeadButton(pageId, index2, btn, isTransparent) {
if (btn.fontFamily) {
iconStyle.fontFamily = btn.fontFamily;
}
return {
return
new Proxy(
{
btnClass: {
// 类似这样的大量重复的字符串,会在gzip时压缩大小,无需在代码层考虑优化相同字符串
"uni-page-head-btn": true,
...
...
@@ -24723,7 +24733,7 @@ function usePageHeadButton(pageId, index2, btn, isTransparent) {
backgroundColor: isTransparent ? btn.background : "transparent",
width: btn.width
},
btnText:
btn.fontSrc && btn.fontFamily ? btn.text.replace("\\u", "&#x") : btn.text
,
btnText:
""
,
btnIconPath: ICON_PATHS[btn.type],
badgeText: btn.badgeText,
iconStyle,
...
...
@@ -24733,7 +24743,15 @@ function usePageHeadButton(pageId, index2, btn, isTransparent) {
}, btn));
},
btnSelect: btn.select
};
}, {
get(target, key, receiver) {
if (["btnText"].includes(key)) {
return btn.fontSrc && btn.fontFamily ? btn.text.replace("\\u", "&#x") : btn.text;
} else {
return Reflect.get(target, key, receiver);
}
}
});
}
function usePageHeadSearchInput({
id: id2,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录