feat: 游玩记录支持区分原故事和AI草稿,已下架草稿显示标签

This commit is contained in:
wangwuww111
2026-03-13 12:28:42 +08:00
parent 411110ce0c
commit 4a69bf2711
8 changed files with 449 additions and 99 deletions

View File

@@ -43,9 +43,48 @@ export default class EndingScene extends BaseScene {
this.showButtons = true;
}, 1500);
// 保存游玩记录回放模式和AI草稿不保存
if (!this.isReplay && !this.draftId) {
// 保存游玩记录
this.checkAndSavePlayRecord();
// 加载收藏状态
this.loadCollectStatus();
}
async checkAndSavePlayRecord() {
// 回放模式不保存
if (this.isReplay) return;
// 原故事:直接保存
if (!this.draftId) {
this.savePlayRecord();
return;
}
// AI草稿检查是否已发布已发布才保存
try {
const userId = this.main.userManager.userId;
const drafts = await this.main.storyManager.getDrafts(userId) || [];
const draft = drafts.find(d => d.id === this.draftId);
if (draft?.publishedToCenter) {
this.savePlayRecord();
}
} catch (e) {
console.error('检查草稿发布状态失败:', e);
}
}
async loadCollectStatus() {
try {
if (this.draftId) {
// AI草稿获取草稿收藏状态
this.isCollected = await this.main.userManager.getDraftCollectStatus(this.draftId);
} else {
// 原故事:获取故事收藏状态
const progress = await this.main.userManager.getProgress(this.storyId);
this.isCollected = progress?.isCollected || false;
}
} catch (e) {
console.error('加载收藏状态失败:', e);
}
}
@@ -56,12 +95,13 @@ export default class EndingScene extends BaseScene {
const endingName = this.ending?.name || '未知结局';
const endingType = this.ending?.type || '';
// 调用保存接口
// 调用保存接口(传入 draftId 区分原故事和AI草稿
await this.main.userManager.savePlayRecord(
this.storyId,
endingName,
endingType,
pathHistory
pathHistory,
this.draftId // AI草稿ID原故事为null
);
console.log('游玩记录保存成功');
} catch (e) {
@@ -1193,7 +1233,13 @@ export default class EndingScene extends BaseScene {
handleCollect() {
this.isCollected = !this.isCollected;
this.main.userManager.collectStory(this.storyId, this.isCollected);
if (this.draftId) {
// AI草稿收藏草稿
this.main.userManager.collectDraft(this.draftId, this.isCollected);
} else {
// 原故事:收藏故事
this.main.userManager.collectStory(this.storyId, this.isCollected);
}
}
// 启动草稿完成轮询每5秒检查一次持续2分钟