/* novel detail page: 章节 / 角色 / 伏笔 三 tab 管理. */ import { escapeHtml, fetchJson, postJson, showError } from "../utils.js"; import { statusBadge } from "../components/status-badge.js"; const NOVEL_ID = window.NOVEL_ID; const alertsEl = document.getElementById("ndAlerts"); /* ---------------- header ---------------- */ async function loadHeader() { const el = document.getElementById("ndHeader"); try { const n = await fetchJson("/api/novels/" + NOVEL_ID); const s = n.stats || {}; const pct = n.target_words > 0 ? Math.min(100, Math.round(((n.current_words || 0) / n.target_words) * 100)) : 0; el.innerHTML = '' + '
' + ' ' + escapeHtml(n.genre || "未分类") + ' ' + statusBadge(n.status) + ' ' + escapeHtml(n.style || "") + '' + '
' + '' + ' 章节 ' + (s.chapter_count || 0) + ' (完成 ' + (s.done_chapters || 0) + ') · ' + ' 总字数 ' + (s.total_words || 0) + ' · ' + ' 角色 ' + (s.character_count || 0) + ' · ' + ' 未回收伏笔 ' + (s.open_foreshadowing || 0) + '
' + '| 章节 | 标题 | 状态 | 字数 |
|---|
| 名字 | 定位 | 状态 | 描述 | " + " |
|---|---|---|---|---|
| " + escapeHtml(c.name) + " | " + "" + escapeHtml(c.role || "") + " | " + "" + statusBadge(c.status) + " | " + '' + escapeHtml((c.description || "").slice(0, 120)) + " | " + '
| 描述 | 埋设 | 回收 | 状态 | " + " |
|---|---|---|---|---|
| ' + escapeHtml((f.description || "").slice(0, 150)) + " | " + "" + (f.planted_chapter ? "第" + f.planted_chapter + "章" : "-") + " | " + "" + (f.resolved_chapter ? "第" + f.resolved_chapter + "章" : "-") + " | " + "" + statusBadge(f.status) + " | " + "" + (f.status !== "resolved" ? '' : "") + " |