mirror of
https://github.com/algerkong/AlgerMusicPlayer.git
synced 2026-04-29 03:17:22 +08:00
没啥
This commit is contained in:
+10
-4
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user