Spaces:
Running
Running
root commited on
Commit ·
8a6a2bc
1
Parent(s): 03b02d3
批阅汇总、修改记录(云端草稿 + 每次存版本记改动段落),去掉正文素材栏
Browse files- fanqie/agent.js +14 -2
- fanqie/dist/index.html +2 -2
- fanqie/mount.js +4 -1
- fanqie/projects.js +126 -2
- public/assets/{index-CL3IWhr7.js → index-C12HIUpY.js} +0 -0
- public/assets/{index-Ih3zuQhz.css → index-D_zwU3UE.css} +0 -0
- public/index.html +2 -2
- ui-src/src/api.ts +13 -0
- ui-src/src/rooms/Book.tsx +12 -1
- ui-src/src/rooms/Editor.tsx +42 -69
- ui-src/src/rooms/NotesHub.tsx +134 -0
- ui-src/src/rooms/Review.tsx +1 -1
- ui-src/src/styles.css +21 -0
fanqie/agent.js
CHANGED
|
@@ -475,6 +475,11 @@ module.exports = function buildAgent(express, projects) {
|
|
| 475 |
const cur = sorted.find(c => c.number === n)
|
| 476 |
if (cur) parts.push(`【本次审查:第${n}章 ${cur.title || ''}】\n${await chText(cur)}`)
|
| 477 |
parts.push('【审查须知】\n下面附上作品概览、圣经、全书大纲、章节目录(含每章目标)、本章之前两章的全文、本章之后已经写好的章节全文。提意见前先查后文和大纲:后文已经交代或大纲已经安排的,归为「后文已安排」,不要当成问题。')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 478 |
for (const k of ['overview', 'bible', 'outline', 'toc']) expanded.push(k)
|
| 479 |
const before = sorted.filter(c => c.number >= n - 2 && c.number < n)
|
| 480 |
const after = sorted.filter(c => c.number > n && c.current_version_id)
|
|
@@ -489,6 +494,11 @@ module.exports = function buildAgent(express, projects) {
|
|
| 489 |
if (a === 'overview') parts.push('【作品概览】\n' + JSON.stringify(pick(P.project, ['title', 'genre', 'target_platform', 'target_words', 'pov', 'style', 'premise', 'status']), null, 1))
|
| 490 |
else if (a === 'bible') { const { updated_at, source_material_uids, ...b } = P.bible || {}; parts.push('【作品圣经】\n' + JSON.stringify(b, null, 1)) }
|
| 491 |
else if (a === 'outline') { const { updated_at, ...o } = P.outline || {}; parts.push('【大纲】\n' + JSON.stringify(o, null, 1)) }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 492 |
else if (a === 'toc') parts.push('【章节目录】\n' + P.chapters.map(c => `第${c.number}章 ${c.title || ''}${c.goal ? `|目标:${c.goal}` : ''}${c.word_count ? `|${c.word_count}字` : ''}`).join('\n'))
|
| 493 |
else if (/^chapters:\d+-\d+$/.test(a) || /^chapter:/.test(a)) {
|
| 494 |
let list
|
|
@@ -826,7 +836,8 @@ module.exports = function buildAgent(express, projects) {
|
|
| 826 |
'| 作品全部资料 | `GET /fanqie/api/projects/{作品ID}` | 概览、圣经、大纲、章节目录 |',
|
| 827 |
'| 某章正文 | `GET /fanqie/api/projects/{作品ID}/chapters/{章节ID}` 取 `current_version_id`,再读 `.../versions/{版本ID}` | 续写、修改前先读 |',
|
| 828 |
'| 写作上下文 | `GET /fanqie/api/projects/{作品ID}/context?chapter_id=` | 圣经 + 大纲 + 上一章摘要 |',
|
| 829 |
-
'| 作者批注 | `GET /fanqie/api/projects/{作品ID}/notes?status=open` |
|
|
|
|
| 830 |
'| 作者留言 | `GET /fanqie/api/projects/{作品ID}/requests` | 作者说「处理留言」时读 |',
|
| 831 |
'| 写作规则 | `GET /fanqie/api/agent/rules` | 自查清单、番茄平台规定、AI 写作规范 |',
|
| 832 |
'| 素材馆 · 母题列表 | `GET /fanqie/api/materials/motifs` | 先看有哪些母题和数量 |',
|
|
@@ -842,6 +853,7 @@ module.exports = function buildAgent(express, projects) {
|
|
| 842 |
L.push('**用素材的规矩:** 素材只借结构、情绪和细节的“类型”,写进小说时人名、地名、职业、具体情节都必须换成自己的;不整段搬用卡片里的句子;一章最多借 1–2 条素材。', '')
|
| 843 |
L.push('## 4. 工作流程', '',
|
| 844 |
'0. **先处理作者对分歧的裁决**:`GET /fanqie/api/projects/{作品ID}/peer?todo=1`。每条 `author_decision`:`adopt` = 按协作 AI 的意见改;`keep` = 维持现在的写法(不用改正文);`own` = 按 `author_note` 里作者自己的想法改。改完存新版本,再 `PATCH /fanqie/api/projects/{作品ID}/peer/{item_id}`,body `{"resolved":true,"resolution":"怎么处理的"}`,这条就不再显示。作者没表态的(`author_decision` 为空)不用管。同时读作者的待改批注 `GET /fanqie/api/projects/{作品ID}/notes?status=open`,**不用等作者说「按批注修改」**:逐条回原文核对,是问题就改正文、存新版本,在批注上写 `reply`(为什么是/不是问题、改了什么、牵连检查查了哪几章)并把 `status` 改成 `fixed`;不是问题也要写 `reply` 说明理由。这一步做完才能往下写新章。',
|
|
|
|
| 845 |
'1. **动笔前**:读作者状态(手册 → 作者状态,即本守则第 1 节)、作品资料、上一章结尾;确认本章目标。',
|
| 846 |
'2. **写作**:一章一章写,每章写完存为新版本(`POST .../chapters/{章节ID}/versions`,`created_by` 填 `AI`),不要覆盖作者的版本。',
|
| 847 |
'3. **自查**:写完一章,读 `/fanqie/api/agent/rules` 里的番茄平台规定,逐条检查本章,把结果写入检查记录(见第 5 节)。作者在章节编辑页的「检查」栏看这些结果,那里没有「运行检查」按钮,检查只由你做。',
|
|
@@ -861,7 +873,7 @@ module.exports = function buildAgent(express, projects) {
|
|
| 861 |
L.push('## 6. 协作 AI(另一个 AI,可以派活)', '',
|
| 862 |
`- 当前设置:${cfg.mode === 'surf' ? `Surf Chat(${SURF_MODELS[cfg.surf_model] || cfg.surf_model})` : cfg.endpoint ? `${cfg.mode} 接口` : '接口未配置'};令牌${cfg.token ? `已保存(末 4 位 ${String(cfg.token).slice(-4)}${cfg.refresh_token && cfg.auto_refresh ? ',会自动续期' : ',约 1 小时过期'})` : '未保存'}。令牌只存在服务器上,你看不到也不需要看到。`,
|
| 863 |
'- 它能做的活:`review` 审查(默认)、`research` 调研、`idea` 出主意、`draft` 起草、`other` 其他。例如:问它概览、圣经、大纲是否合乎逻辑;查某个年代的生活细节;给第 X 章出三种冲突方案。',
|
| 864 |
-
'- 提问:`POST /fanqie/api/agent/reviewer/ask`,字段:`project_id`、`task`、`topic`(如「圣经逻辑」)、`question`、`attach`(可选:作品资料 `overview`、`bible`、`outline`、`toc`、`chapters:1-5`、`chapter:{章节ID或章号}`、`review:{章号}`(**审单章用这个**:本章 + 前两章 + 已写好的全部后文 + 概览/圣经/大纲/目录)、`refs`(本书参考素材摘要);共享资料 `rank`(热榜总览)、`rank:{分类,如 1_1141}`、`motif:{母题卡片uid}`、`motif_role:{人物,如 亲兄弟}`、`material:{素材馆uid}`(只给摘要和改写卡)、`rules`(番茄平台规定))、`wait`(最多等几秒,默认 50)、`queue`(默认开:令牌过期时先排队,作者粘贴新令牌或服务器续期成功后自动发出,状态为 `queued`)、`continue`(填上一次的 `ask_id` 或 `"last"`,就在同一个对话里接着问,对方记得上下文)。',
|
| 865 |
'- 回复要几分钟时,接口先返回 `state: "running"`;之后用 `GET /fanqie/api/agent/reviewer/log/{ask_id}?project_id=&wait=120` 取结果(`state` 变成 `done` 或 `error`)。不要重复提问同一件事。',
|
| 866 |
'- 读回复后自己判断采纳哪些——它的意见只是参考,与守则或作者要求冲突时以守则和作者为准。改完用 `PATCH /fanqie/api/agent/reviewer/log/{ask_id}` 回写 `status`(adopted / partial / rejected)和 `response`(怎么处理的)。',
|
| 867 |
'- **你和协作 AI 是同级的**:它的每条意见你都要自己重新想一遍,不能照单全收。两边意见不一致时,**按你的判断执行**,并把分歧逐条记到对应章节的旁栏(作者在章节编辑页的「分歧」栏里看,**绝不写进正文**):`POST /fanqie/api/projects/{project_id}/peer`,body `{"items":[{"chapter_number":11,"ask_id":"…","topic":"一句话主题","reviewer_said":"协作 AI 的意见","my_view":"我的判断和理由","decision":"最后怎么做","verdict":"disagree"}]}`。`verdict` 取 `disagree`(不一致,按我的)/ `partial`(部分采纳)/ `agree`(一致)。不属于某一章的意见不填章节号,算全书层面。查看:`GET /fanqie/api/projects/{project_id}/peer?chapter_id=`;修改或删除:`PATCH` / `DELETE /fanqie/api/projects/{project_id}/peer/{item_id}`。',
|
|
|
|
| 475 |
const cur = sorted.find(c => c.number === n)
|
| 476 |
if (cur) parts.push(`【本次审查:第${n}章 ${cur.title || ''}】\n${await chText(cur)}`)
|
| 477 |
parts.push('【审查须知】\n下面附上作品概览、圣经、全书大纲、章节目录(含每章目标)、本章之前两章的全文、本章之后已经写好的章节全文。提意见前先查后文和大纲:后文已经交代或大纲已经安排的,归为「后文已安排」,不要当成问题。')
|
| 478 |
+
if (cur) {
|
| 479 |
+
const ch = await projects.listChanges(pid, { by: 'author', chapter_id: cur.chapter_id, limit: 5 }).catch(() => null)
|
| 480 |
+
const fmt = h => `第${h.para}段:${h.before.length ? '原「' + h.before.join('/') + '」' : '(新增)'} → ${h.after.length ? '改为「' + h.after.join('/') + '」' : '(删去)'}`
|
| 481 |
+
if (ch && ch.items.length) parts.push('【作者亲手改过本章的地方(作者的决定,提意见时尊重;若与前后文冲突,请指出)】\n' + ch.items.map(c => `${c.at.slice(0, 16).replace('T', ' ')}\n` + c.hunks.slice(0, 20).map(fmt).join('\n')).join('\n\n'))
|
| 482 |
+
}
|
| 483 |
for (const k of ['overview', 'bible', 'outline', 'toc']) expanded.push(k)
|
| 484 |
const before = sorted.filter(c => c.number >= n - 2 && c.number < n)
|
| 485 |
const after = sorted.filter(c => c.number > n && c.current_version_id)
|
|
|
|
| 494 |
if (a === 'overview') parts.push('【作品概览】\n' + JSON.stringify(pick(P.project, ['title', 'genre', 'target_platform', 'target_words', 'pov', 'style', 'premise', 'status']), null, 1))
|
| 495 |
else if (a === 'bible') { const { updated_at, source_material_uids, ...b } = P.bible || {}; parts.push('【作品圣经】\n' + JSON.stringify(b, null, 1)) }
|
| 496 |
else if (a === 'outline') { const { updated_at, ...o } = P.outline || {}; parts.push('【大纲】\n' + JSON.stringify(o, null, 1)) }
|
| 497 |
+
else if (a === 'changes') {
|
| 498 |
+
const ch = await projects.listChanges(pid, { by: 'author', limit: 20 }).catch(() => null)
|
| 499 |
+
const fmt = h => ` 第${h.para}段:${h.before.length ? '原「' + h.before.join('/') + '」' : '(新增)'} → ${h.after.length ? '改为「' + h.after.join('/') + '」' : '(删去)'}`
|
| 500 |
+
parts.push('【作者近期亲手修改】\n' + (ch && ch.items.length ? ch.items.map(c => `第${c.number}章 ${c.title || ''}(${c.at.slice(0, 16).replace('T', ' ')})\n` + c.hunks.slice(0, 20).map(fmt).join('\n')).join('\n') : '(暂无)'))
|
| 501 |
+
}
|
| 502 |
else if (a === 'toc') parts.push('【章节目录】\n' + P.chapters.map(c => `第${c.number}章 ${c.title || ''}${c.goal ? `|目标:${c.goal}` : ''}${c.word_count ? `|${c.word_count}字` : ''}`).join('\n'))
|
| 503 |
else if (/^chapters:\d+-\d+$/.test(a) || /^chapter:/.test(a)) {
|
| 504 |
let list
|
|
|
|
| 836 |
'| 作品全部资料 | `GET /fanqie/api/projects/{作品ID}` | 概览、圣经、大纲、章节目录 |',
|
| 837 |
'| 某章正文 | `GET /fanqie/api/projects/{作品ID}/chapters/{章节ID}` 取 `current_version_id`,再读 `.../versions/{版本ID}` | 续写、修改前先读 |',
|
| 838 |
'| 写作上下文 | `GET /fanqie/api/projects/{作品ID}/context?chapter_id=` | 圣经 + 大纲 + 上一章摘要 |',
|
| 839 |
+
'| 作者批注 | `GET /fanqie/api/projects/{作品ID}/notes?status=open` | 每次开工先读(第 0 步) |',
|
| 840 |
+
'| 修改记录 | `GET /fanqie/api/projects/{作品ID}/changes?by=author` | 作者亲手改正文的记录 + 未存版本的草稿;每次开工先读(第 0.1 步) |',
|
| 841 |
'| 作者留言 | `GET /fanqie/api/projects/{作品ID}/requests` | 作者说「处理留言」时读 |',
|
| 842 |
'| 写作规则 | `GET /fanqie/api/agent/rules` | 自查清单、番茄平台规定、AI 写作规范 |',
|
| 843 |
'| 素材馆 · 母题列表 | `GET /fanqie/api/materials/motifs` | 先看有哪些母题和数量 |',
|
|
|
|
| 853 |
L.push('**用素材的规矩:** 素材只借结构、情绪和细节的“类型”,写进小说时人名、地名、职业、具体情节都必须换成自己的;不整段搬用卡片里的句子;一章最多借 1–2 条素材。', '')
|
| 854 |
L.push('## 4. 工作流程', '',
|
| 855 |
'0. **先处理作者对分歧的裁决**:`GET /fanqie/api/projects/{作品ID}/peer?todo=1`。每条 `author_decision`:`adopt` = 按协作 AI 的意见改;`keep` = 维持现在的写法(不用改正文);`own` = 按 `author_note` 里作者自己的想法改。改完存新版本,再 `PATCH /fanqie/api/projects/{作品ID}/peer/{item_id}`,body `{"resolved":true,"resolution":"怎么处理的"}`,这条就不再显示。作者没表态的(`author_decision` 为空)不用管。同时读作者的待改批注 `GET /fanqie/api/projects/{作品ID}/notes?status=open`,**不用等作者说「按批注修改」**:逐条回原文核对,是问题就改正文、存新版本,在批注上写 `reply`(为什么是/不是问题、改了什么、牵连检查查了哪几章)并把 `status` 改成 `fixed`;不是问题也要写 `reply` 说明理由。这一步做完才能往下写新章。',
|
| 856 |
+
'0.1 **再看作者亲手改过哪里**:`GET /fanqie/api/projects/{作品ID}/changes?by=author&unread=1` 列出作者存为版本时改动的段落(`hunks`:第几段、原文 → 改为),`unsaved_author_drafts` 是作者还在稿纸上、没存为版本的改动。逐条读:作者的改动就是作者的决定,**以后续写、改稿都以作者改过的文字为准,不要改回去**;如果作者的改动和前后文、圣经、大纲有冲突,按牵连检查去改其他章节,或在回复里提醒作者。读完 `PATCH /fanqie/api/projects/{作品ID}/changes/{change_id}`,body `{"by":"写作 AI","note":"看到了什么、做了什么"}`。**有未存版本的草稿时,别给那一章存新版本**,免得覆盖作者正在改的稿子,先提醒作者存版本。',
|
| 857 |
'1. **动笔前**:读作者状态(手册 → 作者状态,即本守则第 1 节)、作品资料、上一章结尾;确认本章目标。',
|
| 858 |
'2. **写作**:一章一章写,每章写完存为新版本(`POST .../chapters/{章节ID}/versions`,`created_by` 填 `AI`),不要覆盖作者的版本。',
|
| 859 |
'3. **自查**:写完一章,读 `/fanqie/api/agent/rules` 里的番茄平台规定,逐条检查本章,把结果写入检查记录(见第 5 节)。作者在章节编辑页的「检查」栏看这些结果,那里没有「运行检查」按钮,检查只由你做。',
|
|
|
|
| 873 |
L.push('## 6. 协作 AI(另一个 AI,可以派活)', '',
|
| 874 |
`- 当前设置:${cfg.mode === 'surf' ? `Surf Chat(${SURF_MODELS[cfg.surf_model] || cfg.surf_model})` : cfg.endpoint ? `${cfg.mode} 接口` : '接口未配置'};令牌${cfg.token ? `已保存(末 4 位 ${String(cfg.token).slice(-4)}${cfg.refresh_token && cfg.auto_refresh ? ',会自动续期' : ',约 1 小时过期'})` : '未保存'}。令牌只存在服务器上,你看不到也不需要看到。`,
|
| 875 |
'- 它能做的活:`review` 审查(默认)、`research` 调研、`idea` 出主意、`draft` 起草、`other` 其他。例如:问它概览、圣经、大纲是否合乎逻辑;查某个年代的生活细节;给第 X 章出三种冲突方案。',
|
| 876 |
+
'- 提问:`POST /fanqie/api/agent/reviewer/ask`,字段:`project_id`、`task`、`topic`(如「圣经逻辑」)、`question`、`attach`(可选:作品资料 `overview`、`bible`、`outline`、`toc`、`chapters:1-5`、`chapter:{章节ID或章号}`、`review:{章号}`(**审单章用这个**:本章 + 前两章 + 已写好的全部后文 + 概览/圣经/大纲/目录)、`refs`(本书参考素材摘要)、`changes`(作者近期亲手改过的段落,`review:` 包里已自动带上本章的);共享资料 `rank`(热榜总览)、`rank:{分类,如 1_1141}`、`motif:{母题卡片uid}`、`motif_role:{人物,如 亲兄弟}`、`material:{素材馆uid}`(只给摘要和改写卡)、`rules`(番茄平台规定))、`wait`(最多等几秒,默认 50)、`queue`(默认开:令牌过期时先排队,作者粘贴新令牌或服务器续期成功后自动发出,状态为 `queued`)、`continue`(填上一次的 `ask_id` 或 `"last"`,就在同一个对话里接着问,对方记得上下文)。',
|
| 877 |
'- 回复要几分钟时,接口先返回 `state: "running"`;之后用 `GET /fanqie/api/agent/reviewer/log/{ask_id}?project_id=&wait=120` 取结果(`state` 变成 `done` 或 `error`)。不要重复提问同一件事。',
|
| 878 |
'- 读回复后自己判断采纳哪些——它的意见只是参考,与守则或作者要求冲突时以守则和作者为准。改完用 `PATCH /fanqie/api/agent/reviewer/log/{ask_id}` 回写 `status`(adopted / partial / rejected)和 `response`(怎么处理的)。',
|
| 879 |
'- **你和协作 AI 是同级的**:它的每条意见你都要自己重新想一遍,不能照单全收。两边意见不一致时,**按你的判断执行**,并把分歧逐条记到对应章节的旁栏(作者在章节编辑页的「分歧」栏里看,**绝不写进正文**):`POST /fanqie/api/projects/{project_id}/peer`,body `{"items":[{"chapter_number":11,"ask_id":"…","topic":"一句话主题","reviewer_said":"协作 AI 的意见","my_view":"我的判断和理由","decision":"最后怎么做","verdict":"disagree"}]}`。`verdict` 取 `disagree`(不一致,按我的)/ `partial`(部分采纳)/ `agree`(一致)。不属于某一章的意见不填章节号,算全书层面。查看:`GET /fanqie/api/projects/{project_id}/peer?chapter_id=`;修改或删除:`PATCH` / `DELETE /fanqie/api/projects/{project_id}/peer/{item_id}`。',
|
fanqie/dist/index.html
CHANGED
|
@@ -8,8 +8,8 @@
|
|
| 8 |
<title>小说写作台</title>
|
| 9 |
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Crect width='64' height='64' rx='12' fill='%23b8432f'/%3E%3Ctext x='32' y='44' font-size='34' text-anchor='middle' fill='%23fff' font-family='serif'%3E%E6%96%87%3C/text%3E%3C/svg%3E" />
|
| 10 |
<script>try{var t=localStorage.getItem('xs_theme');if(t==='night')document.documentElement.dataset.theme='night'}catch(e){}</script>
|
| 11 |
-
<script type="module" crossorigin src="/assets/index-
|
| 12 |
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
| 13 |
</head>
|
| 14 |
<body>
|
| 15 |
<div id="root"></div>
|
|
|
|
| 8 |
<title>小说写作台</title>
|
| 9 |
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Crect width='64' height='64' rx='12' fill='%23b8432f'/%3E%3Ctext x='32' y='44' font-size='34' text-anchor='middle' fill='%23fff' font-family='serif'%3E%E6%96%87%3C/text%3E%3C/svg%3E" />
|
| 10 |
<script>try{var t=localStorage.getItem('xs_theme');if(t==='night')document.documentElement.dataset.theme='night'}catch(e){}</script>
|
| 11 |
+
<script type="module" crossorigin src="/assets/index-C12HIUpY.js"></script>
|
| 12 |
+
<link rel="stylesheet" crossorigin href="/assets/index-D_zwU3UE.css">
|
| 13 |
</head>
|
| 14 |
<body>
|
| 15 |
<div id="root"></div>
|
fanqie/mount.js
CHANGED
|
@@ -53,7 +53,7 @@ module.exports = function mountFanqie(app, passwordOk, express) {
|
|
| 53 |
a: await projects.getVersion(req.params.projectId, req.params.chapterId, req.query.a),
|
| 54 |
b: await projects.getVersion(req.params.projectId, req.params.chapterId, req.query.b)
|
| 55 |
})))
|
| 56 |
-
app.post('/fanqie/api/projects/:projectId/chapters/:chapterId/versions/:versionId/rollback', projectRoute(req => projects.rollback(req.params.projectId, req.params.chapterId, req.params.versionId)))
|
| 57 |
app.post('/fanqie/api/projects/:projectId/chapters/:chapterId/check', projectRoute(req => projects.basicCheck(req.params.projectId, req.params.chapterId)))
|
| 58 |
app.get('/fanqie/api/projects/:projectId/checks/:versionId', projectRoute(req => projects.getCheck(req.params.projectId, req.params.versionId)))
|
| 59 |
app.put('/fanqie/api/projects/:projectId/checks/:versionId', projectRoute(req => projects.saveCheck(req.params.projectId, req.params.versionId, req.body || {})))
|
|
@@ -61,6 +61,9 @@ module.exports = function mountFanqie(app, passwordOk, express) {
|
|
| 61 |
// 协作 AI 意见裁决(逐章旁栏,不进正文)
|
| 62 |
app.get('/fanqie/api/projects/:projectId/peer', projectRoute(req => projects.listPeer(req.params.projectId, req.query.chapter_id ? String(req.query.chapter_id) : '', { todo: req.query.todo === '1' })))
|
| 63 |
app.put('/fanqie/api/projects/:projectId/peer/:itemId/author', projectRoute(req => projects.decidePeer(req.params.projectId, req.params.itemId, req.body || {})))
|
|
|
|
|
|
|
|
|
|
| 64 |
app.get('/fanqie/api/projects/:projectId/progress', projectRoute(req => projects.getProgress(req.params.projectId)))
|
| 65 |
app.put('/fanqie/api/projects/:projectId/progress', projectRoute(req => projects.saveProgress(req.params.projectId, req.body || {})))
|
| 66 |
app.post('/fanqie/api/projects/:projectId/peer', projectRoute(req => projects.addPeer(req.params.projectId, req.body || {}), 201))
|
|
|
|
| 53 |
a: await projects.getVersion(req.params.projectId, req.params.chapterId, req.query.a),
|
| 54 |
b: await projects.getVersion(req.params.projectId, req.params.chapterId, req.query.b)
|
| 55 |
})))
|
| 56 |
+
app.post('/fanqie/api/projects/:projectId/chapters/:chapterId/versions/:versionId/rollback', projectRoute(req => projects.rollback(req.params.projectId, req.params.chapterId, req.params.versionId, (req.body || {}).by)))
|
| 57 |
app.post('/fanqie/api/projects/:projectId/chapters/:chapterId/check', projectRoute(req => projects.basicCheck(req.params.projectId, req.params.chapterId)))
|
| 58 |
app.get('/fanqie/api/projects/:projectId/checks/:versionId', projectRoute(req => projects.getCheck(req.params.projectId, req.params.versionId)))
|
| 59 |
app.put('/fanqie/api/projects/:projectId/checks/:versionId', projectRoute(req => projects.saveCheck(req.params.projectId, req.params.versionId, req.body || {})))
|
|
|
|
| 61 |
// 协作 AI 意见裁决(逐章旁栏,不进正文)
|
| 62 |
app.get('/fanqie/api/projects/:projectId/peer', projectRoute(req => projects.listPeer(req.params.projectId, req.query.chapter_id ? String(req.query.chapter_id) : '', { todo: req.query.todo === '1' })))
|
| 63 |
app.put('/fanqie/api/projects/:projectId/peer/:itemId/author', projectRoute(req => projects.decidePeer(req.params.projectId, req.params.itemId, req.body || {})))
|
| 64 |
+
app.get('/fanqie/api/projects/:projectId/changes', projectRoute(req => projects.listChanges(req.params.projectId, req.query || {})))
|
| 65 |
+
app.patch('/fanqie/api/projects/:projectId/changes/:changeId', projectRoute(req => projects.ackChange(req.params.projectId, req.params.changeId, req.body || {})))
|
| 66 |
+
app.put('/fanqie/api/projects/:projectId/chapters/:chapterId/draft', projectRoute(req => projects.saveAuthorDraft(req.params.projectId, req.params.chapterId, req.body || {})))
|
| 67 |
app.get('/fanqie/api/projects/:projectId/progress', projectRoute(req => projects.getProgress(req.params.projectId)))
|
| 68 |
app.put('/fanqie/api/projects/:projectId/progress', projectRoute(req => projects.saveProgress(req.params.projectId, req.body || {})))
|
| 69 |
app.post('/fanqie/api/projects/:projectId/peer', projectRoute(req => projects.addPeer(req.params.projectId, req.body || {}), 201))
|
fanqie/projects.js
CHANGED
|
@@ -405,10 +405,15 @@ async function saveVersion(projectId, chapterId, body) {
|
|
| 405 |
await writeJson(projectKey(projectId, 'chapters/index.json'), { ...chapters, updated_at: now() })
|
| 406 |
})
|
| 407 |
await touch(projectId, { current_chapter_id: chapterId })
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 408 |
return version
|
| 409 |
})
|
| 410 |
}
|
| 411 |
-
async function rollback(projectId, chapterId, versionId) {
|
| 412 |
const version = await getVersion(projectId, chapterId, versionId)
|
| 413 |
const { chapter } = await getChapterOrThrow(projectId, chapterId)
|
| 414 |
const next = { ...chapter, current_version_id: version.version_id, word_count: [...String(version.text || '').replace(/\s/g, '')].length, status: 'rolled_back', updated_at: now(), revision: Number(chapter.revision || 0) + 1 }
|
|
@@ -420,6 +425,10 @@ async function rollback(projectId, chapterId, versionId) {
|
|
| 420 |
await writeJson(projectKey(projectId, 'chapters/index.json'), { ...chapters, updated_at: now() })
|
| 421 |
})
|
| 422 |
await touch(projectId, { current_chapter_id: chapterId })
|
|
|
|
|
|
|
|
|
|
|
|
|
| 423 |
return { chapter: next, version }
|
| 424 |
}
|
| 425 |
|
|
@@ -719,6 +728,121 @@ async function deletePeer(projectId, itemId) {
|
|
| 719 |
})
|
| 720 |
}
|
| 721 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 722 |
/* 阅读进度(通读页 + 每章稿纸),存 R2,换设备也能接着读 */
|
| 723 |
function progressKey(projectId) { return projectKey(projectId, 'progress.json') }
|
| 724 |
async function getProgress(projectId) {
|
|
@@ -747,7 +871,7 @@ async function saveProgress(projectId, body) {
|
|
| 747 |
}
|
| 748 |
|
| 749 |
module.exports = {
|
| 750 |
-
getProgress, saveProgress, decidePeer,
|
| 751 |
listProjects, createProject, getProject, updateProject, deleteProject, saveBible, saveOutline, saveMaterials,
|
| 752 |
listChapters, createChapter, getChapter: getChapterOrThrow, updateChapter,
|
| 753 |
listVersions, getVersion, saveVersion, rollback, saveCheck, getCheck, basicCheck, getContext,
|
|
|
|
| 405 |
await writeJson(projectKey(projectId, 'chapters/index.json'), { ...chapters, updated_at: now() })
|
| 406 |
})
|
| 407 |
await touch(projectId, { current_chapter_id: chapterId })
|
| 408 |
+
const prev = chapter.current_version_id ? await readJson(projectKey(projectId, `chapters/${chapterId}/versions/${chapter.current_version_id}.json`), null) : null
|
| 409 |
+
const diff = paraDiff(prev?.text || '', text)
|
| 410 |
+
const byAuthor = version.created_by === 'author'
|
| 411 |
+
await logChange(projectId, chapter, { kind: 'save', by: byLabel(version.created_by), by_author: byAuthor, from_version_id: chapter.current_version_id || null, to_version_id: versionId, summary: version.summary, ...diff })
|
| 412 |
+
if (byAuthor) await clearAuthorDraft(projectId, chapterId)
|
| 413 |
return version
|
| 414 |
})
|
| 415 |
}
|
| 416 |
+
async function rollback(projectId, chapterId, versionId, by) {
|
| 417 |
const version = await getVersion(projectId, chapterId, versionId)
|
| 418 |
const { chapter } = await getChapterOrThrow(projectId, chapterId)
|
| 419 |
const next = { ...chapter, current_version_id: version.version_id, word_count: [...String(version.text || '').replace(/\s/g, '')].length, status: 'rolled_back', updated_at: now(), revision: Number(chapter.revision || 0) + 1 }
|
|
|
|
| 425 |
await writeJson(projectKey(projectId, 'chapters/index.json'), { ...chapters, updated_at: now() })
|
| 426 |
})
|
| 427 |
await touch(projectId, { current_chapter_id: chapterId })
|
| 428 |
+
if (chapter.current_version_id !== version.version_id) {
|
| 429 |
+
const prev = chapter.current_version_id ? await readJson(projectKey(projectId, `chapters/${chapterId}/versions/${chapter.current_version_id}.json`), null) : null
|
| 430 |
+
await logChange(projectId, chapter, { kind: 'rollback', by: byLabel(by || 'author'), by_author: (by || 'author') === 'author', from_version_id: chapter.current_version_id || null, to_version_id: version.version_id, summary: '恢复到旧版本', ...paraDiff(prev?.text || '', version.text) })
|
| 431 |
+
}
|
| 432 |
return { chapter: next, version }
|
| 433 |
}
|
| 434 |
|
|
|
|
| 728 |
})
|
| 729 |
}
|
| 730 |
|
| 731 |
+
/* 修改记录:每次存版本/恢复版本都记一笔(谁、何时、哪几段从什么改成什么),
|
| 732 |
+
* 作者在稿纸上还没存为版本的改动也会同步一份到云端草稿。写作 AI 和协作 AI 都从这里读。 */
|
| 733 |
+
function changesKey(projectId) { return projectKey(projectId, 'changes.json') }
|
| 734 |
+
function draftsKey(projectId) { return projectKey(projectId, 'author_drafts.json') }
|
| 735 |
+
function splitParas(t) { return String(t || '').split(/\n+/).map(s => s.trim()).filter(Boolean) }
|
| 736 |
+
function paraDiff(a, b) {
|
| 737 |
+
const A = splitParas(a), B = splitParas(b)
|
| 738 |
+
let pre = 0
|
| 739 |
+
while (pre < A.length && pre < B.length && A[pre] === B[pre]) pre++
|
| 740 |
+
let suf = 0
|
| 741 |
+
while (suf < A.length - pre && suf < B.length - pre && A[A.length - 1 - suf] === B[B.length - 1 - suf]) suf++
|
| 742 |
+
const a2 = A.slice(pre, A.length - suf), b2 = B.slice(pre, B.length - suf)
|
| 743 |
+
const n = a2.length, m = b2.length
|
| 744 |
+
const rows = []
|
| 745 |
+
if (n * m > 4000000) { a2.forEach(t => rows.push(['del', t])); b2.forEach(t => rows.push(['add', t])) } else {
|
| 746 |
+
const dp = Array.from({ length: n + 1 }, () => new Uint32Array(m + 1))
|
| 747 |
+
for (let i = n - 1; i >= 0; i--) for (let j = m - 1; j >= 0; j--) dp[i][j] = a2[i] === b2[j] ? dp[i + 1][j + 1] + 1 : Math.max(dp[i + 1][j], dp[i][j + 1])
|
| 748 |
+
let i = 0, j = 0
|
| 749 |
+
while (i < n && j < m) {
|
| 750 |
+
if (a2[i] === b2[j]) { rows.push(['same', a2[i]]); i++; j++ } else if (dp[i + 1][j] >= dp[i][j + 1]) rows.push(['del', a2[i++]]); else rows.push(['add', b2[j++]])
|
| 751 |
+
}
|
| 752 |
+
while (i < n) rows.push(['del', a2[i++]])
|
| 753 |
+
while (j < m) rows.push(['add', b2[j++]])
|
| 754 |
+
}
|
| 755 |
+
const hunks = []
|
| 756 |
+
let cur = null, newIdx = pre
|
| 757 |
+
const clip = t => t.length > 1500 ? t.slice(0, 1500) + '…' : t
|
| 758 |
+
for (const [type, t] of rows) {
|
| 759 |
+
if (type === 'same') { cur = null; newIdx++; continue }
|
| 760 |
+
if (!cur) { cur = { para: newIdx + 1, before: [], after: [] }; hunks.push(cur) }
|
| 761 |
+
if (type === 'del') cur.before.push(clip(t)); else { cur.after.push(clip(t)); newIdx++ }
|
| 762 |
+
}
|
| 763 |
+
const added = [...String(b || '').replace(/\s/g, '')].length - [...String(a || '').replace(/\s/g, '')].length
|
| 764 |
+
return { hunks: hunks.slice(0, 120), hunk_count: hunks.length, word_delta: added }
|
| 765 |
+
}
|
| 766 |
+
function byLabel(v) { const s = String(v || ''); return s === 'author' ? '作者' : s === 'surf' ? '写作 AI' : s }
|
| 767 |
+
async function logChange(projectId, chapter, entry) {
|
| 768 |
+
try {
|
| 769 |
+
await withLock(`changes:${projectId}`, async () => {
|
| 770 |
+
const d = await readJson(changesKey(projectId), { items: [] })
|
| 771 |
+
const item = { change_id: id('change'), chapter_id: chapter.chapter_id, number: chapter.number, title: chapter.title, at: now(), ...entry }
|
| 772 |
+
d.items = [item, ...(d.items || [])].slice(0, 3000)
|
| 773 |
+
d.updated_at = now()
|
| 774 |
+
await writeJson(changesKey(projectId), d)
|
| 775 |
+
})
|
| 776 |
+
} catch (e) { console.error('[changes] log failed', e.message) }
|
| 777 |
+
}
|
| 778 |
+
async function listChanges(projectId, q = {}) {
|
| 779 |
+
await getProjectOrThrow(projectId)
|
| 780 |
+
const d = await readJson(changesKey(projectId), { items: [] })
|
| 781 |
+
let items = d.items || []
|
| 782 |
+
if (q.by === 'author') items = items.filter(x => x.by_author)
|
| 783 |
+
else if (q.by === 'ai') items = items.filter(x => !x.by_author)
|
| 784 |
+
if (q.chapter_id) items = items.filter(x => x.chapter_id === q.chapter_id)
|
| 785 |
+
if (q.since) items = items.filter(x => String(x.at) > String(q.since))
|
| 786 |
+
if (q.unread === '1' || q.unread === 'true') items = items.filter(x => x.by_author && !(x.acks || []).length)
|
| 787 |
+
const limit = Math.max(1, Math.min(500, Number(q.limit) || 100))
|
| 788 |
+
const dr = await readJson(draftsKey(projectId), { drafts: {} })
|
| 789 |
+
const drafts = []
|
| 790 |
+
for (const [cid, m] of Object.entries(dr.drafts || {})) {
|
| 791 |
+
const draft = await readJson(projectKey(projectId, `chapters/${cid}/author_draft.json`), null)
|
| 792 |
+
if (!draft) continue
|
| 793 |
+
const chapter = await readJson(projectKey(projectId, `chapters/${cid}/chapter.json`), null)
|
| 794 |
+
if (!chapter) continue
|
| 795 |
+
const cur = chapter.current_version_id ? await readJson(projectKey(projectId, `chapters/${cid}/versions/${chapter.current_version_id}.json`), null) : null
|
| 796 |
+
const diff = paraDiff(cur?.text || '', draft.text)
|
| 797 |
+
if (!diff.hunk_count) continue
|
| 798 |
+
drafts.push({ chapter_id: cid, number: chapter.number, title: chapter.title, at: draft.at || m.at, base_version_id: draft.base || null, current_version_id: chapter.current_version_id || null, ...diff })
|
| 799 |
+
}
|
| 800 |
+
drafts.sort((a, b) => a.number - b.number)
|
| 801 |
+
return { items: items.slice(0, limit), total: items.length, unsaved_author_drafts: drafts, updated_at: d.updated_at || null }
|
| 802 |
+
}
|
| 803 |
+
async function ackChange(projectId, changeId, body) {
|
| 804 |
+
await getProjectOrThrow(projectId)
|
| 805 |
+
return withLock(`changes:${projectId}`, async () => {
|
| 806 |
+
const d = await readJson(changesKey(projectId), { items: [] })
|
| 807 |
+
const it = (d.items || []).find(x => x.change_id === changeId)
|
| 808 |
+
if (!it) throw new HttpError(404, '没有这条修改记录')
|
| 809 |
+
const who = String(body?.by || '写作 AI').slice(0, 40)
|
| 810 |
+
it.acks = [...(it.acks || []).filter(a => a.by !== who), { by: who, note: String(body?.note || '').slice(0, 2000), at: now() }]
|
| 811 |
+
await writeJson(changesKey(projectId), { ...d, updated_at: now() })
|
| 812 |
+
return it
|
| 813 |
+
})
|
| 814 |
+
}
|
| 815 |
+
async function saveAuthorDraft(projectId, chapterId, body) {
|
| 816 |
+
const { chapter } = await getChapterOrThrow(projectId, chapterId)
|
| 817 |
+
const cid = chapter.chapter_id
|
| 818 |
+
const text = String(body?.text || '')
|
| 819 |
+
await withLock(`drafts:${projectId}`, async () => {
|
| 820 |
+
const dr = await readJson(draftsKey(projectId), { drafts: {} })
|
| 821 |
+
dr.drafts = dr.drafts || {}
|
| 822 |
+
if (!text.trim()) {
|
| 823 |
+
if (!dr.drafts || !dr.drafts[cid]) return
|
| 824 |
+
delete dr.drafts[cid]
|
| 825 |
+
await writeJson(projectKey(projectId, `chapters/${cid}/author_draft.json`), null)
|
| 826 |
+
} else {
|
| 827 |
+
dr.drafts[cid] = { at: now() }
|
| 828 |
+
await writeJson(projectKey(projectId, `chapters/${cid}/author_draft.json`), { text: text.slice(0, 400000), base: body?.base || null, at: now() })
|
| 829 |
+
}
|
| 830 |
+
await writeJson(draftsKey(projectId), { ...dr, updated_at: now() })
|
| 831 |
+
})
|
| 832 |
+
return { ok: true }
|
| 833 |
+
}
|
| 834 |
+
async function clearAuthorDraft(projectId, chapterId) {
|
| 835 |
+
try {
|
| 836 |
+
await withLock(`drafts:${projectId}`, async () => {
|
| 837 |
+
const dr = await readJson(draftsKey(projectId), { drafts: {} })
|
| 838 |
+
if (!dr.drafts || !dr.drafts[chapterId]) return
|
| 839 |
+
delete dr.drafts[chapterId]
|
| 840 |
+
await writeJson(projectKey(projectId, `chapters/${chapterId}/author_draft.json`), null)
|
| 841 |
+
await writeJson(draftsKey(projectId), { ...dr, updated_at: now() })
|
| 842 |
+
})
|
| 843 |
+
} catch (e) { console.error('[drafts] clear failed', e.message) }
|
| 844 |
+
}
|
| 845 |
+
|
| 846 |
/* 阅读进度(通读页 + 每章稿纸),存 R2,换设备也能接着读 */
|
| 847 |
function progressKey(projectId) { return projectKey(projectId, 'progress.json') }
|
| 848 |
async function getProgress(projectId) {
|
|
|
|
| 871 |
}
|
| 872 |
|
| 873 |
module.exports = {
|
| 874 |
+
getProgress, saveProgress, decidePeer, listChanges, ackChange, saveAuthorDraft, paraDiff,
|
| 875 |
listProjects, createProject, getProject, updateProject, deleteProject, saveBible, saveOutline, saveMaterials,
|
| 876 |
listChapters, createChapter, getChapter: getChapterOrThrow, updateChapter,
|
| 877 |
listVersions, getVersion, saveVersion, rollback, saveCheck, getCheck, basicCheck, getContext,
|
public/assets/{index-CL3IWhr7.js → index-C12HIUpY.js}
RENAMED
|
The diff for this file is too large to render.
See raw diff
|
|
|
public/assets/{index-Ih3zuQhz.css → index-D_zwU3UE.css}
RENAMED
|
The diff for this file is too large to render.
See raw diff
|
|
|
public/index.html
CHANGED
|
@@ -8,8 +8,8 @@
|
|
| 8 |
<title>小说写作台</title>
|
| 9 |
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Crect width='64' height='64' rx='12' fill='%23b8432f'/%3E%3Ctext x='32' y='44' font-size='34' text-anchor='middle' fill='%23fff' font-family='serif'%3E%E6%96%87%3C/text%3E%3C/svg%3E" />
|
| 10 |
<script>try{var t=localStorage.getItem('xs_theme');if(t==='night')document.documentElement.dataset.theme='night'}catch(e){}</script>
|
| 11 |
-
<script type="module" crossorigin src="/assets/index-
|
| 12 |
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
| 13 |
</head>
|
| 14 |
<body>
|
| 15 |
<div id="root"></div>
|
|
|
|
| 8 |
<title>小说写作台</title>
|
| 9 |
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Crect width='64' height='64' rx='12' fill='%23b8432f'/%3E%3Ctext x='32' y='44' font-size='34' text-anchor='middle' fill='%23fff' font-family='serif'%3E%E6%96%87%3C/text%3E%3C/svg%3E" />
|
| 10 |
<script>try{var t=localStorage.getItem('xs_theme');if(t==='night')document.documentElement.dataset.theme='night'}catch(e){}</script>
|
| 11 |
+
<script type="module" crossorigin src="/assets/index-C12HIUpY.js"></script>
|
| 12 |
+
<link rel="stylesheet" crossorigin href="/assets/index-D_zwU3UE.css">
|
| 13 |
</head>
|
| 14 |
<body>
|
| 15 |
<div id="root"></div>
|
ui-src/src/api.ts
CHANGED
|
@@ -201,6 +201,9 @@ export const projectsApi = {
|
|
| 201 |
decidePeer: (id: string, itemId: string, body: { decision: '' | 'adopt' | 'keep' | 'own'; note?: string }) => put<PeerItem>(`${P}/${id}/peer/${itemId}/author`, body),
|
| 202 |
progress: (id: string) => get<ReadProgress>(`${P}/${id}/progress`),
|
| 203 |
saveProgress: (id: string, body: { reader?: { chapter_id: string; para: number; ratio?: number }; chapter?: { chapter_id: string; read_para?: number; read_ratio?: number; edit_ratio?: number } }) => put<ReadProgress>(`${P}/${id}/progress`, body),
|
|
|
|
|
|
|
|
|
|
| 204 |
createNote: (id: string, cid: string, body: Partial<Note>) => post<Note>(`${P}/${id}/chapters/${cid}/notes`, body),
|
| 205 |
updateNote: (id: string, cid: string, nid: string, body: Partial<Note>) => patch<Note>(`${P}/${id}/chapters/${cid}/notes/${nid}`, body),
|
| 206 |
deleteNote: (id: string, cid: string, nid: string) => del(`${P}/${id}/chapters/${cid}/notes/${nid}`),
|
|
@@ -212,6 +215,16 @@ export interface Note {
|
|
| 212 |
type: string; severity: 'must' | 'should' | 'maybe'; comment: string; suggestion?: string; reply?: string
|
| 213 |
status: 'open' | 'fixed' | 'closed' | 'wontfix'; created_by: string; created_at: string; updated_at?: string
|
| 214 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 215 |
export interface Review { review_id: string; version_id?: string | null; scores: Record<string, number>; summary: string; verdict: 'pass' | 'revise' | 'rewrite'; created_by: string; created_at: string }
|
| 216 |
|
| 217 |
const M = '/fanqie/api/materials'
|
|
|
|
| 201 |
decidePeer: (id: string, itemId: string, body: { decision: '' | 'adopt' | 'keep' | 'own'; note?: string }) => put<PeerItem>(`${P}/${id}/peer/${itemId}/author`, body),
|
| 202 |
progress: (id: string) => get<ReadProgress>(`${P}/${id}/progress`),
|
| 203 |
saveProgress: (id: string, body: { reader?: { chapter_id: string; para: number; ratio?: number }; chapter?: { chapter_id: string; read_para?: number; read_ratio?: number; edit_ratio?: number } }) => put<ReadProgress>(`${P}/${id}/progress`, body),
|
| 204 |
+
allNotes: (id: string, status?: string) => get<{ chapters: { chapter_id: string; number: number; title: string; current_version_id: string | null; notes: Note[] }[] }>(`${P}/${id}/notes${qs({ status })}`),
|
| 205 |
+
changes: (id: string, p: { by?: string; chapter_id?: string; limit?: number } = {}) => get<ChangeList>(`${P}/${id}/changes${qs(p)}`),
|
| 206 |
+
saveDraft: (id: string, cid: string, body: { text: string; base: string | null }) => put<{ ok: boolean }>(`${P}/${id}/chapters/${cid}/draft`, body),
|
| 207 |
createNote: (id: string, cid: string, body: Partial<Note>) => post<Note>(`${P}/${id}/chapters/${cid}/notes`, body),
|
| 208 |
updateNote: (id: string, cid: string, nid: string, body: Partial<Note>) => patch<Note>(`${P}/${id}/chapters/${cid}/notes/${nid}`, body),
|
| 209 |
deleteNote: (id: string, cid: string, nid: string) => del(`${P}/${id}/chapters/${cid}/notes/${nid}`),
|
|
|
|
| 215 |
type: string; severity: 'must' | 'should' | 'maybe'; comment: string; suggestion?: string; reply?: string
|
| 216 |
status: 'open' | 'fixed' | 'closed' | 'wontfix'; created_by: string; created_at: string; updated_at?: string
|
| 217 |
}
|
| 218 |
+
export interface ChangeHunk { para: number; before: string[]; after: string[] }
|
| 219 |
+
export interface ChangeItem {
|
| 220 |
+
change_id: string; chapter_id: string; number: number; title: string; at: string; kind: 'save' | 'rollback'; by: string; by_author: boolean
|
| 221 |
+
from_version_id: string | null; to_version_id: string; summary?: string; hunks: ChangeHunk[]; hunk_count: number; word_delta: number
|
| 222 |
+
acks?: { by: string; note: string; at: string }[]
|
| 223 |
+
}
|
| 224 |
+
export interface ChangeList {
|
| 225 |
+
items: ChangeItem[]; total: number; updated_at: string | null
|
| 226 |
+
unsaved_author_drafts: { chapter_id: string; number: number; title: string; at: string; hunks: ChangeHunk[]; hunk_count: number; word_delta: number }[]
|
| 227 |
+
}
|
| 228 |
export interface Review { review_id: string; version_id?: string | null; scores: Record<string, number>; summary: string; verdict: 'pass' | 'revise' | 'rewrite'; created_by: string; created_at: string }
|
| 229 |
|
| 230 |
const M = '/fanqie/api/materials'
|
ui-src/src/rooms/Book.tsx
CHANGED
|
@@ -1,11 +1,12 @@
|
|
| 1 |
import React, { useCallback, useEffect, useMemo, useState } from 'react'
|
| 2 |
-
import { ChevronLeft, ScrollText, Users, ListTree, Bookmark, Plus, PanelLeftClose, PanelLeftOpen, Info, FileText, BookOpenText } from 'lucide-react'
|
| 3 |
import { Chapter, ProjectBundle, projectsApi } from '../api'
|
| 4 |
import { cnNum, cx, fmtAgo, fmtDate, fmtNum, go, CHAPTER_STATUS, PROJECT_STATUS, useLocal } from '../lib'
|
| 5 |
import { ErrorNote, Field, Loading, useConfirm, useToast, AutoText, Empty } from '../ui'
|
| 6 |
import ChapterEditor from './Editor'
|
| 7 |
import { BibleView, OutlineView, RefsView } from './Bible'
|
| 8 |
import Reader from './Reader'
|
|
|
|
| 9 |
import { useBookProgress, pct, isDone } from './progress'
|
| 10 |
|
| 11 |
export type BookCtx = {
|
|
@@ -71,6 +72,7 @@ export default function Book({ projectId, sub, arg = '' }: { projectId: string;
|
|
| 71 |
else if (sub === 'bible') main = <BibleView ctx={ctx} />
|
| 72 |
else if (sub === 'outline') main = <OutlineView ctx={ctx} />
|
| 73 |
else if (sub === 'refs') main = <RefsView ctx={ctx} />
|
|
|
|
| 74 |
else if (chapter) main = <ChapterEditor key={chapter.chapter_id} ctx={ctx} chapter={chapter} />
|
| 75 |
else if (sub && sub !== 'about') main = <div className="page"><Empty title="找不到这一章" >它可能已被移动。<button className="link-btn" onClick={() => go(`book/${projectId}/about`)}>回到作品概览</button></Empty></div>
|
| 76 |
else main = <BookAbout ctx={ctx} onAddChapter={addChapter} />
|
|
@@ -102,6 +104,13 @@ function Binder({ ctx, sub, onAddChapter, onCollapse }: { ctx: BookCtx; sub: str
|
|
| 102 |
}, [bundle.chapters])
|
| 103 |
const refs = bundle.materials?.items?.length || 0
|
| 104 |
const chars = bundle.bible?.characters?.length || 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
const totalWords = bundle.chapters.reduce((n, c) => n + (c.word_count || 0), 0)
|
| 106 |
const prog = useBookProgress(pid)
|
| 107 |
return (
|
|
@@ -122,6 +131,8 @@ function Binder({ ctx, sub, onAddChapter, onCollapse }: { ctx: BookCtx; sub: str
|
|
| 122 |
<BinderLink on={sub === 'bible'} icon={<Users size={15} />} onClick={() => go(`book/${pid}/bible`)} meta={chars ? `${chars} 人` : ''}>作品圣经</BinderLink>
|
| 123 |
<BinderLink on={sub === 'outline'} icon={<ListTree size={15} />} onClick={() => go(`book/${pid}/outline`)}>大纲</BinderLink>
|
| 124 |
<BinderLink on={sub === 'refs'} icon={<Bookmark size={15} />} onClick={() => go(`book/${pid}/refs`)} meta={`${refs}/3`}>参考素材</BinderLink>
|
|
|
|
|
|
|
| 125 |
<BinderLink on={sub === 'read'} icon={<BookOpenText size={15} />} onClick={() => go(`book/${pid}/read`)} meta={totalWords ? `${fmtNum(totalWords)} 字` : ''}>通读全书</BinderLink>
|
| 126 |
</div>
|
| 127 |
|
|
|
|
| 1 |
import React, { useCallback, useEffect, useMemo, useState } from 'react'
|
| 2 |
+
import { ChevronLeft, ScrollText, Users, ListTree, Bookmark, Plus, PanelLeftClose, PanelLeftOpen, Info, FileText, BookOpenText, Highlighter, History } from 'lucide-react'
|
| 3 |
import { Chapter, ProjectBundle, projectsApi } from '../api'
|
| 4 |
import { cnNum, cx, fmtAgo, fmtDate, fmtNum, go, CHAPTER_STATUS, PROJECT_STATUS, useLocal } from '../lib'
|
| 5 |
import { ErrorNote, Field, Loading, useConfirm, useToast, AutoText, Empty } from '../ui'
|
| 6 |
import ChapterEditor from './Editor'
|
| 7 |
import { BibleView, OutlineView, RefsView } from './Bible'
|
| 8 |
import Reader from './Reader'
|
| 9 |
+
import NotesHub from './NotesHub'
|
| 10 |
import { useBookProgress, pct, isDone } from './progress'
|
| 11 |
|
| 12 |
export type BookCtx = {
|
|
|
|
| 72 |
else if (sub === 'bible') main = <BibleView ctx={ctx} />
|
| 73 |
else if (sub === 'outline') main = <OutlineView ctx={ctx} />
|
| 74 |
else if (sub === 'refs') main = <RefsView ctx={ctx} />
|
| 75 |
+
else if (sub === 'notes' || sub === 'changes') main = <NotesHub key={sub} ctx={ctx} initial={sub} />
|
| 76 |
else if (chapter) main = <ChapterEditor key={chapter.chapter_id} ctx={ctx} chapter={chapter} />
|
| 77 |
else if (sub && sub !== 'about') main = <div className="page"><Empty title="找不到这一章" >它可能已被移动。<button className="link-btn" onClick={() => go(`book/${projectId}/about`)}>回到作品概览</button></Empty></div>
|
| 78 |
else main = <BookAbout ctx={ctx} onAddChapter={addChapter} />
|
|
|
|
| 104 |
}, [bundle.chapters])
|
| 105 |
const refs = bundle.materials?.items?.length || 0
|
| 106 |
const chars = bundle.bible?.characters?.length || 0
|
| 107 |
+
const [openNotes, setOpenNotes] = useState(0)
|
| 108 |
+
useEffect(() => {
|
| 109 |
+
let alive = true
|
| 110 |
+
const pull = () => projectsApi.allNotes(pid, 'open').then(r => { if (alive) setOpenNotes(r.chapters.reduce((s, c) => s + c.notes.length, 0)) }, () => {})
|
| 111 |
+
pull()
|
| 112 |
+
return () => { alive = false }
|
| 113 |
+
}, [pid, sub])
|
| 114 |
const totalWords = bundle.chapters.reduce((n, c) => n + (c.word_count || 0), 0)
|
| 115 |
const prog = useBookProgress(pid)
|
| 116 |
return (
|
|
|
|
| 131 |
<BinderLink on={sub === 'bible'} icon={<Users size={15} />} onClick={() => go(`book/${pid}/bible`)} meta={chars ? `${chars} 人` : ''}>作品圣经</BinderLink>
|
| 132 |
<BinderLink on={sub === 'outline'} icon={<ListTree size={15} />} onClick={() => go(`book/${pid}/outline`)}>大纲</BinderLink>
|
| 133 |
<BinderLink on={sub === 'refs'} icon={<Bookmark size={15} />} onClick={() => go(`book/${pid}/refs`)} meta={`${refs}/3`}>参考素材</BinderLink>
|
| 134 |
+
<BinderLink on={sub === 'notes'} icon={<Highlighter size={15} />} onClick={() => go(`book/${pid}/notes`)} meta={openNotes ? `${openNotes} 待改` : ''}>批阅汇总</BinderLink>
|
| 135 |
+
<BinderLink on={sub === 'changes'} icon={<History size={15} />} onClick={() => go(`book/${pid}/changes`)}>修改记录</BinderLink>
|
| 136 |
<BinderLink on={sub === 'read'} icon={<BookOpenText size={15} />} onClick={() => go(`book/${pid}/read`)} meta={totalWords ? `${fmtNum(totalWords)} 字` : ''}>通读全书</BinderLink>
|
| 137 |
</div>
|
| 138 |
|
ui-src/src/rooms/Editor.tsx
CHANGED
|
@@ -1,20 +1,18 @@
|
|
| 1 |
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
| 2 |
import {
|
| 3 |
-
Save, Maximize2, Minimize2, PanelRightClose, PanelRightOpen, History, ClipboardCheck,
|
| 4 |
-
Type, AlignLeft, RotateCcw, Eye, GitCompare, Copy,
|
| 5 |
} from 'lucide-react'
|
| 6 |
import { locateNotes, NotesPanel, ReviewText, segmentText, useNotes } from './Review'
|
| 7 |
-
import { agentApi, Chapter,
|
| 8 |
import { AskLog, AuditCard, SayToAi } from './Agent'
|
| 9 |
import { PeerPanel, locateDisputes, peerCount, usePeer } from './Peer'
|
| 10 |
-
import { cnNum, copyText, countWords, cx, diffParagraphs, fmtAgo, fmtDate, go, CHAPTER_STATUS,
|
| 11 |
import { AutoText, Empty, ErrorNote, Field, ListEditor, Loading, Modal, Spinner, Tabs, useConfirm, useToast, Segmented, Tag } from '../ui'
|
| 12 |
import type { BookCtx } from './Book'
|
| 13 |
-
import { toRef } from './Bible'
|
| 14 |
-
import { feedApi } from './RankInspire'
|
| 15 |
import { noteProgress, pct } from './progress'
|
| 16 |
|
| 17 |
-
type Tab = 'chapter' | 'notes' | 'peer' | 'check' | 'ai' | 'versions'
|
| 18 |
const draftKey = (cid: string) => `xs_draft_${cid}`
|
| 19 |
type Draft = { text: string; base: string | null; at: string }
|
| 20 |
const readDraft = (cid: string): Draft | null => { try { return JSON.parse(localStorage.getItem(draftKey(cid)) || 'null') } catch { return null } }
|
|
@@ -44,6 +42,7 @@ export default function ChapterEditor({ ctx, chapter }: { ctx: BookCtx; chapter:
|
|
| 44 |
return () => window.removeEventListener('xs:inspector-close', off)
|
| 45 |
}, [setInspectorRaw])
|
| 46 |
const [tab, setTab] = useLocal<Tab>('xs_inspector_tab', 'chapter')
|
|
|
|
| 47 |
const [fontSize, setFontSize] = useLocal('xs_font', 19)
|
| 48 |
const [pageWidth, setPageWidth] = useLocal<'narrow' | 'normal' | 'wide'>('xs_page_width', 'normal')
|
| 49 |
const [title, setTitle] = useState(chapter.title)
|
|
@@ -67,6 +66,16 @@ export default function ChapterEditor({ ctx, chapter }: { ctx: BookCtx; chapter:
|
|
| 67 |
} catch (e: any) { toast(e.message, 'err'); return false }
|
| 68 |
}
|
| 69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
/* 载入章节和当前版本 */
|
| 71 |
const [ready, setReady] = useState(false)
|
| 72 |
const load = useCallback(async () => {
|
|
@@ -103,6 +112,7 @@ export default function ChapterEditor({ ctx, chapter }: { ctx: BookCtx; chapter:
|
|
| 103 |
useEffect(() => {
|
| 104 |
if (!detail || !ready || restoredFor.current === cid) return
|
| 105 |
restoredFor.current = cid
|
|
|
|
| 106 |
const local = Number(localStorage.getItem(`xs_epos_${cid}`) || 'NaN')
|
| 107 |
const apply = (r: number) => requestAnimationFrame(() => requestAnimationFrame(() => {
|
| 108 |
const el = scrollRef.current
|
|
@@ -116,6 +126,18 @@ export default function ChapterEditor({ ctx, chapter }: { ctx: BookCtx; chapter:
|
|
| 116 |
if (!isNaN(local)) apply(local)
|
| 117 |
else projectsApi.progress(pid).then(p => { const r = p.chapters?.[cid]?.edit_ratio; if (r != null) apply(r) }, () => {})
|
| 118 |
}, [detail, ready, cid, pid])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
const onScroll = () => {
|
| 120 |
const el = scrollRef.current
|
| 121 |
if (!el) return
|
|
@@ -144,6 +166,18 @@ export default function ChapterEditor({ ctx, chapter }: { ctx: BookCtx; chapter:
|
|
| 144 |
} catch {}
|
| 145 |
}, [debounced, savedText, detail, cid])
|
| 146 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 147 |
/* 自动增高:撑高稿纸的同时保住看到的位置(开关侧栏、换字号都不跳回开头) */
|
| 148 |
const fitTa = (byRatio: boolean) => {
|
| 149 |
const el = taRef.current, sc = scrollRef.current
|
|
@@ -265,7 +299,7 @@ export default function ChapterEditor({ ctx, chapter }: { ctx: BookCtx; chapter:
|
|
| 265 |
if (loadErr) return <div className="page"><ErrorNote error={loadErr} onRetry={load} /></div>
|
| 266 |
if (!detail) return <Loading label="正在铺开稿纸…" />
|
| 267 |
|
| 268 |
-
const st = saving ? { k: 'saving', full: '正在保存', short: '保存中' } : dirty ? { k: 'dirty', full: '
|
| 269 |
const showInspector = inspector && !focus
|
| 270 |
const nextCh = [...bundle.chapters].sort((a, b) => a.number - b.number).find(c => c.number > detail.number && c.current_version_id)
|
| 271 |
|
|
@@ -339,7 +373,6 @@ export default function ChapterEditor({ ctx, chapter }: { ctx: BookCtx; chapter:
|
|
| 339 |
{ id: 'check', label: <><ClipboardCheck size={14} />检查</> },
|
| 340 |
{ id: 'ai', label: <><Sparkles size={14} />AI 和协作 AI</> },
|
| 341 |
{ id: 'versions', label: <><History size={14} />版本</>, count: versions.length || undefined },
|
| 342 |
-
{ id: 'refs', label: <><BookmarkPlus size={14} />素材</> },
|
| 343 |
]} />
|
| 344 |
<div className="inspector-body">
|
| 345 |
{tab === 'chapter' && <ChapterMeta ctx={ctx} detail={detail} onSaved={c => { setDetail(d => d ? { ...d, ...c } : d); updateChapterInBundle(c); setTitle(c.title) }} />}
|
|
@@ -348,7 +381,6 @@ export default function ChapterEditor({ ctx, chapter }: { ctx: BookCtx; chapter:
|
|
| 348 |
{tab === 'peer' && <PeerPanel data={peer} pid={pid} />}
|
| 349 |
{tab === 'versions' && <VersionsPanel pid={pid} cid={cid} versions={versions} current={detail.current_version_id} editorText={text} onLoad={loadIntoEditor} />}
|
| 350 |
{tab === 'check' && <CheckPanel num={detail.number} pid={pid} cid={cid} currentVersion={detail.current_version_id} text={text} dirty={dirty} />}
|
| 351 |
-
{tab === 'refs' && <RefsPanel ctx={ctx} />}
|
| 352 |
{tab === 'ai' && <AiPanel ctx={ctx} detail={detail} text={text} />}
|
| 353 |
</div>
|
| 354 |
</aside>
|
|
@@ -610,65 +642,6 @@ function CheckPanel({ num, pid, cid, currentVersion, text }: { num: number; pid:
|
|
| 610 |
)
|
| 611 |
}
|
| 612 |
|
| 613 |
-
/* ---------- 素材 ---------- */
|
| 614 |
-
function RefsPanel({ ctx }: { ctx: BookCtx }) {
|
| 615 |
-
const { bundle, setBundle } = ctx
|
| 616 |
-
const toast = useToast()
|
| 617 |
-
const pid = bundle.project.project_id
|
| 618 |
-
const refs = bundle.materials?.items || []
|
| 619 |
-
const [q, setQ] = useState('')
|
| 620 |
-
const [res, setRes] = useState<Material[] | null>(null)
|
| 621 |
-
const [busy, setBusy] = useState(false)
|
| 622 |
-
const [open, setOpen] = useState<string>('')
|
| 623 |
-
const search = async (e?: React.FormEvent) => {
|
| 624 |
-
e?.preventDefault()
|
| 625 |
-
if (!q.trim()) return
|
| 626 |
-
setBusy(true)
|
| 627 |
-
try { const r = await materialsApi.search({ q: q.trim(), size: 12 }); setRes(r.items) } catch (er: any) { toast(er.message, 'err') } finally { setBusy(false) }
|
| 628 |
-
}
|
| 629 |
-
const save = async (items: any[]) => {
|
| 630 |
-
try { const r = await projectsApi.saveMaterials(pid, items); setBundle(b => ({ ...b, materials: { ...b.materials, items: r.items } })); return true }
|
| 631 |
-
catch (e: any) { toast(e.message, 'err'); return false }
|
| 632 |
-
}
|
| 633 |
-
const add = async (m: Material) => {
|
| 634 |
-
if (refs.some((r: any) => r.uid === m.uid)) return toast('已经在参考素材里了')
|
| 635 |
-
if (refs.length >= 3) return toast('每本书最多 3 条参考素材,先移除一条', 'err')
|
| 636 |
-
if (await save([...refs, toRef(m)])) toast('已加入本书参考素材', 'ok')
|
| 637 |
-
}
|
| 638 |
-
return (
|
| 639 |
-
<div className="panel-stack">
|
| 640 |
-
<b className="panel-h">本书参考素材 <span className="muted">{refs.length}/3</span></b>
|
| 641 |
-
{refs.length === 0 && <div className="muted small-note">还没有参考素材。在下面搜一搜,或去素材馆挑选。</div>}
|
| 642 |
-
{refs.map((r: any) => (
|
| 643 |
-
<div key={r.uid} className="ref-card">
|
| 644 |
-
<div className="ref-sum">{r.sum || r.text.slice(0, 40)}</div>
|
| 645 |
-
<div className="ref-meta">{GENRE[r.g] || r.g} · {KIND[r.k] || r.k}</div>
|
| 646 |
-
<button className="link-btn" onClick={() => setOpen(open === r.uid ? '' : r.uid)}>{open === r.uid ? '收起正文' : '看清洗后正文'}</button>
|
| 647 |
-
{open === r.uid && <div className="ref-text">{r.text}</div>}
|
| 648 |
-
</div>
|
| 649 |
-
))}
|
| 650 |
-
<div className="divider" />
|
| 651 |
-
<form className="search-row" onSubmit={search}>
|
| 652 |
-
<Search size={15} />
|
| 653 |
-
<input className="input bare" value={q} onChange={e => setQ(e.target.value)} placeholder="搜情节、人物、关键词…" />
|
| 654 |
-
<button className="btn small ghost" disabled={busy}>{busy ? '…' : '搜索'}</button>
|
| 655 |
-
</form>
|
| 656 |
-
{res && res.length === 0 && <div className="muted small-note">没有找到相关素材,换个说法试试。</div>}
|
| 657 |
-
{res?.map(m => (
|
| 658 |
-
<div key={m.uid} className="ref-card">
|
| 659 |
-
<div className="ref-sum">{m.card?.logline || m.sum}</div>
|
| 660 |
-
{m.card?.hook && <div className="ref-hook">「{m.card.hook}」</div>}
|
| 661 |
-
<div className="ref-meta">{GENRE[m.g] || m.g} · {KIND[m.k] || m.k}</div>
|
| 662 |
-
<div className="row gap">
|
| 663 |
-
<button className="link-btn" onClick={() => add(m)}><BookmarkPlus size={13} />设为参考</button>
|
| 664 |
-
<button className="link-btn" onClick={() => go(`library/materials/${encodeURIComponent(m.uid)}`)}>在素材馆打开</button>
|
| 665 |
-
</div>
|
| 666 |
-
</div>
|
| 667 |
-
))}
|
| 668 |
-
</div>
|
| 669 |
-
)
|
| 670 |
-
}
|
| 671 |
-
|
| 672 |
/* ---------- AI 和协作 AI:写作由 AI 按作者的吩咐在工作台上完成,这里只放给它的话、留言和协作记录 ---------- */
|
| 673 |
function AiPanel({ ctx, detail }: { ctx: BookCtx; detail: Chapter; text: string }) {
|
| 674 |
const { bundle } = ctx
|
|
|
|
| 1 |
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
| 2 |
import {
|
| 3 |
+
Save, Maximize2, Minimize2, PanelRightClose, PanelRightOpen, History, ClipboardCheck, Sparkles, FileCog,
|
| 4 |
+
Type, AlignLeft, RotateCcw, Eye, GitCompare, Copy, Send, X, Check, AlertTriangle, Undo2, Highlighter, Scale, ChevronRight,
|
| 5 |
} from 'lucide-react'
|
| 6 |
import { locateNotes, NotesPanel, ReviewText, segmentText, useNotes } from './Review'
|
| 7 |
+
import { agentApi, Chapter, projectsApi, Version, VersionMeta } from '../api'
|
| 8 |
import { AskLog, AuditCard, SayToAi } from './Agent'
|
| 9 |
import { PeerPanel, locateDisputes, peerCount, usePeer } from './Peer'
|
| 10 |
+
import { cnNum, copyText, countWords, cx, diffParagraphs, fmtAgo, fmtDate, go, CHAPTER_STATUS, VERSION_KIND, useLocal, useDebounced, useAsync } from '../lib'
|
| 11 |
import { AutoText, Empty, ErrorNote, Field, ListEditor, Loading, Modal, Spinner, Tabs, useConfirm, useToast, Segmented, Tag } from '../ui'
|
| 12 |
import type { BookCtx } from './Book'
|
|
|
|
|
|
|
| 13 |
import { noteProgress, pct } from './progress'
|
| 14 |
|
| 15 |
+
type Tab = 'chapter' | 'notes' | 'peer' | 'check' | 'ai' | 'versions'
|
| 16 |
const draftKey = (cid: string) => `xs_draft_${cid}`
|
| 17 |
type Draft = { text: string; base: string | null; at: string }
|
| 18 |
const readDraft = (cid: string): Draft | null => { try { return JSON.parse(localStorage.getItem(draftKey(cid)) || 'null') } catch { return null } }
|
|
|
|
| 42 |
return () => window.removeEventListener('xs:inspector-close', off)
|
| 43 |
}, [setInspectorRaw])
|
| 44 |
const [tab, setTab] = useLocal<Tab>('xs_inspector_tab', 'chapter')
|
| 45 |
+
useEffect(() => { if (!['chapter', 'notes', 'peer', 'check', 'ai', 'versions'].includes(tab)) setTab('chapter') }, [tab])
|
| 46 |
const [fontSize, setFontSize] = useLocal('xs_font', 19)
|
| 47 |
const [pageWidth, setPageWidth] = useLocal<'narrow' | 'normal' | 'wide'>('xs_page_width', 'normal')
|
| 48 |
const [title, setTitle] = useState(chapter.title)
|
|
|
|
| 66 |
} catch (e: any) { toast(e.message, 'err'); return false }
|
| 67 |
}
|
| 68 |
|
| 69 |
+
/* 从「批阅汇总」点过来:打开批阅模式,滚到那条批注的原句 */
|
| 70 |
+
const jumpTo = useRef<string>('')
|
| 71 |
+
if (!jumpTo.current) {
|
| 72 |
+
try {
|
| 73 |
+
const j = JSON.parse(sessionStorage.getItem('xs_jump_note') || 'null')
|
| 74 |
+
if (j && j.cid === cid && Date.now() - j.ts < 60000) jumpTo.current = j.nid
|
| 75 |
+
} catch {}
|
| 76 |
+
}
|
| 77 |
+
useEffect(() => { jumpTo.current = ''; try { const j = JSON.parse(sessionStorage.getItem('xs_jump_note') || 'null'); if (j && j.cid === cid && Date.now() - j.ts < 60000) jumpTo.current = j.nid } catch {} }, [cid])
|
| 78 |
+
|
| 79 |
/* 载入章节和当前版本 */
|
| 80 |
const [ready, setReady] = useState(false)
|
| 81 |
const load = useCallback(async () => {
|
|
|
|
| 112 |
useEffect(() => {
|
| 113 |
if (!detail || !ready || restoredFor.current === cid) return
|
| 114 |
restoredFor.current = cid
|
| 115 |
+
if (jumpTo.current) return
|
| 116 |
const local = Number(localStorage.getItem(`xs_epos_${cid}`) || 'NaN')
|
| 117 |
const apply = (r: number) => requestAnimationFrame(() => requestAnimationFrame(() => {
|
| 118 |
const el = scrollRef.current
|
|
|
|
| 126 |
if (!isNaN(local)) apply(local)
|
| 127 |
else projectsApi.progress(pid).then(p => { const r = p.chapters?.[cid]?.edit_ratio; if (r != null) apply(r) }, () => {})
|
| 128 |
}, [detail, ready, cid, pid])
|
| 129 |
+
useEffect(() => {
|
| 130 |
+
const nid = jumpTo.current
|
| 131 |
+
if (!nid || !ready || !nb.notes) return
|
| 132 |
+
jumpTo.current = ''
|
| 133 |
+
try { sessionStorage.removeItem('xs_jump_note') } catch {}
|
| 134 |
+
const n = located.find(x => x.note_id === nid)
|
| 135 |
+
setInspector(true); setTab('notes')
|
| 136 |
+
if (!n) return toast('这条批注已被删除', 'err')
|
| 137 |
+
if (n.at < 0) { setActiveNote(nid); if (n.quote) toast('原句已经改动过,正文里找不到原位置了', 'err'); return }
|
| 138 |
+
setReviewMode(true)
|
| 139 |
+
setTimeout(() => { setActiveNote(''); setTimeout(() => setActiveNote(nid), 0) }, 250)
|
| 140 |
+
}, [ready, nb.notes, located])
|
| 141 |
const onScroll = () => {
|
| 142 |
const el = scrollRef.current
|
| 143 |
if (!el) return
|
|
|
|
| 166 |
} catch {}
|
| 167 |
}, [debounced, savedText, detail, cid])
|
| 168 |
|
| 169 |
+
/* 云端草稿:还没存为版本的改动也同步一份到云端,写作 AI 和协作 AI 能看到 */
|
| 170 |
+
const cloudText = useDebounced(text, 3000)
|
| 171 |
+
const cloudSent = useRef<string | null>(null)
|
| 172 |
+
useEffect(() => { cloudSent.current = null }, [cid])
|
| 173 |
+
useEffect(() => {
|
| 174 |
+
if (!detail || !ready) return
|
| 175 |
+
const want = cloudText !== savedText && cloudText.trim() ? cloudText : ''
|
| 176 |
+
if (want === cloudSent.current) return
|
| 177 |
+
cloudSent.current = want
|
| 178 |
+
projectsApi.saveDraft(pid, cid, { text: want, base: detail.current_version_id }).catch(() => { cloudSent.current = null })
|
| 179 |
+
}, [cloudText, savedText, ready, detail, pid, cid])
|
| 180 |
+
|
| 181 |
/* 自动增高:撑高稿纸的同时保住看到的位置(开关侧栏、换字号都不跳回开头) */
|
| 182 |
const fitTa = (byRatio: boolean) => {
|
| 183 |
const el = taRef.current, sc = scrollRef.current
|
|
|
|
| 299 |
if (loadErr) return <div className="page"><ErrorNote error={loadErr} onRetry={load} /></div>
|
| 300 |
if (!detail) return <Loading label="正在铺开稿纸…" />
|
| 301 |
|
| 302 |
+
const st = saving ? { k: 'saving', full: '正在保存', short: '保存中' } : dirty ? { k: 'dirty', full: '已暂存(AI 也能看到改动)· 尚未存为版本', short: '未存版本' } : detail.current_version_id ? { k: 'ok', full: '已与云端版本一致', short: '已同步' } : { k: 'new', full: '新章节,还没有版本', short: '新章节' }
|
| 303 |
const showInspector = inspector && !focus
|
| 304 |
const nextCh = [...bundle.chapters].sort((a, b) => a.number - b.number).find(c => c.number > detail.number && c.current_version_id)
|
| 305 |
|
|
|
|
| 373 |
{ id: 'check', label: <><ClipboardCheck size={14} />检查</> },
|
| 374 |
{ id: 'ai', label: <><Sparkles size={14} />AI 和协作 AI</> },
|
| 375 |
{ id: 'versions', label: <><History size={14} />版本</>, count: versions.length || undefined },
|
|
|
|
| 376 |
]} />
|
| 377 |
<div className="inspector-body">
|
| 378 |
{tab === 'chapter' && <ChapterMeta ctx={ctx} detail={detail} onSaved={c => { setDetail(d => d ? { ...d, ...c } : d); updateChapterInBundle(c); setTitle(c.title) }} />}
|
|
|
|
| 381 |
{tab === 'peer' && <PeerPanel data={peer} pid={pid} />}
|
| 382 |
{tab === 'versions' && <VersionsPanel pid={pid} cid={cid} versions={versions} current={detail.current_version_id} editorText={text} onLoad={loadIntoEditor} />}
|
| 383 |
{tab === 'check' && <CheckPanel num={detail.number} pid={pid} cid={cid} currentVersion={detail.current_version_id} text={text} dirty={dirty} />}
|
|
|
|
| 384 |
{tab === 'ai' && <AiPanel ctx={ctx} detail={detail} text={text} />}
|
| 385 |
</div>
|
| 386 |
</aside>
|
|
|
|
| 642 |
)
|
| 643 |
}
|
| 644 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 645 |
/* ---------- AI 和协作 AI:写作由 AI 按作者的吩咐在工作台上完成,这里只放给它的话、留言和协作记录 ---------- */
|
| 646 |
function AiPanel({ ctx, detail }: { ctx: BookCtx; detail: Chapter; text: string }) {
|
| 647 |
const { bundle } = ctx
|
ui-src/src/rooms/NotesHub.tsx
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React, { useMemo, useState } from 'react'
|
| 2 |
+
import { Highlighter, History, ChevronRight, MapPin, RefreshCw } from 'lucide-react'
|
| 3 |
+
import { ChangeItem, Note, projectsApi } from '../api'
|
| 4 |
+
import { cnNum, cx, fmtAgo, fmtDate, go, useAsync, useLocal } from '../lib'
|
| 5 |
+
import { Empty, ErrorNote, Loading, Segmented } from '../ui'
|
| 6 |
+
import type { BookCtx } from './Book'
|
| 7 |
+
import { NOTE_TYPE, SEVERITY, STATUS } from './Review'
|
| 8 |
+
|
| 9 |
+
/* 批阅汇总 + 修改记录:所有章节的批阅集中在一页,点一下跳到正文原句;
|
| 10 |
+
* 正文的每次改动(谁改的、改了哪几段)也在这里,写作 AI 和协作 AI 读的是同一份记录。 */
|
| 11 |
+
export function jumpToNote(pid: string, cid: string, nid: string) {
|
| 12 |
+
try { sessionStorage.setItem('xs_jump_note', JSON.stringify({ cid, nid, ts: Date.now() })) } catch {}
|
| 13 |
+
go(`book/${pid}/${cid}`)
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
export default function NotesHub({ ctx, initial }: { ctx: BookCtx; initial?: string }) {
|
| 17 |
+
const pid = ctx.bundle.project.project_id
|
| 18 |
+
const [view, setView] = useLocal<'notes' | 'changes'>('xs_hub_view', initial === 'changes' ? 'changes' : 'notes')
|
| 19 |
+
return (
|
| 20 |
+
<div className="page narrow hub">
|
| 21 |
+
<div className="eyebrow">{view === 'notes' ? <><Highlighter size={13} />批阅汇总</> : <><History size={13} />修改记录</>}</div>
|
| 22 |
+
<h1 className="hub-title">{view === 'notes' ? '所有章节的批阅' : '正文修改记录'}</h1>
|
| 23 |
+
<p className="muted hub-lead">{view === 'notes'
|
| 24 |
+
? '点任意一条,会打开那一章并滚到被批注的句子。'
|
| 25 |
+
: '每次存为版本、恢复旧版本都会自动记一笔。你还没存为版本的改动也会同步到云端。我(写作 AI)和协作 AI 每次动笔前都会先看这里。'}</p>
|
| 26 |
+
<Segmented value={view} onChange={setView} items={[{ id: 'notes', label: '批阅' }, { id: 'changes', label: '修改记录' }]} />
|
| 27 |
+
<div className="hub-body">{view === 'notes' ? <AllNotes pid={pid} /> : <Changes pid={pid} />}</div>
|
| 28 |
+
</div>
|
| 29 |
+
)
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
function AllNotes({ pid }: { pid: string }) {
|
| 33 |
+
const [filter, setFilter] = useLocal<'open' | 'all'>('xs_hub_filter', 'open')
|
| 34 |
+
const res = useAsync(() => projectsApi.allNotes(pid), [pid])
|
| 35 |
+
const groups = useMemo(() => {
|
| 36 |
+
const cs = res.data?.chapters || []
|
| 37 |
+
return cs.map(c => ({ ...c, notes: (c.notes || []).filter(n => filter === 'all' || n.status === 'open').sort((a, b) => (a.start || 0) - (b.start || 0)) }))
|
| 38 |
+
.filter(c => c.notes.length).sort((a, b) => a.number - b.number)
|
| 39 |
+
}, [res.data, filter])
|
| 40 |
+
const all = (res.data?.chapters || []).flatMap(c => c.notes || [])
|
| 41 |
+
const open = all.filter(n => n.status === 'open').length
|
| 42 |
+
if (res.error) return <ErrorNote error={res.error} onRetry={res.reload} />
|
| 43 |
+
if (!res.data) return <Loading label="正在收集批阅…" />
|
| 44 |
+
return (
|
| 45 |
+
<>
|
| 46 |
+
<div className="hub-bar">
|
| 47 |
+
<Segmented value={filter} onChange={setFilter} items={[{ id: 'open', label: `待修改 ${open}` }, { id: 'all', label: `全部 ${all.length}` }]} />
|
| 48 |
+
<button className="link-btn" onClick={res.reload}><RefreshCw size={13} />刷新</button>
|
| 49 |
+
</div>
|
| 50 |
+
{groups.length === 0 ? <Empty icon={<Highlighter size={20} />} title={filter === 'open' ? '没有待修改的批阅' : '还没有批阅'}>{filter === 'open' && all.length ? '全部处理完了。' : '在正文里点「批阅」,选中句子就能写批注。'}</Empty> : groups.map(g => (
|
| 51 |
+
<section key={g.chapter_id} className="hub-group">
|
| 52 |
+
<button className="hub-ch" onClick={() => go(`book/${pid}/${g.chapter_id}`)}>第{cnNum(g.number)}章 {g.title}<span className="muted">{g.notes.length} 条</span><ChevronRight size={14} /></button>
|
| 53 |
+
<ul className="note-list">
|
| 54 |
+
{g.notes.map(n => <HubNote key={n.note_id} n={n} onOpen={() => jumpToNote(pid, g.chapter_id, n.note_id)} />)}
|
| 55 |
+
</ul>
|
| 56 |
+
</section>
|
| 57 |
+
))}
|
| 58 |
+
</>
|
| 59 |
+
)
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
function HubNote({ n, onOpen }: { n: Note; onOpen: () => void }) {
|
| 63 |
+
return (
|
| 64 |
+
<li className={cx('note hub-note', `sev-${n.severity}`, n.type === 'praise' && 'praise', n.status !== 'open' && 'done')} onClick={onOpen} role="button" tabIndex={0}
|
| 65 |
+
onKeyDown={e => { if (e.key === 'Enter') onOpen() }} title="打开这一章,定位到这句">
|
| 66 |
+
<div className="note-head">
|
| 67 |
+
<span className="tag">{NOTE_TYPE[n.type] || n.type}</span>
|
| 68 |
+
{n.type !== 'praise' && <span className={cx('sev', n.severity)}>{SEVERITY[n.severity]}</span>}
|
| 69 |
+
<span className={cx('note-st', n.status)}>{STATUS[n.status]}</span>
|
| 70 |
+
<span className="muted">{n.created_by === 'ai' ? 'AI · ' : ''}{fmtAgo(n.created_at)}</span>
|
| 71 |
+
<span className="hub-go"><MapPin size={13} />定位</span>
|
| 72 |
+
</div>
|
| 73 |
+
<div className={cx('note-quote', !n.quote && 'general')}>{n.quote ? `「${n.quote.length > 80 ? n.quote.slice(0, 80) + '…' : n.quote}」` : '整章'}</div>
|
| 74 |
+
{n.comment && <div className="note-body">{n.comment}</div>}
|
| 75 |
+
{n.suggestion && <div className="note-sug"><span>建议</span>{n.suggestion}</div>}
|
| 76 |
+
{n.reply && <div className="note-reply"><span>AI 回复</span>{n.reply}</div>}
|
| 77 |
+
</li>
|
| 78 |
+
)
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
function Changes({ pid }: { pid: string }) {
|
| 82 |
+
const [by, setBy] = useLocal<'author' | 'all'>('xs_hub_by', 'author')
|
| 83 |
+
const res = useAsync(() => projectsApi.changes(pid, { by: by === 'author' ? 'author' : undefined, limit: 200 }), [pid, by])
|
| 84 |
+
if (res.error) return <ErrorNote error={res.error} onRetry={res.reload} />
|
| 85 |
+
if (!res.data) return <Loading label="正在读取修改记录…" />
|
| 86 |
+
const { items, unsaved_author_drafts: drafts } = res.data
|
| 87 |
+
return (
|
| 88 |
+
<>
|
| 89 |
+
<div className="hub-bar">
|
| 90 |
+
<Segmented value={by} onChange={setBy} items={[{ id: 'author', label: '我改的' }, { id: 'all', label: '全部(含 AI)' }]} />
|
| 91 |
+
<button className="link-btn" onClick={res.reload}><RefreshCw size={13} />刷新</button>
|
| 92 |
+
</div>
|
| 93 |
+
{drafts.length > 0 && (
|
| 94 |
+
<section className="hub-group">
|
| 95 |
+
<div className="hub-sub">还没存为版本的改动</div>
|
| 96 |
+
{drafts.map(d => (
|
| 97 |
+
<ChangeCard key={d.chapter_id} pid={pid} c={{ chapter_id: d.chapter_id, number: d.number, title: d.title, at: d.at, hunks: d.hunks, hunk_count: d.hunk_count, word_delta: d.word_delta }} tag="未存版本" />
|
| 98 |
+
))}
|
| 99 |
+
</section>
|
| 100 |
+
)}
|
| 101 |
+
{items.length === 0 && drafts.length === 0 ? <Empty icon={<History size={20} />} title="还没有修改记录">从现在起,你在稿纸上的每次改动都会记在这里。</Empty> : items.length > 0 && (
|
| 102 |
+
<section className="hub-group">
|
| 103 |
+
{drafts.length > 0 && <div className="hub-sub">已存的修改</div>}
|
| 104 |
+
{items.map(c => <ChangeCard key={c.change_id} pid={pid} c={c} tag={c.kind === 'rollback' ? '恢复旧版本' : undefined} />)}
|
| 105 |
+
</section>
|
| 106 |
+
)}
|
| 107 |
+
</>
|
| 108 |
+
)
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
function ChangeCard({ pid, c, tag }: { pid: string; c: Partial<ChangeItem> & Pick<ChangeItem, 'chapter_id' | 'number' | 'title' | 'at' | 'hunks' | 'hunk_count' | 'word_delta'>; tag?: string }) {
|
| 112 |
+
const [open, setOpen] = useState(false)
|
| 113 |
+
const shown = open ? c.hunks : c.hunks.slice(0, 2)
|
| 114 |
+
return (
|
| 115 |
+
<div className="change-card">
|
| 116 |
+
<div className="change-head">
|
| 117 |
+
<button className="hub-ch inline" onClick={() => go(`book/${pid}/${c.chapter_id}`)}>第{cnNum(c.number)}章 {c.title}</button>
|
| 118 |
+
{tag && <span className="tag">{tag}</span>}
|
| 119 |
+
<span className="muted">{c.by ? `${c.by} · ` : ''}{fmtDate(c.at)}({fmtAgo(c.at)})</span>
|
| 120 |
+
<span className="muted">改了 {c.hunk_count} 处 · {c.word_delta > 0 ? '+' : ''}{c.word_delta} 字</span>
|
| 121 |
+
</div>
|
| 122 |
+
{c.summary && <div className="note-body">{c.summary}</div>}
|
| 123 |
+
{shown.map((h, i) => (
|
| 124 |
+
<div key={i} className="change-hunk">
|
| 125 |
+
<div className="change-para">第 {h.para} 段</div>
|
| 126 |
+
{h.before.map((t, j) => <div key={'b' + j} className="diff-row del">{t}</div>)}
|
| 127 |
+
{h.after.map((t, j) => <div key={'a' + j} className="diff-row add">{t}</div>)}
|
| 128 |
+
</div>
|
| 129 |
+
))}
|
| 130 |
+
{c.hunks.length > 2 && <button className="link-btn" onClick={() => setOpen(!open)}>{open ? '收起' : `展开其余 ${c.hunks.length - 2} 处`}</button>}
|
| 131 |
+
{(c.acks || []).map(a => <div key={a.by} className="note-reply"><span>{a.by} 已看</span>{a.note || '已读'}</div>)}
|
| 132 |
+
</div>
|
| 133 |
+
)
|
| 134 |
+
}
|
ui-src/src/rooms/Review.tsx
CHANGED
|
@@ -11,7 +11,7 @@ export const NOTE_TYPE: Record<string, string> = {
|
|
| 11 |
cut: '该删', add: '该补', praise: '写得好', other: '其他',
|
| 12 |
}
|
| 13 |
export const SEVERITY: Record<string, string> = { must: '必须改', should: '建议改', maybe: '可改可不改' }
|
| 14 |
-
const STATUS: Record<string, string> = { open: '待修改', fixed: '已修改', closed: '已关闭', wontfix: '不改了' }
|
| 15 |
const SCORE_DIMS: [string, string][] = [
|
| 16 |
['logic', '逻辑自洽'], ['setting', '设定一致'], ['character', '人物立得住'], ['pace', '节奏'], ['hook', '爽点与钩子'], ['prose', '文笔'],
|
| 17 |
]
|
|
|
|
| 11 |
cut: '该删', add: '该补', praise: '写得好', other: '其他',
|
| 12 |
}
|
| 13 |
export const SEVERITY: Record<string, string> = { must: '必须改', should: '建议改', maybe: '可改可不改' }
|
| 14 |
+
export const STATUS: Record<string, string> = { open: '待修改', fixed: '已修改', closed: '已关闭', wontfix: '不改了' }
|
| 15 |
const SCORE_DIMS: [string, string][] = [
|
| 16 |
['logic', '逻辑自洽'], ['setting', '设定一致'], ['character', '人物立得住'], ['pace', '节奏'], ['hook', '爽点与钩子'], ['prose', '文笔'],
|
| 17 |
]
|
ui-src/src/styles.css
CHANGED
|
@@ -1837,3 +1837,24 @@ details.older[open] { display: flex; flex-direction: column; gap: 8px; }
|
|
| 1837 |
.paper-next .btn { gap: 8px; }
|
| 1838 |
.reader-mark { box-shadow: inset 3px 0 0 var(--accent); background: color-mix(in srgb, var(--accent) 7%, transparent); transition: background 2s, box-shadow 2s; }
|
| 1839 |
.reader-resume { position: absolute; top: 58px; left: 50%; transform: translateX(-50%); margin: 0; animation: none; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1837 |
.paper-next .btn { gap: 8px; }
|
| 1838 |
.reader-mark { box-shadow: inset 3px 0 0 var(--accent); background: color-mix(in srgb, var(--accent) 7%, transparent); transition: background 2s, box-shadow 2s; }
|
| 1839 |
.reader-resume { position: absolute; top: 58px; left: 50%; transform: translateX(-50%); margin: 0; animation: none; }
|
| 1840 |
+
|
| 1841 |
+
/* ---------- 批阅汇总 / 修改记录 ---------- */
|
| 1842 |
+
.hub-title { font-family: var(--serif); font-size: 26px; margin: 2px 0 6px; }
|
| 1843 |
+
.hub-lead { margin: 0 0 16px; font-size: 13.5px; line-height: 1.7; }
|
| 1844 |
+
.hub-body { margin-top: 18px; display: flex; flex-direction: column; gap: 18px; }
|
| 1845 |
+
.hub-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
|
| 1846 |
+
.hub-group { display: flex; flex-direction: column; gap: 10px; }
|
| 1847 |
+
.hub-sub { font-size: 12px; letter-spacing: .08em; color: var(--ink-3); font-weight: 600; }
|
| 1848 |
+
.hub-ch { display: inline-flex; align-items: center; gap: 8px; background: none; border: 0; padding: 0; font: inherit; font-weight: 600; font-size: 15px; color: var(--ink); cursor: pointer; text-align: left; }
|
| 1849 |
+
.hub-ch .muted { font-weight: 400; font-size: 12.5px; }
|
| 1850 |
+
.hub-ch:hover { color: var(--accent); }
|
| 1851 |
+
.hub-ch.inline { font-size: 14px; }
|
| 1852 |
+
.hub-note { cursor: pointer; transition: border-color .15s, box-shadow .15s; }
|
| 1853 |
+
.hub-note:hover, .hub-note:focus-visible { box-shadow: var(--shadow-s); border-color: var(--accent); outline: none; }
|
| 1854 |
+
.hub-note .note-quote { cursor: pointer; }
|
| 1855 |
+
.hub-go { margin-left: auto; display: inline-flex; align-items: center; gap: 3px; font-size: 12px; color: var(--accent); opacity: .75; }
|
| 1856 |
+
.hub-note:hover .hub-go { opacity: 1; }
|
| 1857 |
+
.change-card { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
|
| 1858 |
+
.change-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 12.5px; }
|
| 1859 |
+
.change-hunk { display: flex; flex-direction: column; gap: 2px; font-family: var(--serif); font-size: 14px; line-height: 1.8; }
|
| 1860 |
+
.change-para { font-family: var(--sans); font-size: 11.5px; color: var(--ink-3); }
|