feat: 完善AI改写草稿箱功能 - 修复重头游玩、评分、数据刷新等问题

This commit is contained in:
wangwuww111
2026-03-09 14:15:00 +08:00
parent bbdccfa843
commit 18db6a8cc6
17 changed files with 1385 additions and 99 deletions

View File

@@ -7,6 +7,7 @@ export default class StoryScene extends BaseScene {
constructor(main, params) {
super(main, params);
this.storyId = params.storyId;
this.draftId = params.draftId || null; // 草稿ID
this.aiContent = params.aiContent || null; // AI改写内容
this.story = null;
this.currentNode = null;
@@ -31,6 +32,18 @@ export default class StoryScene extends BaseScene {
this.sceneColors = this.generateSceneColors();
// AI改写相关
this.isAIRewriting = false;
// 剧情回顾模式
this.isRecapMode = false;
this.recapData = null;
this.recapScrollY = 0;
this.recapMaxScrollY = 0;
this.recapBtnRect = null;
this.recapReplayBtnRect = null;
this.recapCardRects = [];
// 重头游玩模式
this.isReplayMode = false;
this.replayPath = [];
this.replayPathIndex = 0;
}
// 根据场景生成氛围色
@@ -46,6 +59,52 @@ export default class StoryScene extends BaseScene {
}
async init() {
// 如果是从Draft加载先获取草稿详情进入回顾模式
if (this.draftId) {
this.main.showLoading('加载AI改写内容...');
const draft = await this.main.storyManager.getDraftDetail(this.draftId);
if (draft && draft.aiNodes && draft.storyId) {
// 先加载原故事
this.story = await this.main.storyManager.loadStoryDetail(draft.storyId);
if (this.story) {
this.setThemeByCategory(this.story.category);
// 将AI生成的节点合并到故事中
Object.assign(this.story.nodes, draft.aiNodes);
// 获取 AI 入口节点的内容
const entryKey = draft.entryNodeKey || 'branch_1';
const aiEntryNode = draft.aiNodes[entryKey];
// 保存回顾数据,包含 AI 内容
this.recapData = {
pathHistory: draft.pathHistory || [],
userPrompt: draft.userPrompt || '',
entryNodeKey: entryKey,
aiContent: aiEntryNode // 保存 AI 入口节点内容
};
// 同时保存到 aiContent方便后续访问
this.aiContent = aiEntryNode;
// 进入回顾模式
this.isRecapMode = true;
this.calculateRecapScroll();
this.main.hideLoading();
return;
}
}
this.main.hideLoading();
this.main.showError('草稿加载失败');
this.main.sceneManager.switchScene('home');
return;
}
// 如果是AI改写内容直接播放
if (this.aiContent) {
this.story = this.main.storyManager.currentStory;
@@ -63,6 +122,10 @@ export default class StoryScene extends BaseScene {
// 重新开始,使用已有数据
this.story = existingStory;
this.setThemeByCategory(this.story.category);
// 重置到起点并清空历史
this.main.storyManager.resetStory();
this.currentNode = this.main.storyManager.getCurrentNode();
if (this.currentNode) {
this.startTypewriter(this.currentNode.content);
@@ -108,8 +171,341 @@ export default class StoryScene extends BaseScene {
this.sceneColors = themes[category] || this.sceneColors;
}
// 计算回顾页面滚动范围
calculateRecapScroll() {
if (!this.recapData) return;
const itemHeight = 90;
const headerHeight = 120;
const promptHeight = 80;
const buttonHeight = 80;
const contentHeight = headerHeight + this.recapData.pathHistory.length * itemHeight + promptHeight + buttonHeight;
this.recapMaxScrollY = Math.max(0, contentHeight - this.screenHeight + 40);
}
// 渲染剧情回顾页面
renderRecapPage(ctx) {
// 背景
const gradient = ctx.createLinearGradient(0, 0, 0, this.screenHeight);
gradient.addColorStop(0, this.sceneColors.bg1);
gradient.addColorStop(1, this.sceneColors.bg2);
ctx.fillStyle = gradient;
ctx.fillRect(0, 0, this.screenWidth, this.screenHeight);
// 返回按钮
ctx.fillStyle = '#ffffff';
ctx.font = '16px sans-serif';
ctx.textAlign = 'left';
ctx.fillText(' 返回', 15, 35);
// 标题
ctx.textAlign = 'center';
ctx.font = 'bold 18px sans-serif';
ctx.fillStyle = this.sceneColors.accent;
ctx.fillText('📖 剧情回顾', this.screenWidth / 2, 35);
// 故事标题
if (this.story) {
ctx.fillStyle = 'rgba(255,255,255,0.6)';
ctx.font = '13px sans-serif';
ctx.fillText(this.story.title, this.screenWidth / 2, 60);
}
// 内容区域裁剪(调整起点避免被标题挡住)
ctx.save();
ctx.beginPath();
ctx.rect(0, 70, this.screenWidth, this.screenHeight - 150);
ctx.clip();
const padding = 16;
let y = 100 - this.recapScrollY;
const pathHistory = this.recapData?.pathHistory || [];
// 保存卡片位置用于点击检测
this.recapCardRects = [];
// 计算可用文字宽度
const maxTextWidth = this.screenWidth - padding * 2 - 50;
// 绘制每个路径项
pathHistory.forEach((item, index) => {
if (y > 50 && y < this.screenHeight - 80) {
// 卡片背景
ctx.fillStyle = 'rgba(255,255,255,0.06)';
this.roundRect(ctx, padding, y, this.screenWidth - padding * 2, 80, 12);
ctx.fill();
// 序号圆圈
ctx.fillStyle = this.sceneColors.accent;
ctx.beginPath();
ctx.arc(padding + 20, y + 28, 12, 0, Math.PI * 2);
ctx.fill();
ctx.fillStyle = '#ffffff';
ctx.font = 'bold 11px sans-serif';
ctx.textAlign = 'center';
ctx.fillText(`${index + 1}`, padding + 20, y + 32);
// 内容摘要(限制宽度)
ctx.fillStyle = 'rgba(255,255,255,0.85)';
ctx.font = '12px sans-serif';
ctx.textAlign = 'left';
const contentText = this.truncateTextByWidth(ctx, item.content || '', maxTextWidth - 40);
ctx.fillText(contentText, padding + 40, y + 28);
// 选择(限制宽度)
ctx.fillStyle = this.sceneColors.accent;
ctx.font = '11px sans-serif';
const choiceText = `${this.truncateTextByWidth(ctx, item.choice || '', maxTextWidth - 60)}`;
ctx.fillText(choiceText, padding + 40, y + 52);
// 点击提示图标
ctx.fillStyle = 'rgba(255,255,255,0.4)';
ctx.font = '14px sans-serif';
ctx.textAlign = 'right';
ctx.fillText('', this.screenWidth - padding - 12, y + 40);
// 保存卡片区域
this.recapCardRects.push({
x: padding,
y: y + this.recapScrollY,
width: this.screenWidth - padding * 2,
height: 80,
index: index,
item: item
});
}
y += 90;
});
// 空状态
if (pathHistory.length === 0) {
ctx.fillStyle = 'rgba(255,255,255,0.4)';
ctx.font = '14px sans-serif';
ctx.textAlign = 'center';
ctx.fillText('没有历史记录', this.screenWidth / 2, y + 30);
y += 60;
}
// AI改写指令可点击查看详情
this.recapPromptRect = null;
if (y > 40 && y < this.screenHeight - 30) {
ctx.fillStyle = 'rgba(168, 85, 247, 0.15)';
this.roundRect(ctx, padding, y + 10, this.screenWidth - padding * 2, 60, 12);
ctx.fill();
ctx.fillStyle = '#a855f7';
ctx.font = 'bold 12px sans-serif';
ctx.textAlign = 'left';
ctx.fillText('✨ AI改写指令', padding + 12, y + 32);
ctx.fillStyle = 'rgba(255,255,255,0.8)';
ctx.font = '11px sans-serif';
const promptText = this.truncateTextByWidth(ctx, this.recapData?.userPrompt || '无', maxTextWidth - 30);
ctx.fillText(`${promptText}`, padding + 12, y + 52);
// 点击提示
ctx.fillStyle = 'rgba(255,255,255,0.4)';
ctx.font = '14px sans-serif';
ctx.textAlign = 'right';
ctx.fillText('', this.screenWidth - padding - 12, y + 42);
// 保存点击区域
this.recapPromptRect = {
x: padding,
y: y + 10 + this.recapScrollY,
width: this.screenWidth - padding * 2,
height: 60
};
}
y += 80;
ctx.restore();
// 底部按钮区域(固定位置,两个按钮)
const btnY = this.screenHeight - 70;
const btnH = 42;
const btnGap = 12;
const btnW = (this.screenWidth - padding * 2 - btnGap) / 2;
// 左边按钮:重头游玩
ctx.fillStyle = 'rgba(255,255,255,0.1)';
this.roundRect(ctx, padding, btnY, btnW, btnH, 21);
ctx.fill();
ctx.strokeStyle = 'rgba(255,255,255,0.3)';
ctx.lineWidth = 1;
this.roundRect(ctx, padding, btnY, btnW, btnH, 21);
ctx.stroke();
ctx.fillStyle = '#ffffff';
ctx.font = '14px sans-serif';
ctx.textAlign = 'center';
ctx.fillText('🔄 重头游玩', padding + btnW / 2, btnY + 26);
// 右边按钮:开始新剧情
const btn2X = padding + btnW + btnGap;
const btnGradient = ctx.createLinearGradient(btn2X, btnY, btn2X + btnW, btnY);
btnGradient.addColorStop(0, '#a855f7');
btnGradient.addColorStop(1, '#ec4899');
ctx.fillStyle = btnGradient;
this.roundRect(ctx, btn2X, btnY, btnW, btnH, 21);
ctx.fill();
ctx.fillStyle = '#ffffff';
ctx.font = 'bold 14px sans-serif';
ctx.fillText('新剧情 →', btn2X + btnW / 2, btnY + 26);
// 保存按钮区域
this.recapReplayBtnRect = { x: padding, y: btnY, width: btnW, height: btnH };
this.recapBtnRect = { x: btn2X, y: btnY, width: btnW, height: btnH };
// 滚动提示
if (this.recapMaxScrollY > 0) {
ctx.fillStyle = 'rgba(255,255,255,0.3)';
ctx.font = '11px sans-serif';
ctx.textAlign = 'center';
if (this.recapScrollY < this.recapMaxScrollY - 10) {
ctx.fillText('↓ 上滑查看更多', this.screenWidth / 2, btnY - 15);
}
}
}
// 开始播放AI改写内容从回顾模式退出
startAIContent() {
if (!this.recapData) return;
this.isRecapMode = false;
this.main.storyManager.currentNodeKey = this.recapData.entryNodeKey || 'branch_1';
this.currentNode = this.main.storyManager.getCurrentNode();
if (this.currentNode) {
this.startTypewriter(this.currentNode.content);
}
}
// 显示历史项详情
showRecapDetail(item, index) {
const content = item.content || '无内容';
const choice = item.choice || '无选择';
wx.showModal({
title: `${index + 1}`,
content: `【剧情】\n${content}\n\n【你的选择】\n${choice}`,
showCancel: false,
confirmText: '关闭'
});
}
// 显示AI改写指令详情
showPromptDetail() {
const prompt = this.recapData?.userPrompt || '无';
wx.showModal({
title: '✨ AI改写指令',
content: prompt,
showCancel: false,
confirmText: '关闭'
});
}
// 根据宽度截断文字
truncateTextByWidth(ctx, text, maxWidth) {
if (!text) return '';
if (ctx.measureText(text).width <= maxWidth) return text;
let t = text;
while (t.length > 0 && ctx.measureText(t + '...').width > maxWidth) {
t = t.slice(0, -1);
}
return t + '...';
}
// 重头游玩自动快进到AI改写点
startReplayMode() {
if (!this.recapData) return;
this.isRecapMode = false;
this.isReplayMode = true;
this.replayPathIndex = 0;
this.replayPath = this.recapData.pathHistory || [];
// 从 start 节点开始
this.main.storyManager.currentNodeKey = 'start';
this.main.storyManager.pathHistory = [];
this.currentNode = this.main.storyManager.getCurrentNode();
if (this.currentNode) {
this.startTypewriter(this.currentNode.content);
}
}
// 自动选择回放路径中的选项
autoSelectReplayChoice() {
if (!this.isReplayMode || this.replayPathIndex >= this.replayPath.length) {
// 回放结束进入AI改写内容
this.isReplayMode = false;
this.enterAIContent();
return;
}
// 找到对应的选项并自动选择
const currentPath = this.replayPath[this.replayPathIndex];
const currentNode = this.main.storyManager.getCurrentNode();
if (currentNode && currentNode.choices) {
const choiceIndex = currentNode.choices.findIndex(c => c.text === currentPath.choice);
if (choiceIndex >= 0) {
this.replayPathIndex++;
this.main.storyManager.selectChoice(choiceIndex);
this.currentNode = this.main.storyManager.getCurrentNode();
if (this.currentNode) {
this.startTypewriter(this.currentNode.content);
}
return;
}
}
// 找不到匹配的选项直接进入AI内容
this.isReplayMode = false;
this.enterAIContent();
}
// 进入AI改写内容
enterAIContent() {
console.log('进入AI改写内容');
// AI 节点已经合并到 story.nodes 中,使用 storyManager 来管理
const entryKey = this.recapData?.entryNodeKey || 'branch_1';
// 检查节点是否存在
if (this.story && this.story.nodes && this.story.nodes[entryKey]) {
this.main.storyManager.currentNodeKey = entryKey;
this.currentNode = this.main.storyManager.getCurrentNode();
if (this.currentNode) {
this.startTypewriter(this.currentNode.content);
return;
}
}
// 节点不存在,显示错误
console.error('AI入口节点不存在:', entryKey);
wx.showModal({
title: '内容加载失败',
content: 'AI改写内容未找到',
showCancel: false,
confirmText: '返回',
success: () => {
this.main.sceneManager.switchScene('home');
}
});
}
startTypewriter(text) {
this.targetText = text || '';
let content = text || '';
// 回放模式下过滤掉结局提示因为后面还有AI改写内容
if (this.isReplayMode) {
content = content.replace(/【达成结局[:][^】]*】/g, '').trim();
}
this.targetText = content;
this.displayText = '';
this.charIndex = 0;
this.isTyping = true;
@@ -145,6 +541,12 @@ export default class StoryScene extends BaseScene {
}
render(ctx) {
// 如果是回顾模式,渲染回顾页面
if (this.isRecapMode) {
this.renderRecapPage(ctx);
return;
}
// 1. 绘制场景背景
this.renderSceneBackground(ctx);
@@ -418,7 +820,7 @@ export default class StoryScene extends BaseScene {
renderChoices(ctx) {
if (!this.currentNode || !this.currentNode.choices) return;
const choices = this.currentNode.choices;
let choices = this.currentNode.choices;
const choiceHeight = 50;
const choiceMargin = 10;
const padding = 20;
@@ -428,18 +830,37 @@ export default class StoryScene extends BaseScene {
ctx.fillStyle = 'rgba(0,0,0,0.5)';
ctx.fillRect(0, this.screenHeight * 0.42, this.screenWidth, this.screenHeight * 0.58);
// 提示文字
ctx.fillStyle = '#ffffff';
ctx.font = '14px sans-serif';
ctx.textAlign = 'center';
ctx.fillText('请做出选择', this.screenWidth / 2, startY);
// 回放模式下的处理
let replayChoice = null;
if (this.isReplayMode && this.replayPathIndex < this.replayPath.length) {
const previousChoice = this.replayPath[this.replayPathIndex]?.choice;
replayChoice = choices.find(c => c.text === previousChoice);
// 提示文字
ctx.fillStyle = this.sceneColors.accent;
ctx.font = '13px sans-serif';
ctx.textAlign = 'center';
ctx.fillText('📍 你之前选择的是:', this.screenWidth / 2, startY);
// 只显示之前选过的选项
if (replayChoice) {
choices = [replayChoice];
}
} else {
// 正常模式提示文字
ctx.fillStyle = '#ffffff';
ctx.font = '14px sans-serif';
ctx.textAlign = 'center';
ctx.fillText('请做出选择', this.screenWidth / 2, startY);
}
choices.forEach((choice, index) => {
const y = startY + 25 + index * (choiceHeight + choiceMargin);
const isSelected = index === this.selectedChoice;
const isReplayItem = this.isReplayMode && replayChoice && choice.text === replayChoice.text;
// 选项背景
if (isSelected) {
if (isSelected || isReplayItem) {
const gradient = ctx.createLinearGradient(padding, y, this.screenWidth - padding, y);
gradient.addColorStop(0, this.sceneColors.accent);
gradient.addColorStop(1, this.sceneColors.accent + 'aa');
@@ -451,7 +872,7 @@ export default class StoryScene extends BaseScene {
ctx.fill();
// 选项边框
ctx.strokeStyle = isSelected ? this.sceneColors.accent : 'rgba(255,255,255,0.2)';
ctx.strokeStyle = (isSelected || isReplayItem) ? this.sceneColors.accent : 'rgba(255,255,255,0.2)';
ctx.lineWidth = 1.5;
this.roundRect(ctx, padding, y, this.screenWidth - padding * 2, choiceHeight, 25);
ctx.stroke();
@@ -462,6 +883,13 @@ export default class StoryScene extends BaseScene {
ctx.textAlign = 'center';
ctx.fillText(choice.text, this.screenWidth / 2, y + 30);
// 回放模式下显示点击继续提示
if (isReplayItem) {
ctx.fillStyle = 'rgba(255,255,255,0.5)';
ctx.font = '11px sans-serif';
ctx.fillText('点击继续 ', this.screenWidth / 2, y + 45);
}
// 锁定图标
if (choice.isLocked) {
ctx.fillStyle = '#ffd700';
@@ -512,6 +940,14 @@ export default class StoryScene extends BaseScene {
this.lastTouchY = touch.clientY;
this.hasMoved = false;
// 回顾模式下的滚动
if (this.isRecapMode) {
if (touch.clientY > 75) {
this.isDragging = true;
}
return;
}
// 判断是否在对话框区域
const boxY = this.screenHeight * 0.42;
if (touch.clientY > boxY) {
@@ -522,6 +958,20 @@ export default class StoryScene extends BaseScene {
onTouchMove(e) {
const touch = e.touches[0];
// 回顾模式下的滚动
if (this.isRecapMode && this.isDragging) {
const deltaY = this.lastTouchY - touch.clientY;
if (Math.abs(deltaY) > 2) {
this.hasMoved = true;
}
if (this.recapMaxScrollY > 0) {
this.recapScrollY += deltaY;
this.recapScrollY = Math.max(0, Math.min(this.recapScrollY, this.recapMaxScrollY));
}
this.lastTouchY = touch.clientY;
return;
}
// 滑动对话框内容
if (this.isDragging) {
const deltaY = this.lastTouchY - touch.clientY;
@@ -548,6 +998,57 @@ export default class StoryScene extends BaseScene {
return;
}
// 回顾模式下的点击处理
if (this.isRecapMode) {
// 返回按钮
if (y < 60 && x < 80) {
this.main.sceneManager.switchScene('profile', { tab: 1 });
return;
}
// 重头游玩按钮
if (this.recapReplayBtnRect) {
const btn = this.recapReplayBtnRect;
if (x >= btn.x && x <= btn.x + btn.width && y >= btn.y && y <= btn.y + btn.height) {
this.startReplayMode();
return;
}
}
// 开始新剧情按钮
if (this.recapBtnRect) {
const btn = this.recapBtnRect;
if (x >= btn.x && x <= btn.x + btn.width && y >= btn.y && y <= btn.y + btn.height) {
this.startAIContent();
return;
}
}
// 历史项卡片点击(显示详情)
if (this.recapCardRects) {
const adjustedY = y + this.recapScrollY;
for (const rect of this.recapCardRects) {
if (x >= rect.x && x <= rect.x + rect.width &&
adjustedY >= rect.y && adjustedY <= rect.y + rect.height) {
this.showRecapDetail(rect.item, rect.index);
return;
}
}
}
// AI改写指令点击显示完整指令
if (this.recapPromptRect) {
const adjustedY = y + this.recapScrollY;
const rect = this.recapPromptRect;
if (x >= rect.x && x <= rect.x + rect.width &&
adjustedY >= rect.y && adjustedY <= rect.y + rect.height) {
this.showPromptDetail();
return;
}
}
return;
}
// 返回按钮
if (y < 60 && x < 80) {
this.main.sceneManager.switchScene('home');
@@ -584,46 +1085,94 @@ export default class StoryScene extends BaseScene {
console.log('AI改写内容:', JSON.stringify(this.aiContent));
this.main.sceneManager.switchScene('ending', {
storyId: this.storyId,
draftId: this.draftId,
ending: {
name: this.aiContent.ending_name,
type: this.aiContent.ending_type,
content: this.aiContent.content,
score: 100
score: this.aiContent.ending_score || 80
}
});
return;
}
// 检查是否是结局
if (this.main.storyManager.isEnding()) {
// 检查是否是结局回放模式下跳过因为要进入AI改写内容
if (!this.isReplayMode && this.main.storyManager.isEnding()) {
this.main.sceneManager.switchScene('ending', {
storyId: this.storyId,
draftId: this.draftId,
ending: this.main.storyManager.getEndingInfo()
});
return;
}
// 回放模式下如果到达原结局或没有选项进入AI改写内容
if (this.isReplayMode) {
const currentNode = this.main.storyManager.getCurrentNode();
if (!currentNode || !currentNode.choices || currentNode.choices.length === 0 || currentNode.is_ending) {
// 回放结束进入AI改写内容
this.isReplayMode = false;
this.enterAIContent();
return;
}
}
// 显示选项
if (this.currentNode && this.currentNode.choices && this.currentNode.choices.length > 0) {
// 回放模式下也显示选项,但只显示之前选过的
this.showChoices = true;
} else if (this.currentNode && (!this.currentNode.choices || this.currentNode.choices.length === 0)) {
// 没有选项的节点,检查是否是死胡同(故事数据问题)
console.log('当前节点没有选项:', this.main.storyManager.currentNodeKey, this.currentNode);
// 如果有 AI 改写内容,跳转到 AI 内容
if (this.recapData && this.recapData.entryNodeKey) {
this.main.storyManager.currentNodeKey = this.recapData.entryNodeKey;
this.currentNode = this.main.storyManager.getCurrentNode();
if (this.currentNode) {
this.startTypewriter(this.currentNode.content);
}
return;
}
// 否则当作结局处理
wx.showModal({
title: '故事结束',
content: '当前剧情已结束',
showCancel: false,
confirmText: '返回',
success: () => {
this.main.sceneManager.switchScene('home');
}
});
}
return;
}
// 选项点击
if (this.showChoices && this.currentNode && this.currentNode.choices) {
const choices = this.currentNode.choices;
const choiceHeight = 50;
const choiceMargin = 10;
const padding = 20;
const startY = this.screenHeight * 0.42 + 55;
for (let i = 0; i < choices.length; i++) {
const choiceY = startY + i * (choiceHeight + choiceMargin);
// 回放模式下只有一个选项
if (this.isReplayMode && this.replayPathIndex < this.replayPath.length) {
const choiceY = startY;
if (y >= choiceY && y <= choiceY + choiceHeight && x >= padding && x <= this.screenWidth - padding) {
this.handleChoiceSelect(i);
this.autoSelectReplayChoice();
return;
}
} else {
// 正常模式
const choices = this.currentNode.choices;
for (let i = 0; i < choices.length; i++) {
const choiceY = startY + i * (choiceHeight + choiceMargin);
if (y >= choiceY && y <= choiceY + choiceHeight && x >= padding && x <= this.screenWidth - padding) {
this.handleChoiceSelect(i);
return;
}
}
}
}
}
@@ -689,24 +1238,24 @@ export default class StoryScene extends BaseScene {
placeholderText: '输入你的改写指令,如"让主角暴富"',
success: (res) => {
if (res.confirm && res.content) {
this.doAIRewrite(res.content);
this.doAIRewriteAsync(res.content);
}
}
});
}
/**
* 执行AI改写
* 异步提交AI改写到草稿箱
*/
async doAIRewrite(prompt) {
async doAIRewriteAsync(prompt) {
if (this.isAIRewriting) return;
this.isAIRewriting = true;
this.main.showLoading('AI正在改写剧情...');
this.main.showLoading('正在提交...');
try {
const userId = this.main.userManager.userId || 0;
const newNode = await this.main.storyManager.rewriteBranch(
const result = await this.main.storyManager.rewriteBranchAsync(
this.storyId,
prompt,
userId
@@ -714,26 +1263,25 @@ export default class StoryScene extends BaseScene {
this.main.hideLoading();
if (newNode) {
// 成功获取新分支,开始播放
this.currentNode = newNode;
this.startTypewriter(newNode.content);
wx.showToast({
title: '改写成功!',
icon: 'success',
duration: 1500
if (result && result.draftId) {
// 提交成功
wx.showModal({
title: '提交成功',
content: 'AI正在后台生成中完成后会通知您。\n您可以继续播放当前故事。',
showCancel: false,
confirmText: '知道了'
});
} else {
// AI 失败,继续原故事
// 提交失败
wx.showToast({
title: 'AI暂时不可用继续原故事',
title: '提交失败,请重试',
icon: 'none',
duration: 2000
});
}
} catch (error) {
this.main.hideLoading();
console.error('AI改写出错:', error);
console.error('AI改写提交出错:', error);
wx.showToast({
title: '网络错误,请重试',
icon: 'none',