From da051409dff81b0e08888ab5de928839f0b8222e Mon Sep 17 00:00:00 2001 From: x1ao4 Date: Tue, 23 Sep 2025 14:10:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BA=E9=87=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=A4=B9=E5=8A=9F=E8=83=BD=E5=A2=9E=E5=8A=A0=20SSE=20=E6=8E=A8?= =?UTF-8?q?=E9=80=81=EF=BC=8C=E6=94=AF=E6=8C=81=E7=9B=B8=E5=85=B3=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E7=9A=84=E5=AE=9E=E6=97=B6=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/run.py | 6 ++++++ app/templates/index.html | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/app/run.py b/app/run.py index d285e89..d46dd9a 100644 --- a/app/run.py +++ b/app/run.py @@ -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} 条记录", diff --git a/app/templates/index.html b/app/templates/index.html index 3311d25..9f26aa4 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -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();