u
This commit is contained in:
parent
fc146dc10d
commit
5f3cc1fb12
11
tool_core.js
11
tool_core.js
@ -332,23 +332,24 @@ module.exports = {
|
||||
// 返回新的数组
|
||||
filter_story (story) {
|
||||
if (Array.isArray(story) && story.length) {
|
||||
// section can contain property '_xxx' which shall not change filter result.
|
||||
return story.filter((section) => {
|
||||
if (!section) return false
|
||||
return Object.entries(section).some(([key, val]) => !key.startsWith('_') && !this.is_empty(val))
|
||||
return Object.values(section).some((val) => !this.is_empty(val))
|
||||
//return Object.entries(section).some(([key, val]) => !key.startsWith('_') && !this.is_empty(val)) // don't check properties '_xxx'
|
||||
})
|
||||
} else {
|
||||
return []
|
||||
}
|
||||
},
|
||||
|
||||
// 20250621 todo 如果 text 是 {enUS,zhCN} 怎么处理
|
||||
extract_story_title (story) {
|
||||
if (Array.isArray(story) && story.length) {
|
||||
return (
|
||||
story
|
||||
.map(({ text = '' } = {}) => text.trim().replace(/\n/g, ' '))
|
||||
.join(' ')
|
||||
.substring(0, 140) || ''
|
||||
.map(({ text = '' } = {}) => text.trim?.()?.replace?.(/\n/g, ' '))
|
||||
?.join(' ')
|
||||
?.substring?.(0, 140) || ''
|
||||
)
|
||||
} else {
|
||||
return ''
|
||||
|
Loading…
Reference in New Issue
Block a user