u
This commit is contained in:
parent
dd3cedcd23
commit
df386d8266
16
tool_core.js
16
tool_core.js
@ -286,7 +286,10 @@ module.exports = {
|
||||
let parent = root || globalThis || global || window || {}
|
||||
let keychain = path.split('.')
|
||||
for (let key of keychain) {
|
||||
if (typeof parent === 'object' && /^\w+\(.*\)$/.test(key)) {
|
||||
if (!parent) {
|
||||
// 如果 parent 是 null 或 undefined,直接返回空值。
|
||||
return emptyValue
|
||||
} else if (typeof parent === 'object' && /^\w+\(.*\)$/.test(key)) {
|
||||
// 支持 myfunc(param) 作为一个路径节点。
|
||||
let [all, func, param] = key.match(/^(\w+)\((.*)\)$/)
|
||||
parent = parent[func](param)
|
||||
@ -352,7 +355,7 @@ module.exports = {
|
||||
summarize_story (story = []) {
|
||||
// story is an array of objects, each object could either be {text:'some string'}, {image: url} or {video:url}. Please construct a summary object as result: { textLength, imageCount, VideoCount }
|
||||
return story.reduce(
|
||||
(summary, { text, image, video, file } = {}) => {
|
||||
(summary, { text, image, video, file, linkTarget } = {}) => {
|
||||
if (text) {
|
||||
summary.textLength += text.length
|
||||
summary.wordCount += text.split(/\s+/).length
|
||||
@ -362,10 +365,14 @@ module.exports = {
|
||||
summary.videoCount++
|
||||
} else if (file) {
|
||||
summary.fileCount++
|
||||
} else if (linkTarget) {
|
||||
summary.linkCount++
|
||||
} else {
|
||||
summary.untype++
|
||||
}
|
||||
return summary
|
||||
},
|
||||
{ textLength: 0, wordCount: 0, imageCount: 0, videoCount: 0 }
|
||||
{ textLength: 0, wordCount: 0, imageCount: 0, videoCount: 0, file: 0, link: 0, untype: 0 }
|
||||
)
|
||||
},
|
||||
|
||||
@ -462,6 +469,7 @@ module.exports = {
|
||||
})
|
||||
},
|
||||
|
||||
// 洗牌算法,随机打乱数组顺序
|
||||
shuffle_array (array = []) {
|
||||
if (Array.isArray(array)) {
|
||||
for (let i = array.length - 1; i > 0; i--) {
|
||||
@ -473,6 +481,6 @@ module.exports = {
|
||||
},
|
||||
|
||||
is_uuid (uuid) {
|
||||
return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(unid)
|
||||
return /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(uuid)
|
||||
},
|
||||
}
|
||||
|
@ -66,9 +66,8 @@ module.exports = {
|
||||
return i18nText
|
||||
} else if (typeof i18nText === 'object' && i18nText) {
|
||||
return (
|
||||
i18nText?.[langCode] ||
|
||||
i18nText?.[my.get_mylang()] ||
|
||||
(precise ? '' : i18nText?.earTH || i18nText?.defLAN || i18nText?.gloBAL || i18nText?.enUS || Object.values(i18nText)[0] || '')
|
||||
i18nText[langCode || my.get_mylang()] ||
|
||||
(precise ? '' : i18nText.earTH || i18nText.gloBAL || i18nText.defLAN || i18nText.enUS || Object.values(i18nText)[0] || '')
|
||||
)
|
||||
} else {
|
||||
return ''
|
||||
@ -97,7 +96,11 @@ module.exports = {
|
||||
)
|
||||
|
||||
windowTitle =
|
||||
windowTitle || wo?.envar?.callnames?.[langNow] || wo?.pagesJson?.appInfo?.i18nText?.[langNow] || wo?.pagesJson?.globalStyle?.navigationBarTitleText || ''
|
||||
windowTitle ||
|
||||
this.localizeText(wo?.envar?.callnames, { langCode: langNow }) ||
|
||||
this.localizeText(wo?.pagesJson?.appInfo?.i18nText, { langCode: langNow }) ||
|
||||
wo?.pagesJson?.globalStyle?.navigationBarTitleText ||
|
||||
''
|
||||
|
||||
if (wo.envar._clientInfo.deviceType === 'pc') {
|
||||
uni.setNavigationBarTitle({ title: windowTitle + (navibarTitle ? ` - ${navibarTitle}` : '') })
|
||||
|
Loading…
Reference in New Issue
Block a user