From 4cd948ff637788f6f4e687e850c34322d81d0f36 Mon Sep 17 00:00:00 2001 From: Sunwuyuan Date: Sat, 7 Mar 2026 08:37:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=80=92=E8=AE=A1=E6=97=B6?= =?UTF-8?q?=E7=BB=93=E6=9D=9F=E5=BC=B9=E6=A1=86=E5=8A=9F=E8=83=BD=EF=BC=8C?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=94=A8=E6=88=B7=E4=BD=93=E9=AA=8C=EF=BC=8C?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E8=B6=85=E6=97=B6=E6=8F=90=E7=A4=BA=E5=92=8C?= =?UTF-8?q?=E5=80=92=E8=AE=A1=E6=97=B6=E6=A0=BC=E5=BC=8F=E5=8C=96=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/TimeCard.vue | 134 ++++++++++++++++++++++++++++++------ 1 file changed, 112 insertions(+), 22 deletions(-) diff --git a/src/components/TimeCard.vue b/src/components/TimeCard.vue index dedd1dd..baa6b04 100644 --- a/src/components/TimeCard.vue +++ b/src/components/TimeCard.vue @@ -38,6 +38,7 @@ v-model="showFullscreen" fullscreen :scrim="false" + persistent transition="dialog-bottom-transition" >
-
+
@@ -379,6 +380,61 @@
+ + + + + + 时间到! + + +
+ {{ formatCountdownTotal(countdownTotal) }} +
+
+ 设定的倒计时已结束 +
+
+ + 已超时 {{ overtimeDisplay }} + +
+
+ + + 知道了 + + +
+
+ 0) { + return `${h}小时${m}分${s}秒` + } + if (m > 0) { + return `${m}分${s}秒` + } + return `${s}秒` + }, // 秒表 computed stopwatchDisplay() { const ms = this.stopwatchElapsed @@ -598,9 +655,10 @@ export default { if (e.key === 'Escape') { if (this.showSettings) { this.showSettings = false - } else { - this.showFullscreen = false + } else if (this.countdownEndedDialog) { + this.dismissCountdownDialog() } + // 不关闭全屏弹框,阻止默认行为 e.preventDefault() e.stopPropagation() } @@ -628,6 +686,7 @@ export default { this.clearCountdownTimer() this.clearStopwatchTimer() this.clearToolbarTimer() + this.dismissCountdownDialog() if (this.unwatch) { this.unwatch() } @@ -697,6 +756,7 @@ export default { this.countdownRunning = false this.clearCountdownTimer() playSound(defaultSingleSound) + this.showCountdownEndedDialog() } }, toggleCountdown() { @@ -716,6 +776,36 @@ export default { this.countdownRemaining = 0 this.countdownTotal = 0 this.clearCountdownTimer() + this.dismissCountdownDialog() + }, + showCountdownEndedDialog() { + this.countdownEndedDialog = true + this.overtimeElapsed = 0 + this.overtimeLastTick = Date.now() + this.overtimeTimer = setInterval(() => { + const now = Date.now() + this.overtimeElapsed += now - this.overtimeLastTick + this.overtimeLastTick = now + }, 200) + }, + dismissCountdownDialog() { + this.countdownEndedDialog = false + this.overtimeElapsed = 0 + if (this.overtimeTimer) { + clearInterval(this.overtimeTimer) + this.overtimeTimer = null + } + }, + formatCountdownTotal(ms) { + const totalSec = Math.round(ms / 1000) + const h = Math.floor(totalSec / 3600) + const m = Math.floor((totalSec % 3600) / 60) + const s = totalSec % 60 + const parts = [] + if (h > 0) parts.push(`${h}小时`) + if (m > 0) parts.push(`${m}分钟`) + if (s > 0) parts.push(`${s}秒`) + return parts.join('') || '0秒' }, clearCountdownTimer() { if (this.countdownTimer) {