From bb7d1e332fd5a386d4dcc61ff0eeef9d1bfe9af6 Mon Sep 17 00:00:00 2001 From: alger Date: Fri, 11 Apr 2025 20:07:51 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20=E4=BC=98=E5=8C=96=E9=9F=B3?= =?UTF-8?q?=E4=B9=90=E5=B0=81=E9=9D=A2=E6=98=BE=E7=A4=BA=E9=80=BB=E8=BE=91?= =?UTF-8?q?=EF=BC=8C=E7=A1=AE=E4=BF=9D=E5=9C=A8=E7=BC=BA=E5=A4=B1=E5=B0=81?= =?UTF-8?q?=E9=9D=A2=E6=97=B6=E4=BD=BF=E7=94=A8=E9=BB=98=E8=AE=A4=E5=9B=BE?= =?UTF-8?q?=E7=89=87=EF=BC=8C=E5=B9=B6=E6=9B=B4=E6=96=B0=E6=8E=A8=E8=8D=90?= =?UTF-8?q?=E4=B8=93=E8=BE=91=E7=BB=84=E4=BB=B6=E4=BB=A5=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E5=B0=81=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/components/MusicList.vue | 23 ++++++++++++++++++- .../components/home/RecommendAlbum.vue | 16 +++++++------ 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/src/renderer/components/MusicList.vue b/src/renderer/components/MusicList.vue index 55dc1b7..3e76364 100644 --- a/src/renderer/components/MusicList.vue +++ b/src/renderer/components/MusicList.vue @@ -44,7 +44,7 @@
{ return props.songList.length; }); +const getCoverImgUrl = computed(() => { + if (props.listInfo?.coverImgUrl) { + return props.listInfo.coverImgUrl; + } + + const song = props.songList[0]; + if (song?.picUrl) { + return song.picUrl; + } + if (song?.al?.picUrl) { + return song.al.picUrl; + } + if (song?.album?.picUrl) { + return song.album.picUrl; + } + return ''; +}); + // 过滤歌曲列表 const filteredSongs = computed(() => { if (!searchKeyword.value) { @@ -203,6 +221,9 @@ const filteredSongs = computed(() => { // 格式化歌曲数据 const formatSong = (item: any) => { + if (!item) { + return null; + } return { ...item, picUrl: item.al?.picUrl || item.picUrl, diff --git a/src/renderer/components/home/RecommendAlbum.vue b/src/renderer/components/home/RecommendAlbum.vue index a0ed779..513ce73 100644 --- a/src/renderer/components/home/RecommendAlbum.vue +++ b/src/renderer/components/home/RecommendAlbum.vue @@ -26,7 +26,7 @@ v-model:show="showMusic" :name="albumName" :song-list="songList" - :cover="false" + :cover="true" :loading="loadingList" :list-info="albumInfo" /> @@ -62,17 +62,19 @@ const handleClick = async (item: any) => { loadingList.value = true; showMusic.value = true; const res = await getAlbum(item.id); - songList.value = res.data.songs.map((song: any) => { - song.al.picUrl = song.al.picUrl || item.picUrl; + const { songs, album } = res.data; + songList.value = songs.map((song: any) => { + song.al.picUrl = song.al.picUrl || album.picUrl; + song.picUrl = song.al.picUrl || album.picUrl || song.picUrl; return song; }); albumInfo.value = { - ...res.data.album, + ...album, creator: { - avatarUrl: res.data.album.artist.img1v1Url, - nickname: `${res.data.album.artist.name} - ${res.data.album.company}` + avatarUrl: album.artist.img1v1Url, + nickname: `${album.artist.name} - ${album.company}` }, - description: res.data.album.description + description: album.description }; loadingList.value = false; };