feat: 游玩记录多版本功能 - 支持多版本记录存储和回放 - 相同路径自动去重只保留最新 - 版本列表支持删除功能 - AI草稿箱游玩不记录历史 - iOS日期格式兼容修复

This commit is contained in:
wangwuww111
2026-03-10 12:44:55 +08:00
parent 9948ccba8f
commit baf7dd1e2b
8 changed files with 693 additions and 35 deletions

View File

@@ -1,7 +1,7 @@
/**
* 用户数据管理器
*/
import { get, post } from '../utils/http';
import { get, post, del } from '../utils/http';
export default class UserManager {
constructor() {
@@ -191,4 +191,66 @@ export default class UserManager {
return [];
}
}
// ========== 游玩记录相关 ==========
/**
* 保存游玩记录
*/
async savePlayRecord(storyId, endingName, endingType, pathHistory) {
if (!this.isLoggedIn) return null;
try {
return await post('/user/play-record', {
userId: this.userId,
storyId,
endingName,
endingType: endingType || '',
pathHistory: pathHistory || []
});
} catch (e) {
console.error('保存游玩记录失败:', e);
return null;
}
}
/**
* 获取游玩记录列表
* @param {number} storyId - 可选指定故事ID获取该故事的所有记录
*/
async getPlayRecords(storyId = null) {
if (!this.isLoggedIn) return [];
try {
const params = { userId: this.userId };
if (storyId) params.storyId = storyId;
return await get('/user/play-records', params);
} catch (e) {
console.error('获取游玩记录失败:', e);
return [];
}
}
/**
* 获取单条记录详情
*/
async getPlayRecordDetail(recordId) {
if (!this.isLoggedIn) return null;
try {
return await get(`/user/play-records/${recordId}`);
} catch (e) {
console.error('获取记录详情失败:', e);
return null;
}
}
// 删除游玩记录
async deletePlayRecord(recordId) {
if (!this.isLoggedIn) return false;
try {
await del(`/user/play-records/${recordId}`);
return true;
} catch (e) {
console.error('删除记录失败:', e);
return false;
}
}
}