From 28383722cc6f154d6e2e17029793c8992390c053 Mon Sep 17 00:00:00 2001 From: JOJO <1498581755@qq.com> Date: Mon, 15 Dec 2025 00:52:32 +0800 Subject: [PATCH] fix: keep wait overlay alive for long waits --- .../chat/monitor/MonitorDirector.ts | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/static/src/components/chat/monitor/MonitorDirector.ts b/static/src/components/chat/monitor/MonitorDirector.ts index f0ac7c6..cab1d57 100644 --- a/static/src/components/chat/monitor/MonitorDirector.ts +++ b/static/src/components/chat/monitor/MonitorDirector.ts @@ -3761,22 +3761,31 @@ export class MonitorDirector implements MonitorDriver { clearInterval(this.waitOverlayTimer); this.waitOverlayTimer = null; } + let phase = 0; const update = () => { const elapsed = (performance.now() - start) / 1000; - const remain = Math.max(0, total - elapsed); - if (this.elements.waitCountdown) { + const remain = total - elapsed; + if (!this.elements.waitCountdown) { + return; + } + if (remain > 0) { this.elements.waitCountdown.textContent = this.formatWaitText(Math.ceil(remain)); + } else { + const over = Math.ceil(-remain); + const dots = '.'.repeat(phase); + phase = (phase + 1) % 4; + this.elements.waitCountdown.textContent = `等待中 +${over}s${dots}`; } }; - this.waitOverlayTimer = window.setInterval(update, 200); + this.waitOverlayTimer = window.setInterval(update, 260); const done = until || Promise.resolve(); + const minDuration = new Promise(resolve => setTimeout(resolve, total * 1000)); try { - await done; - } catch (_err) { - // 忽略错误,仍然结束动画 + await Promise.all([done.catch(() => null), minDuration]); + } finally { + update(); + this.hideWaitOverlay(); } - update(); - this.hideWaitOverlay(); } /**