From c0e485edb762151802164999a434621d68bec187 Mon Sep 17 00:00:00 2001 From: algerkong Date: Wed, 21 Jul 2021 17:45:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B2=A1=E5=95=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 2 +- src/layout/AppLayout.vue | 9 ++- src/layout/components/PlayBar.vue | 109 +++++++++++++++++++++++++----- src/store/index.ts | 14 ++-- 4 files changed, 112 insertions(+), 22 deletions(-) diff --git a/index.html b/index.html index 695423e..52c3e3a 100644 --- a/index.html +++ b/index.html @@ -6,7 +6,7 @@ Vite App - + \ No newline at end of file diff --git a/src/store/index.ts b/src/store/index.ts index 20f2875..8d5ae8d 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -1,5 +1,6 @@ import { createStore } from "vuex"; import { SongResult } from "@/type/music"; +import { getMusicUrl } from "@/api/music"; let state = { menus: [ @@ -21,6 +22,7 @@ let state = { ], isPlay: false, playMusic: {} as SongResult, + playMusicUrl: "", }; let mutations = { @@ -28,17 +30,21 @@ let mutations = { state.menus = menus; }, setPlay(state: any, playMusic: SongResult) { - console.log(playMusic); - state.playMusic = playMusic; + state.playMusicUrl = getSongUrl(playMusic.id); }, setIsPlay(state: any, isPlay: boolean) { - console.log(isPlay); - state.isPlay = isPlay; }, }; +const getSongUrl = async (id: number) => { + const { data } = await getMusicUrl(id); + console.log(data.data[0].url); + + return data.data[0].url; +}; + const store = createStore({ state: state, mutations: mutations,