feat: 添加测试用户到种子数据, AI改写功能优化, 前端联调修复

This commit is contained in:
2026-03-09 23:00:15 +08:00
parent 5e931424ab
commit 9948ccba8f
12 changed files with 1082 additions and 151 deletions

View File

@@ -156,6 +156,58 @@ export default class StoryManager {
}
}
/**
* AI改写结局异步提交到草稿箱
*/
async rewriteEndingAsync(storyId, ending, prompt, userId) {
try {
// 先标记之前的未读草稿为已读
await this.markAllDraftsRead(userId);
const result = await post(`/drafts/ending`, {
userId: userId,
storyId: storyId,
endingName: ending?.name || '未知结局',
endingContent: ending?.content || '',
prompt: prompt
}, { timeout: 30000 });
if (result && result.draftId) {
return result;
}
return null;
} catch (error) {
console.error('AI改写结局提交失败:', error?.errMsg || error?.message || JSON.stringify(error));
return null;
}
}
/**
* AI续写结局异步提交到草稿箱
*/
async continueEndingAsync(storyId, ending, prompt, userId) {
try {
// 先标记之前的未读草稿为已读
await this.markAllDraftsRead(userId);
const result = await post(`/drafts/continue-ending`, {
userId: userId,
storyId: storyId,
endingName: ending?.name || '未知结局',
endingContent: ending?.content || '',
prompt: prompt
}, { timeout: 30000 });
if (result && result.draftId) {
return result;
}
return null;
} catch (error) {
console.error('AI续写结局提交失败:', error?.errMsg || error?.message || JSON.stringify(error));
return null;
}
}
/**
* AI改写中间章节异步提交到草稿箱
* @returns {Object|null} 成功返回草稿ID失败返回 null