🐞 fix: 修复解析方法的问题

This commit is contained in:
alger
2023-12-20 16:19:16 +08:00
parent a1780bc9d4
commit 19140cd680
4 changed files with 18 additions and 23 deletions
+7 -5
View File
@@ -2,7 +2,7 @@ import { createStore } from "vuex";
import { SongResult } from "@/type/music";
import { getMusicUrl, getParsingMusicUrl } from '@/api/music'
import homeRouter from '@/router/home'
import { getMusicProxyUrl } from '@/hooks/MusicHook'
import { getMusicProxyUrl } from '@/utils'
interface State {
menus: any[]
@@ -58,24 +58,26 @@ const mutations = {
const getSongUrl = async (id: number) => {
const { data } = await getMusicUrl(id)
let url = ''
try {
if (data.data[0].freeTrialInfo) {
const res = await getParsingMusicUrl(id)
return res.data.data.url
url = res.data.data.url
}
} catch (error) {
console.error('error', error)
}
return data.data[0].url
url = data.data[0].url
return getMusicProxyUrl(url)
}
const updatePlayMusic = async (state: State) => {
state.playMusic = state.playList[state.playListIndex]
const playMusicUrl = await getSongUrl(state.playMusic.id)
state.playMusicUrl = getMusicProxyUrl(playMusicUrl)
state.playMusicUrl = await getSongUrl(state.playMusic.id)
state.play = true
}
const store = createStore({
state: state,
mutations: mutations,