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; // 大纲章节(来自 GET .../outline,无大纲时为空);当前章会被并入并去重。 chapters: ChapterEntry[]; currentChapterNo: number; } 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, collapsed, onToggle, }: DesktopChapterListProps) { if (collapsed) { return ( ); } return ( ); } interface ChapterListContentProps extends ChapterListProps { // 桌面列传入 → 目录标题旁显示「收起」按钮;移动抽屉不传(抽屉自带关闭)。 onCollapse?: () => void; } export function ChapterListContent({ projectId, chapters, currentChapterNo, onCollapse, }: ChapterListContentProps) { const entries = buildChapterEntries(chapters, currentChapterNo); const hasOutline = chapters.length > 0; return ( <>

目录

{onCollapse ? ( ) : null}
{!hasOutline ? (

还没有章节目录。 去「大纲」生成 。

) : null} ); }