This commit is contained in:
Luk
2026-02-07 11:36:04 +08:00
parent 95c5416959
commit 4c95f401bc
2 changed files with 42 additions and 7 deletions

View File

@@ -22,6 +22,12 @@
*.nosf/ *.nosf/
*.nosf.*/ *.nosf.*/
## everything 'git pull or fetch' will update `.git/FETCH_HEAD`, even if the content doesn't change. To avoid too many useless updates of this file in Seafile history:
FETCH_HEAD
*/FETCH_HEAD
.Trash/
.DS_Store .DS_Store
*/.DS_Store */.DS_Store
@@ -48,12 +54,18 @@ _desktop.ini
node_modules/ node_modules/
*/node_modules/ */node_modules/
package-lock.json package-lock.json
*/package-lock.json
pages4loader.json5 pages4loader.json5
*/pages4loader.json5
.deploy_git/ .deploy_git/
*/.deploy_git/ */.deploy_git/
# next.js 项目
.next/
*/.next/
# HBuilder 目录 # HBuilder 目录
unpackage/ unpackage/
*/unpackage/ */unpackage/

View File

@@ -38,20 +38,44 @@ module.exports = {
return obj return obj
}, },
parse_json (value, { failsafe } = {}) {
failsafe = typeof failsafe !== 'undefined' ? failsafe : value
if (typeof value === 'object') return value
else if (typeof value === 'string') {
try {
return JSON.parse(value)
} catch (e) {
return failsafe
}
} else {
return failsafe
}
},
parse_json_anyway (value) { parse_json_anyway (value) {
if (typeof value === 'object') return value
else if (typeof value === 'string') {
try { try {
return JSON.parse(value) return JSON.parse(value)
} catch (e) { } catch (e) {
return undefined return undefined
} }
} else {
return undefined
}
}, },
parse_json_or_keep (value) { parse_json_or_keep (value) {
if (typeof value === 'object') return value
else if (typeof value === 'string') {
try { try {
return JSON.parse(value) return JSON.parse(value)
} catch (e) { } catch (e) {
return value return value
} }
} else {
return value
}
}, },
// 按顺序展开,哪怕嵌套。 // 按顺序展开,哪怕嵌套。
@@ -342,7 +366,6 @@ module.exports = {
} }
}, },
// 20250621 todo 如果 text 是 {enUS,zhCN} 怎么处理
extract_story_title ({ story, lang = 'enUS' } = {}) { extract_story_title ({ story, lang = 'enUS' } = {}) {
if (Array.isArray(story) && story.length) { if (Array.isArray(story) && story.length) {
return ( return (