diff --git a/apps/web/components/workbench/ChapterList.tsx b/apps/web/components/workbench/ChapterList.tsx index 6074a85..07653f7 100644 --- a/apps/web/components/workbench/ChapterList.tsx +++ b/apps/web/components/workbench/ChapterList.tsx @@ -1,6 +1,8 @@ import Link from "next/link"; +import { PanelLeftClose, PanelLeftOpen } from "lucide-react"; import { buildChapterEntries, type ChapterEntry } from "@/lib/workbench/chapter"; +import { focusRing } from "@/lib/ui/variants"; interface ChapterListProps { projectId: string; @@ -9,36 +11,83 @@ interface ChapterListProps { currentChapterNo: number; } -// 左栏目录(UX §6.3):列出大纲全部章节 + 当前章,点击切换写作章号(`?chapter=N`)。 -// 桌面 aside 包裹;移动端经 Workbench 抽屉复用 ChapterListContent。 +interface DesktopChapterListProps extends ChapterListProps { + // 目录列收起态(P2-2):收起时只留一条带「展开」按钮的窄轨,让宽给正文。 + collapsed: boolean; + onToggle: () => void; +} + +// 左栏目录(UX §6.3 / P2-2):列出大纲全部章节 + 当前章,点击切换写作章号(`?chapter=N`)。 +// 桌面 aside 包裹,可收起为窄轨;移动端经 Workbench 抽屉复用 ChapterListContent(不带折叠)。 export function ChapterList({ projectId, chapters, currentChapterNo, -}: ChapterListProps) { + collapsed, + onToggle, +}: DesktopChapterListProps) { + if (collapsed) { + return ( + + ); + } return ( ); } +interface ChapterListContentProps extends ChapterListProps { + // 桌面列传入 → 目录标题旁显示「收起」按钮;移动抽屉不传(抽屉自带关闭)。 + onCollapse?: () => void; +} + export function ChapterListContent({ projectId, chapters, currentChapterNo, -}: ChapterListProps) { + onCollapse, +}: ChapterListContentProps) { const entries = buildChapterEntries(chapters, currentChapterNo); const hasOutline = chapters.length > 0; return ( <> -

- 目录 -

+
+

+ 目录 +

+ {onCollapse ? ( + + ) : null} +