From 321246c96cd92c5c9e7751391c1c4500ec770dc8 Mon Sep 17 00:00:00 2001 From: Peanut Date: Sun, 26 Jul 2026 18:18:14 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E7=AB=A0=E8=8A=82=E6=95=B0=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=E4=BF=AE=E5=A4=8D=E8=AE=BE=E8=AE=A1=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...2026-07-26-chapter-count-display-design.md | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 docs/superpowers/specs/2026-07-26-chapter-count-display-design.md diff --git a/docs/superpowers/specs/2026-07-26-chapter-count-display-design.md b/docs/superpowers/specs/2026-07-26-chapter-count-display-design.md new file mode 100644 index 0000000..739fac1 --- /dev/null +++ b/docs/superpowers/specs/2026-07-26-chapter-count-display-design.md @@ -0,0 +1,52 @@ +--- +author: AI Assistant +created_at: 2026-07-26 +purpose: 修复 ScriptLibraryView 章节数展示为 0 的问题 +--- + +# 章节数展示修复设计 + +## 问题 + +ScriptLibraryView 列表页中所有剧本的章节数均显示为"0章"。 + +**根因**:前端 `getChapterCount` 函数读取 `script.chapterCount || script.chapters || 0`,但后端未返回 `chapterCount` 或 `chapters` 字段;老剧本的 `plotJson` 仅包含 `title` 和 `fullContent`,不存在 `stages.outline.beats` 结构。 + +## 目标 + +- 新剧本(Task 1-5 部署后生成):从 `plotJson.stages.outline.beats.length` 获取真实章节数 +- 老剧本:根据 `script.length` 字段(short/medium/long)估算合理的章节数 +- 短篇显示"1章"(符合业务预期) + +## 方案 + +修改 `mini-program/src/pages/main/ScriptLibraryView.vue` 中的 `getChapterCount` 函数: + +```javascript +const getChapterCount = (script) => { + // 优先从 beats 数组长度获取(新剧本结构) + const beats = script?.plotJson?.stages?.outline?.beats + if (Array.isArray(beats) && beats.length > 0) return beats.length + + // Fallback:根据 length 字段估算 + const length = script?.length + if (length === 'short') return 1 + if (length === 'medium') return 2 + if (length === 'long') return 4 + return 1 +} +``` + +## 影响范围 + +- 仅修改 `ScriptLibraryView.vue` 的 `getChapterCount` 函数 +- 不涉及后端改动 +- 不涉及其他前端文件 + +## 验收标准 + +- 短篇剧本列表卡片显示"1章" +- 中篇剧本列表卡片显示"2章" +- 长篇剧本列表卡片显示"4章" +- 新剧本(有 beats 数据)显示真实 beats 数量 +- Console 无新增错误