fix(Player): 修复播放器时间更新逻辑
修复了播放器组件中时间更新逻辑的问题,将`!newValue`改为`newValue === null`以更准确地判断时间更新条件。同时在`Playroom`页面中改进了时间格式化函数,当时间无效时返回`-:--`而不是`0:00`,并增加了对NaN值的处理。
This commit is contained in:
parent
3bb49881d7
commit
3074950226
|
@ -46,7 +46,7 @@ function setMetadata() {
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(() => playQueueStore.updatedCurrentTime, (newValue) => {
|
watch(() => playQueueStore.updatedCurrentTime, (newValue) => {
|
||||||
if (!newValue) { return }
|
if (newValue === null) { return }
|
||||||
if (player.value) player.value.currentTime = newValue
|
if (player.value) player.value.currentTime = newValue
|
||||||
playQueueStore.updatedCurrentTime = null
|
playQueueStore.updatedCurrentTime = null
|
||||||
})
|
})
|
||||||
|
|
|
@ -31,9 +31,10 @@ onMounted(() => {
|
||||||
|
|
||||||
function timeFormatter(time: number) {
|
function timeFormatter(time: number) {
|
||||||
const timeInSeconds = Math.floor(time)
|
const timeInSeconds = Math.floor(time)
|
||||||
if (timeInSeconds < 0) { return '0:00' }
|
if (timeInSeconds < 0) { return '-:--' }
|
||||||
const minutes = Math.floor(timeInSeconds / 60)
|
const minutes = Math.floor(timeInSeconds / 60)
|
||||||
const seconds = Math.floor(timeInSeconds % 60)
|
const seconds = Math.floor(timeInSeconds % 60)
|
||||||
|
if (isNaN(minutes) || isNaN(seconds)) { return '-:--' }
|
||||||
return `${minutes}:${seconds < 10 ? '0' : ''}${seconds}`
|
return `${minutes}:${seconds < 10 ? '0' : ''}${seconds}`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user