mirror of
https://github.com/algerkong/AlgerMusicPlayer.git
synced 2026-04-23 23:57:22 +08:00
✨ feat(music): 添加自动解析 并修改获取url的逻辑
This commit is contained in:
+16
-8
@@ -1,7 +1,8 @@
|
||||
import { createStore } from "vuex";
|
||||
import { SongResult } from "@/type/music";
|
||||
import { getMusicUrl } from "@/api/music";
|
||||
import homeRouter from "@/router/home";
|
||||
import { getMusicUrl, getParsingMusicUrl } from '@/api/music'
|
||||
import homeRouter from '@/router/home'
|
||||
import { getMusicProxyUrl } from '@/hooks/MusicHook'
|
||||
|
||||
interface State {
|
||||
menus: any[]
|
||||
@@ -56,15 +57,22 @@ const mutations = {
|
||||
}
|
||||
|
||||
const getSongUrl = async (id: number) => {
|
||||
const { data } = await getMusicUrl(id);
|
||||
console.log(data.data[0].url);
|
||||
|
||||
return data.data[0].url;
|
||||
};
|
||||
const { data } = await getMusicUrl(id)
|
||||
try {
|
||||
if (data.data[0].freeTrialInfo) {
|
||||
const res = await getParsingMusicUrl(id)
|
||||
return res.data.data.url
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('error', error)
|
||||
}
|
||||
return data.data[0].url
|
||||
}
|
||||
|
||||
const updatePlayMusic = async (state: State) => {
|
||||
state.playMusic = state.playList[state.playListIndex]
|
||||
state.playMusicUrl = await getSongUrl(state.playMusic.id)
|
||||
const playMusicUrl = await getSongUrl(state.playMusic.id)
|
||||
state.playMusicUrl = getMusicProxyUrl(playMusicUrl)
|
||||
state.play = true
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user