fix: keep wait overlay alive for long waits

This commit is contained in:
JOJO 2025-12-15 00:52:32 +08:00
parent 4191c26f93
commit 28383722cc

View File

@ -3761,23 +3761,32 @@ export class MonitorDirector implements MonitorDriver {
clearInterval(this.waitOverlayTimer); clearInterval(this.waitOverlayTimer);
this.waitOverlayTimer = null; this.waitOverlayTimer = null;
} }
let phase = 0;
const update = () => { const update = () => {
const elapsed = (performance.now() - start) / 1000; const elapsed = (performance.now() - start) / 1000;
const remain = Math.max(0, total - elapsed); const remain = total - elapsed;
if (this.elements.waitCountdown) { if (!this.elements.waitCountdown) {
return;
}
if (remain > 0) {
this.elements.waitCountdown.textContent = this.formatWaitText(Math.ceil(remain)); 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 done = until || Promise.resolve();
const minDuration = new Promise(resolve => setTimeout(resolve, total * 1000));
try { try {
await done; await Promise.all([done.catch(() => null), minDuration]);
} catch (_err) { } finally {
// 忽略错误,仍然结束动画
}
update(); update();
this.hideWaitOverlay(); this.hideWaitOverlay();
} }
}
/** /**
* *