From d66494f19df47229d8f7a7c00b6204983f7dd867 Mon Sep 17 00:00:00 2001 From: CosineSky <11737516+cosinesky@user.noreply.gitee.com> Date: Wed, 18 Dec 2024 15:01:23 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E4=B8=BB=E9=A1=B5=E9=9D=A2=E5=8F=B3?= =?UTF-8?q?=E4=BE=A7=E5=92=8C=E5=BA=95=E9=83=A8=E6=92=AD=E6=94=BE=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E7=8E=B0=E5=9C=A8=E4=B8=8D=E4=BC=9A=E9=9A=8F=E4=B8=AD?= =?UTF-8?q?=E9=83=A8=E5=B1=95=E7=A4=BA=E5=86=85=E5=AE=B9=E5=8F=98=E5=8C=96?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/HomePage.vue | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/views/HomePage.vue b/src/views/HomePage.vue index 88aadef..9ea3e3a 100644 --- a/src/views/HomePage.vue +++ b/src/views/HomePage.vue @@ -334,6 +334,7 @@ const currentUserId = ref(userToken.value.id); */ // Playing Status const songs = ref([]); +const displayingSongs = ref([]); const isPaused = ref(false); const duration = ref(0); const playingMode = ref(0); /* 0 - Normal, 1 - Loop, 2 - Random */ @@ -396,6 +397,7 @@ const switchToSong = (index) => { const playlists = ref([]); const currentPlaylist = ref(2); const currentPlaylistId = ref(2); +const displayingPlaylist = ref(2); const receivePlaylistId = (value) => { currentPlaylist.value = value; currentPlaylistId.value = value.id; @@ -407,6 +409,16 @@ const receivePlaylistId = (value) => { console.log("Failed to get songs!"); }); }; +const receiveDisplayingPlaylist = (value) => { + displayingPlaylist.value = value; + getSongsByPlaylist({ + playlist_id: value.id, + }).then((res) => { + displayingSongs.value = res.data.result; + }).catch(e => { + console.log("Failed to get songs!"); + }); +}; /* @@ -447,12 +459,14 @@ onMounted(() => { }).then((res) => { playlists.value = res.data.result; currentPlaylist.value = playlists.value[0]; + displayingPlaylist.value = playlists.value[0]; currentPlaylistId.value = currentPlaylist.value.id; theme.change(currentPlaylist.value.picPath); getSongsByPlaylist({ playlist_id: currentPlaylistId.value, }).then((res) => { songs.value = res.data.result; + displayingSongs.value = res.data.result; currentSongId.value = songs.value[0].id; // TODO: currentSongIndex != currentSongId ? @@ -475,12 +489,12 @@ onMounted(() => { <!-- MAIN & RIGHT CONTENT --> <Header class="header" @headData="receiveDataFromHeader"/> <img class="logo" src="../assets/pictures/logos/logo3.png" alt=""> - <left-side-bar class="left-side-bar" @setCurrentPlaylist="receivePlaylistId"/> + <left-side-bar class="left-side-bar" @setCurrentPlaylist="receiveDisplayingPlaylist"/> <div class="content" :class="{ 'full-width': !showRightContent }"> <div class="main-view" :class="{ 'expanded': !showRightContent }"> <el-container v-if="midComponents == 1" class="playlist-container" style="overflow: auto; height: 698px ;border-radius: 12px"> - <MusicAlbumView :album-info="currentPlaylist" :music-list="songs"/> + <MusicAlbumView :album-info="displayingPlaylist" :music-list="displayingSongs"/> </el-container> <el-container v-if="midComponents == 2" class="playlist-container" style="overflow: auto; height: 668px"> -- GitLab