feat: 添加测试用户到种子数据, AI改写功能优化, 前端联调修复
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user