|
|
@@ -1357,10 +1357,28 @@ window.pause = async function(seconds) {
|
|
|
showCountdown.value = true;
|
|
|
countdownValue.value = seconds;
|
|
|
|
|
|
- // 倒计时循环
|
|
|
- while (countdownValue.value > 0 && !shouldStopExecution) {
|
|
|
- await new Promise(resolve => setTimeout(resolve, 1000));
|
|
|
- countdownValue.value--;
|
|
|
+ // 使用更细粒度的时间间隔,确保能快速响应重置操作
|
|
|
+ const interval = 100; // 100毫秒检查一次
|
|
|
+ const totalIterations = seconds * 10; // 总迭代次数
|
|
|
+
|
|
|
+ for (let i = 0; i < totalIterations; i++) {
|
|
|
+ // 检查是否应该停止执行
|
|
|
+ if (shouldStopExecution) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 等待一小段时间
|
|
|
+ await new Promise(resolve => setTimeout(resolve, interval));
|
|
|
+
|
|
|
+ // 检查是否应该停止执行
|
|
|
+ if (shouldStopExecution) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 每10次迭代(即1秒)减少倒计时值
|
|
|
+ if ((i + 1) % 10 === 0) {
|
|
|
+ countdownValue.value--;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 隐藏倒计时
|
|
|
@@ -1662,6 +1680,10 @@ const resetPlayer = async () => {
|
|
|
// 设置标志强制停止所有执行
|
|
|
shouldStopExecution = true;
|
|
|
|
|
|
+ // 清除倒计时显示和重置倒计时值
|
|
|
+ showCountdown.value = false;
|
|
|
+ countdownValue.value = 0;
|
|
|
+
|
|
|
// 取消任何正在执行的代码
|
|
|
if (executionAbortController) {
|
|
|
executionAbortController.abort();
|