feat: 游玩记录支持区分原故事和AI草稿,已下架草稿显示标签
This commit is contained in:
@@ -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分钟)
|
||||
|
||||
Reference in New Issue
Block a user