feat(ai写作): 历史回看右侧成稿可编辑并保存回历史记录
- 后端新增 PUT /api/ai-writing/sessions/{id}/draft(属主校验,draft_title 可选)
- 前端历史模式放开只读,工具栏新增「保存」按钮持久化修改
- 实时写作完成态保持原样(仅导出,不落库)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
304e1b637a
commit
42f55251f2
7 files changed
+126
-6
No files matched your search
@@ -82,6 +82,27 @@ export async function renameAIWritingSession(id: string, title: string): Promise
|
||||
return resp.json();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新历史会话的成稿正文(历史回看时用户在右侧编辑器里直接修改并保存)。
|
||||
* draftTitle 省略时后端不动原标题。
|
||||
*/
|
||||
export async function updateAIWritingDraft(
|
||||
id: string,
|
||||
draftMarkdown: string,
|
||||
draftTitle?: string,
|
||||
): Promise<AIWritingSessionSummary> {
|
||||
const resp = await apiFetch(`${BASE()}/${id}/draft`, {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
draft_markdown: draftMarkdown,
|
||||
...(draftTitle === undefined ? {} : { draft_title: draftTitle }),
|
||||
}),
|
||||
});
|
||||
if (!resp.ok) throw new Error(`保存修改失败: ${resp.status}`);
|
||||
return resp.json();
|
||||
}
|
||||
|
||||
export async function deleteAIWritingSession(id: string): Promise<void> {
|
||||
const resp = await apiFetch(`${BASE()}/${id}`, { method: 'DELETE' });
|
||||
if (!resp.ok) throw new Error(`删除失败: ${resp.status}`);
|
||||
|
||||
Reference in new issue
Block a user