From 4da52e7f9540258c6f15b33bf03e7e4d2d592699 Mon Sep 17 00:00:00 2001 From: Astrian Zheng Date: Mon, 26 May 2025 13:39:47 +1000 Subject: [PATCH] =?UTF-8?q?feat(=E6=92=AD=E6=94=BE=E5=99=A8):=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=BE=AA=E7=8E=AF=E6=92=AD=E6=94=BE=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 实现三种循环播放模式:关闭、全部循环和单曲循环。修改播放逻辑以支持不同模式: - 关闭模式:播放到队列末尾时停止 - 全部循环:播放到队列末尾时从头开始 - 单曲循环:当前歌曲播放结束后自动重播 新增单曲循环图标组件,并优化播放控制按钮的UI交互。 --- src/assets/icons/cycletwoarrowswithnumone.vue | 13 +++++++++++ src/components/Player.vue | 14 ++++++++--- src/pages/Playroom.vue | 23 +++++++++++++++---- 3 files changed, 43 insertions(+), 7 deletions(-) create mode 100644 src/assets/icons/cycletwoarrowswithnumone.vue diff --git a/src/assets/icons/cycletwoarrowswithnumone.vue b/src/assets/icons/cycletwoarrowswithnumone.vue new file mode 100644 index 0000000..e112847 --- /dev/null +++ b/src/assets/icons/cycletwoarrowswithnumone.vue @@ -0,0 +1,13 @@ + + + \ No newline at end of file diff --git a/src/components/Player.vue b/src/components/Player.vue index c1fd923..eed6099 100644 --- a/src/components/Player.vue +++ b/src/components/Player.vue @@ -69,8 +69,13 @@ function playNext() { if (playQueueStore.currentIndex === playQueueStore.list.length - 1) { console.log("at the bottom, pause") playQueueStore.currentIndex = 0 - player.value?.pause() - playQueueStore.isPlaying = false + if(playQueueStore.playMode.repeat === 'all') { + playQueueStore.currentIndex = 0 + playQueueStore.isPlaying = true + } else { + player.value?.pause() + playQueueStore.isPlaying = false + } } else { playQueueStore.currentIndex++ playQueueStore.isPlaying = true @@ -204,7 +209,10 @@ function getCurrentTrack() { ref="playerRef" :autoplay="playQueueStore.isPlaying" v-if="playQueueStore.list.length !== 0" - @ended="playNext" + @ended="() => { + if (playQueueStore.playMode.repeat === 'single') { playQueueStore.isPlaying = true } + else { playNext() } + }" @pause="playQueueStore.isPlaying = false" @play="playQueueStore.isPlaying = true" @playing="() => { diff --git a/src/pages/Playroom.vue b/src/pages/Playroom.vue index 9f2d0b3..999436d 100644 --- a/src/pages/Playroom.vue +++ b/src/pages/Playroom.vue @@ -19,6 +19,7 @@ import EllipsisHorizontalIcon from '../assets/icons/ellipsishorizontal.vue' import XIcon from '../assets/icons/x.vue' import ShuffleIcon from '../assets/icons/shuffle.vue' import CycleTwoArrowsIcon from '../assets/icons/cycletwoarrows.vue' +import CycleTwoArrowsWithNumOneIcon from '../assets/icons/cycletwoarrowswithnumone.vue' import SpeakerIcon from '../assets/icons/speaker.vue' const playQueueStore = usePlayQueueStore() @@ -301,7 +302,7 @@ function getCurrentTrack() { -
+