为重置文件夹功能增加 SSE 推送,支持相关数据的实时更新

This commit is contained in:
x1ao4 2025-09-23 14:10:27 +08:00
parent 338418e595
commit da051409df
2 changed files with 19 additions and 0 deletions

View File

@ -3169,6 +3169,12 @@ def reset_folder():
logging.error(f">>> 删除记录时出错: {str(e)}")
# 即使删除记录失败,也返回文件删除成功
# 成功后通过 SSE 通知前端进行热更新
try:
notify_calendar_changed('reset_folder')
except Exception:
pass
return jsonify({
"success": True,
"message": f"重置成功,删除了 {deleted_files} 个文件和 {deleted_records} 条记录",

View File

@ -10488,6 +10488,19 @@
.then(response => {
if (response.data.success) {
this.showToast(`重置成功:删除了 ${response.data.deleted_files || 0} 个文件,${response.data.deleted_records || 0} 条记录`);
// 重置成功后,主动热更新最近转存文件与任务元数据,避免等待 SSE 或轮询
(async () => {
try {
const latestRes = await axios.get('/task_latest_info');
if (latestRes.data && latestRes.data.success) {
const latestFiles = latestRes.data.data.latest_files || {};
this.taskLatestFiles = latestFiles;
this.taskLatestRecords = latestRes.data.data.latest_records || {};
}
} catch (e) {}
// 重新加载任务元数据(海报与详细信息)
try { await this.loadTasklistMetadata(); } catch (e) {}
})();
// 如果当前是历史记录页面,刷新记录
if (this.activeTab === 'history') {
this.loadHistoryRecords();