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,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();
}
/**