fix(mini-program): 修复 ScriptLibraryView 章节数展示为 0 的问题

getChapterCount 优先从 plotJson.stages.outline.beats.length 获取真实章节数(新剧本),
fallback 根据 length 字段估算:short→1章, medium→2章, long→4章。
This commit is contained in:
2026-07-26 18:21:58 +08:00
parent 321246c96c
commit 502586b64a
@@ -235,7 +235,18 @@ const getTags = (script) => {
return []
}
const getChapterCount = (script) => script.chapterCount || script.chapters || 0
const getChapterCount = (script) => {
// 优先从 beats 数组长度获取(Task 1-5 部署后新剧本结构)
const beats = script?.plotJson?.stages?.outline?.beats
if (Array.isArray(beats) && beats.length > 0) return beats.length
// Fallback:根据 length 字段估算(老剧本无 beats 数据)
const length = script?.length
if (length === 'short') return 1
if (length === 'medium') return 2
if (length === 'long') return 4
return 1
}
const getWordCount = (script) => {
const count = Number(script.wordCount || 0)