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

@@ -59,6 +59,11 @@ export default class Main {
// 设置分享
this.setupShare();
// 启动草稿检查(仅登录用户)
if (this.userManager.isLoggedIn) {
this.startDraftChecker();
}
} catch (error) {
console.error('[Main] 初始化失败:', error);
this.hideLoading();
@@ -111,6 +116,61 @@ export default class Main {
});
}
// 启动草稿检查定时器
startDraftChecker() {
// 避免重复启动
if (this.draftCheckTimer) return;
console.log('[Main] 启动草稿检查定时器');
// 每30秒检查一次
this.draftCheckTimer = setInterval(async () => {
try {
if (!this.userManager.isLoggedIn) return;
const result = await this.storyManager.checkNewDrafts(this.userManager.userId);
if (result && result.hasNew && result.count > 0) {
console.log('[Main] 检测到新草稿:', result.count);
// 先标记为已读,避免重复弹窗
await this.storyManager.markAllDraftsRead(this.userManager.userId);
// 弹窗通知
wx.showModal({
title: 'AI改写完成',
content: `您有 ${result.count} 个新的AI改写已完成是否前往查看`,
confirmText: '查看',
cancelText: '稍后',
success: (res) => {
if (res.confirm) {
// 跳转到个人中心的草稿箱 tab
this.sceneManager.switchScene('profile', { tab: 1 });
} else {
// 点击稍后,如果当前在个人中心页面则刷新草稿列表
const currentScene = this.sceneManager.currentScene;
if (currentScene && currentScene.refreshDrafts) {
currentScene.refreshDrafts();
}
}
}
});
}
} catch (e) {
console.warn('[Main] 草稿检查失败:', e);
}
}, 30000);
}
// 停止草稿检查定时器
stopDraftChecker() {
if (this.draftCheckTimer) {
clearInterval(this.draftCheckTimer);
this.draftCheckTimer = null;
console.log('[Main] 停止草稿检查定时器');
}
}
// 设置分享
setupShare() {
wx.showShareMenu({