"use client"; import { useMemo, useState } from "react"; import { AppShell } from "@/components/AppShell"; import type { OutlineChapterView, ProjectResponse } from "@/lib/api/types"; import { groupByVolume } from "@/lib/outline/outline"; import { useOutline } from "@/lib/outline/useOutline"; import { OutlineChapterRow } from "./OutlineChapterRow"; interface OutlineEditorProps { project: ProjectResponse; initialChapters: OutlineChapterView[]; } // 大纲编辑器主体(UX §6.7)。RSC 种入已存大纲;Client 承载生成(POST .../outline)。 // 无凭据 → 503 LLM_UNAVAILABLE 经 error 检出、引导去设置。 export function OutlineEditor({ project, initialChapters, }: OutlineEditorProps) { const { chapters, status, error, generate } = useOutline(initialChapters); const [volume, setVolume] = useState(1); const volumes = useMemo(() => groupByVolume(chapters), [chapters]); const generating = status === "generating"; return (

大纲

setVolume(Math.max(1, Number(e.target.value) || 1))} className="w-16 rounded border border-line bg-bg px-2 py-1 text-sm text-ink focus:border-cinnabar focus:outline-none" />
{error ? (

大纲生成失败({error.code}):{error.message} {error.code === "LLM_UNAVAILABLE" ? ( <> {" "} 去设置提供商 ) : null}

) : null}
{volumes.length === 0 ? (

暂无大纲。点「✦ AI 排大纲」生成逐章节拍与伏笔窗口。

) : ( volumes.map((group) => (

卷 {group.volume}

    {group.chapters.map((ch) => ( ))}
)) )}
); }