From 3074950226ff642f593db622bef9dfbeeba6bc2c Mon Sep 17 00:00:00 2001 From: Astrian Zheng Date: Sun, 25 May 2025 14:25:12 +1000 Subject: [PATCH] =?UTF-8?q?fix(Player):=20=E4=BF=AE=E5=A4=8D=E6=92=AD?= =?UTF-8?q?=E6=94=BE=E5=99=A8=E6=97=B6=E9=97=B4=E6=9B=B4=E6=96=B0=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复了播放器组件中时间更新逻辑的问题,将`!newValue`改为`newValue === null`以更准确地判断时间更新条件。同时在`Playroom`页面中改进了时间格式化函数,当时间无效时返回`-:--`而不是`0:00`,并增加了对NaN值的处理。 --- src/components/Player.vue | 2 +- src/pages/Playroom.vue | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/Player.vue b/src/components/Player.vue index 3547b00..5f04221 100644 --- a/src/components/Player.vue +++ b/src/components/Player.vue @@ -46,7 +46,7 @@ function setMetadata() { } watch(() => playQueueStore.updatedCurrentTime, (newValue) => { - if (!newValue) { return } + if (newValue === null) { return } if (player.value) player.value.currentTime = newValue playQueueStore.updatedCurrentTime = null }) diff --git a/src/pages/Playroom.vue b/src/pages/Playroom.vue index 803b290..783c065 100644 --- a/src/pages/Playroom.vue +++ b/src/pages/Playroom.vue @@ -31,9 +31,10 @@ onMounted(() => { function timeFormatter(time: number) { const timeInSeconds = Math.floor(time) - if (timeInSeconds < 0) { return '0:00' } + if (timeInSeconds < 0) { return '-:--' } const minutes = Math.floor(timeInSeconds / 60) const seconds = Math.floor(timeInSeconds % 60) + if (isNaN(minutes) || isNaN(seconds)) { return '-:--' } return `${minutes}:${seconds < 10 ? '0' : ''}${seconds}` }