From 0756362d147679286176021373504785358a0205 Mon Sep 17 00:00:00 2001 From: Fam Zheng Date: Tue, 26 May 2026 09:58:22 +0100 Subject: [PATCH] =?UTF-8?q?music(player):=20sidebar=20=E5=8F=8C=E5=87=BB?= =?UTF-8?q?=E5=88=87=E6=AD=8C=E5=B9=B6=E6=92=AD=E6=94=BE=EF=BC=88=E5=8D=95?= =?UTF-8?q?=E5=87=BB=E5=8F=AA=E5=88=87=E6=8D=A2=E4=B8=8D=E6=89=93=E6=89=B0?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/music/frontend/src/views/PlayerView.vue | 21 ++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/apps/music/frontend/src/views/PlayerView.vue b/apps/music/frontend/src/views/PlayerView.vue index b2b99c6..2c453e1 100644 --- a/apps/music/frontend/src/views/PlayerView.vue +++ b/apps/music/frontend/src/views/PlayerView.vue @@ -68,6 +68,8 @@ class="row" :class="{ active: selectedId === p.id }" @click="selectPiece(p.id)" + @dblclick="playPiece(p.id)" + title="单击切换 / 双击切换并播放" >
{{ p.title }}
@@ -773,9 +775,12 @@ async function loadPiece(id) { await nextTick() const first = audioAttachments.value[0] if (first && audioEl.value) { - // 优先用 IDB 缓存的 blob URL(cache 关时同步返回网络 URL,零延迟) audioEl.value.src = getAudioUrl(first.id) - if (wasPlaying) audioEl.value.play().catch(() => {}) + // 续播条件:之前正在播 / 双击强制要求 / forceNextPlay flag + if (wasPlaying || forceNextPlay) { + audioEl.value.play().catch(() => {}) + } + forceNextPlay = false } else if (audioEl.value) { audioEl.value.removeAttribute('src') audioEl.value.load() @@ -804,6 +809,18 @@ function selectPiece(id) { router.push({ name: 'piece', params: { id } }) } +let forceNextPlay = false +function playPiece(id) { + forceNextPlay = true + // 同 piece dblclick:URL 不变 watch 不触发 → 直接 play + if (id === selectedId.value && audioEl.value) { + audioEl.value.play().catch(() => {}) + forceNextPlay = false + return + } + selectPiece(id) +} + function attachmentUrl(id) { return attUrl(id) } function togglePlay() {