From 388dcae818d9bd45c3990321ba32539b97236162 Mon Sep 17 00:00:00 2001
From: hyf <221250007@smail.nju.edu.cn>
Date: Tue, 31 Dec 2024 11:45:02 +0800
Subject: [PATCH] =?UTF-8?q?1.=20=E5=AE=9E=E7=8E=B0=E7=82=B9=E5=87=BB?=
 =?UTF-8?q?=E6=AD=8C=E5=8D=95=E5=90=8D=E7=A7=B0=E5=8D=B3=E8=BF=9B=E5=85=A5?=
 =?UTF-8?q?=EF=BC=8C=E8=8B=A5=E6=B2=A1=E6=9C=89=E6=94=B6=E5=BD=95=E6=AD=8C?=
 =?UTF-8?q?=E5=8D=95=E5=88=99=E6=8F=90=E9=86=92?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/api/playlist.js           |  4 +++-
 src/api/song.js               |  1 +
 src/components/SearchView.vue |  9 +++++++--
 src/views/HomePage.vue        | 30 ++++++++++++++++++------------
 4 files changed, 29 insertions(+), 15 deletions(-)

diff --git a/src/api/playlist.js b/src/api/playlist.js
index 181e4ef..af327d4 100644
--- a/src/api/playlist.js
+++ b/src/api/playlist.js
@@ -20,7 +20,9 @@ export const getPlaylistsByUser = (userInfo) => {
  */
 export const getPlaylistsByTitle = (titleInfo) => {
     console.log(titleInfo)
-    return axios.get(`${PLAYLIST_MODULE}/fetchByTitle`, { params: titleInfo })
+    return axios.get(`${PLAYLIST_MODULE}/title`, { params: {
+        title: titleInfo.title
+        } })
         .then(res => {
             return res;
         });
diff --git a/src/api/song.js b/src/api/song.js
index 100cc97..1619bbc 100644
--- a/src/api/song.js
+++ b/src/api/song.js
@@ -9,6 +9,7 @@ import { SONG_MODULE } from './_prefix';
     + playlist_id: number
  */
 export const getSongsByPlaylist = (playlistInfo) => {
+    console.log(playlistInfo)
     return axios.get(`${SONG_MODULE}/fetch`, { params: playlistInfo })
         .then(res => {
             return res;
diff --git a/src/components/SearchView.vue b/src/components/SearchView.vue
index 438e1c6..1e7f015 100644
--- a/src/components/SearchView.vue
+++ b/src/components/SearchView.vue
@@ -36,6 +36,8 @@ const currentTab = ref('songs')
 const handleTabClick = (tab) => {
   currentTab.value = tab
 }
+const userToken = ref(JSON.parse(sessionStorage.getItem('user-token')));
+const currentUserId = ref(userToken.value.id);
 
 // const songDurations = ref(new Map());
 // watch(() => props.musicList, (newSongs) => {
@@ -48,13 +50,16 @@ let musicPlayIndex = ref(null);
 let musicPauseIndex = ref(null);
 
 const playFromId = (musicId) => {
-  if (musicId === null || musicId === undefined) {
+
+  if (musicId === null ) {
     // 浠庡ご寮€濮嬫挱鏀�
     musicPlayIndex  = props.currentSongId;
   } else {
     musicPlayIndex  = musicId;
+    // console.log(musicPlayIndex)
   }
-  emit('switchSong', musicPlayIndex, true);
+  console.log(musicPlayIndex)
+  emit('switchSong', props.albumInfo, true);
   musicPauseIndex = null;
 }
 
diff --git a/src/views/HomePage.vue b/src/views/HomePage.vue
index 8071a1d..fbd0d56 100644
--- a/src/views/HomePage.vue
+++ b/src/views/HomePage.vue
@@ -20,7 +20,7 @@ import NowPlayingView from '../components/NowPlayingView.vue';
 
 // APIs
 import {getSongsByEpisode, getSongsByPlaylist} from "../api/song";
-import {getPlaylistsByUser} from "../api/playlist";
+import {getPlaylistsByTitle, getPlaylistsByUser} from "../api/playlist";
 
 // Others
 import {useTheme} from "../store/theme";
@@ -29,6 +29,7 @@ import {updateBackground} from "../utils/getBackgroundColor";
 import { formatTime } from '../utils/formatTime';
 import {getArtistById, getPlaylistById, getUserById} from "../api/resolve";
 import {userFollowArtist} from "@/api/user";
+import {ElMessage} from "element-plus";
 
 
 /*
@@ -518,18 +519,23 @@ const receiveDisplayingEpisode = (episode) => {
 };
 
 const receiveDisplayingEpisodeByName = (episodeName) => {
-	setMidComponents(4);
 
-	//TODO:
-	// getPlaylistByName();
-	displayingEpisode.value = episode;
-	getSongsByPlaylist({
-		playlist_id: episodeName.id,
-	}).then((res) => {
-		displayingSongs.value = res.data.result;
-	}).catch(e => {
-		console.log("Failed to get songs!");
-	});
+  console.log(episodeName);
+  getPlaylistsByTitle({title:episodeName}).then((res) => {
+    const episode = res.data.result;
+    displayingEpisode.value = episode;
+    console.log(episode);
+    getSongsByPlaylist({playlist_id:  episode.id}).then((res) => {
+      displayingSongs.value = res.data.result;
+      setMidComponents(4);
+    }).catch(e => {
+      console.log("Failed to get songs!");
+    });
+  }).catch(e=>{
+    ElMessage.warning("鏈瓕鍗曟湭琚敹褰�")
+  })
+
+
 }
 /*
     SEARCH
-- 
GitLab