/* deconstruct page: 拆书 UI - 顺序生成 5 个 section, 用户逐个确认后创建小说. */ import { escapeHtml, getCsrf, postJson, showError } from "../utils.js"; import { createSSEStream } from "../components/sse-client.js"; const SECTIONS = [ { id: "concept", label: "主题构思" }, { id: "world", label: "世界观" }, { id: "characters", label: "角色" }, { id: "outline", label: "大纲" }, { id: "foreshadowing", label: "伏笔计划" }, ]; // state: pending -> streaming -> confirm -> confirmed | skipped const state = {}; SECTIONS.forEach((s) => { state[s.id] = { status: "pending", text: "" }; }); let activeStream = null; let autoRunning = false; const alertsEl = document.getElementById("dcAlerts"); const sectionsEl = document.getElementById("dcSections"); const startBtn = document.getElementById("dcStartBtn"); const createBtn = document.getElementById("dcCreateBtn"); /* ---------------- UI 构建 ---------------- */ const BADGE = { pending: '待生成', streaming: '生成中', confirm: '待确认', confirmed: '已确认', skipped: '已跳过', }; function buildPanels() { sectionsEl.innerHTML = SECTIONS.map((s, i) => '' + '