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.*/
## 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
@@ -48,12 +54,18 @@ _desktop.ini
node_modules/
*/node_modules/
package-lock.json
*/package-lock.json
pages4loader.json5
*/pages4loader.json5
.deploy_git/
*/.deploy_git/
# next.js 项目
.next/
*/.next/
# HBuilder 目录
unpackage/
*/unpackage/

View File

@@ -38,18 +38,42 @@ module.exports = {
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) {
try {
return JSON.parse(value)
} catch (e) {
if (typeof value === 'object') return value
else if (typeof value === 'string') {
try {
return JSON.parse(value)
} catch (e) {
return undefined
}
} else {
return undefined
}
},
parse_json_or_keep (value) {
try {
return JSON.parse(value)
} catch (e) {
if (typeof value === 'object') return value
else if (typeof value === 'string') {
try {
return JSON.parse(value)
} catch (e) {
return value
}
} else {
return value
}
},
@@ -342,7 +366,6 @@ module.exports = {
}
},
// 20250621 todo 如果 text 是 {enUS,zhCN} 怎么处理
extract_story_title ({ story, lang = 'enUS' } = {}) {
if (Array.isArray(story) && story.length) {
return (