From 823fdf3245a4d47304a84ea7ed029388914995e6 Mon Sep 17 00:00:00 2001 From: ikmkj <1@qq,com> Date: Sat, 26 Jul 2025 00:53:00 +0800 Subject: [PATCH] =?UTF-8?q?refactor(music-player):=20=E4=BC=98=E5=8C=96=20?= =?UTF-8?q?currentMusic=20=E5=8F=98=E5=8C=96=E7=9B=91=E5=90=AC=E9=80=BB?= =?UTF-8?q?=E8=BE=91-=20=E4=BF=AE=E6=94=B9=20watch=20=E7=9B=91=E5=90=AC?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=EF=BC=8C=E4=BD=BF=E7=94=A8=E7=AE=AD=E5=A4=B4?= =?UTF-8?q?=E5=87=BD=E6=95=B0=E7=9B=91=E5=90=AC=20currentMusic.value=3F.id?= =?UTF-8?q?=20=E7=9A=84=E5=8F=98=E5=8C=96=20-=E5=A2=9E=E5=8A=A0=E5=AF=B9?= =?UTF-8?q?=E5=BD=93=E5=89=8D=E9=9F=B3=E4=B9=90=E5=AF=B9=E8=B1=A1=E7=9A=84?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=E6=80=A7=E6=A3=80=E6=9F=A5=20-=20=E4=BF=9D?= =?UTF-8?q?=E7=95=99=E5=8E=9F=E6=9C=89=E7=9A=84=E7=AB=8B=E5=8D=B3=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E8=A1=8C=E4=B8=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- music-qianduan/src/components/MusicPlayer.vue | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/music-qianduan/src/components/MusicPlayer.vue b/music-qianduan/src/components/MusicPlayer.vue index 4e478be..f8225f0 100644 --- a/music-qianduan/src/components/MusicPlayer.vue +++ b/music-qianduan/src/components/MusicPlayer.vue @@ -546,8 +546,11 @@ const scrollToActiveLyric = async () => { } // 监听当前播放歌曲的变化 -watch(currentMusic, (newMusic) => { - if (newMusic && newMusic.id) { +watch(() => currentMusic.value?.id, (newId) => { + if (newId) { + const newMusic = playerStore.getCurrentMusic; + if (!newMusic) return; + // 处理 URL playerStore.updateMusicUrl(newMusic.id, processMusicUrl(newMusic.url)) playerStore.updateMusicCover(newMusic.id, processMusicUrl(newMusic.cover)) @@ -571,7 +574,7 @@ watch(currentMusic, (newMusic) => { lyricLines.value = {} if (isExpanded.value) expandedActiveTab.value = 'lyric' } -}, { deep: true }) +}, { immediate: true })