From 3bb49881d777febfb5e7135c33e964f0e18db19f Mon Sep 17 00:00:00 2001 From: Astrian Zheng Date: Sun, 25 May 2025 14:19:41 +1000 Subject: [PATCH] =?UTF-8?q?feat(=E6=92=AD=E6=94=BE=E6=8E=A7=E5=88=B6):=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=92=AD=E6=94=BE=E9=98=9F=E5=88=97=E7=9A=84?= =?UTF-8?q?=E4=B8=8A=E4=B8=80=E9=A6=96=E5=92=8C=E4=B8=8B=E4=B8=80=E9=A6=96?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增 `playNext` 和 `playPrevious` 函数,用于控制播放队列中的上一首和下一首歌曲。同时为播放按钮绑定点击事件,实现播放控制功能。 --- src/pages/Playroom.vue | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/pages/Playroom.vue b/src/pages/Playroom.vue index a36fc77..803b290 100644 --- a/src/pages/Playroom.vue +++ b/src/pages/Playroom.vue @@ -55,6 +55,26 @@ function formatDetector() { if (format === 'wav') { return 'WAV' } return '未知格式' } + +function playNext() { + if (playQueueStore.currentIndex === playQueueStore.list.length - 1) { + console.log("at the bottom, pause") + playQueueStore.currentIndex = 0 + playQueueStore.isPlaying = false + } else { + playQueueStore.currentIndex++ + playQueueStore.isPlaying = true + } +} + +function playPrevious() { + if (playQueueStore.currentTime < 5 && playQueueStore.currentIndex > 0) { + playQueueStore.currentIndex-- + playQueueStore.isPlaying = true + } else { + playQueueStore.updatedCurrentTime = 0 + } +}