mirror of
https://github.com/algerkong/AlgerMusicPlayer.git
synced 2026-04-28 10:57:23 +08:00
🐞 fix: 修复解析方法的问题
This commit is contained in:
@@ -90,17 +90,6 @@ const setAudioTime = (index: any, audio: HTMLAudioElement) => {
|
|||||||
audio.play()
|
audio.play()
|
||||||
}
|
}
|
||||||
|
|
||||||
const ProxyUrl =
|
|
||||||
import.meta.env.VITE_API_PROXY + '' || 'http://110.42.251.190:9856'
|
|
||||||
|
|
||||||
const getMusicProxyUrl = (url: string) => {
|
|
||||||
if (!getIsMc()) {
|
|
||||||
return url
|
|
||||||
}
|
|
||||||
const PUrl = url.split('').join('+')
|
|
||||||
return `${ProxyUrl}/mc?url=${PUrl}`
|
|
||||||
}
|
|
||||||
|
|
||||||
export {
|
export {
|
||||||
lrcData,
|
lrcData,
|
||||||
lrcArray,
|
lrcArray,
|
||||||
@@ -113,5 +102,4 @@ export {
|
|||||||
setAudioTime,
|
setAudioTime,
|
||||||
nowTime,
|
nowTime,
|
||||||
allTime,
|
allTime,
|
||||||
getMusicProxyUrl,
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -237,12 +237,6 @@ const setMusicFull = () => {
|
|||||||
musicFull.value = !musicFull.value
|
musicFull.value = !musicFull.value
|
||||||
}
|
}
|
||||||
|
|
||||||
// 解析音乐
|
|
||||||
const parsingMusic = async () => {
|
|
||||||
const { data } = await getParsingMusicUrl(playMusic.value.id)
|
|
||||||
store.state.playMusicUrl = data.data.url
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|||||||
+7
-5
@@ -2,7 +2,7 @@ import { createStore } from "vuex";
|
|||||||
import { SongResult } from "@/type/music";
|
import { SongResult } from "@/type/music";
|
||||||
import { getMusicUrl, getParsingMusicUrl } from '@/api/music'
|
import { getMusicUrl, getParsingMusicUrl } from '@/api/music'
|
||||||
import homeRouter from '@/router/home'
|
import homeRouter from '@/router/home'
|
||||||
import { getMusicProxyUrl } from '@/hooks/MusicHook'
|
import { getMusicProxyUrl } from '@/utils'
|
||||||
|
|
||||||
interface State {
|
interface State {
|
||||||
menus: any[]
|
menus: any[]
|
||||||
@@ -58,24 +58,26 @@ const mutations = {
|
|||||||
|
|
||||||
const getSongUrl = async (id: number) => {
|
const getSongUrl = async (id: number) => {
|
||||||
const { data } = await getMusicUrl(id)
|
const { data } = await getMusicUrl(id)
|
||||||
|
let url = ''
|
||||||
try {
|
try {
|
||||||
if (data.data[0].freeTrialInfo) {
|
if (data.data[0].freeTrialInfo) {
|
||||||
const res = await getParsingMusicUrl(id)
|
const res = await getParsingMusicUrl(id)
|
||||||
return res.data.data.url
|
url = res.data.data.url
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('error', error)
|
console.error('error', error)
|
||||||
}
|
}
|
||||||
return data.data[0].url
|
url = data.data[0].url
|
||||||
|
return getMusicProxyUrl(url)
|
||||||
}
|
}
|
||||||
|
|
||||||
const updatePlayMusic = async (state: State) => {
|
const updatePlayMusic = async (state: State) => {
|
||||||
state.playMusic = state.playList[state.playListIndex]
|
state.playMusic = state.playList[state.playListIndex]
|
||||||
const playMusicUrl = await getSongUrl(state.playMusic.id)
|
state.playMusicUrl = await getSongUrl(state.playMusic.id)
|
||||||
state.playMusicUrl = getMusicProxyUrl(playMusicUrl)
|
|
||||||
state.play = true
|
state.play = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const store = createStore({
|
const store = createStore({
|
||||||
state: state,
|
state: state,
|
||||||
mutations: mutations,
|
mutations: mutations,
|
||||||
|
|||||||
@@ -30,6 +30,17 @@ export const secondToMinute = (s: number) => {
|
|||||||
export const getIsMc = () => {
|
export const getIsMc = () => {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
const ProxyUrl =
|
||||||
|
import.meta.env.VITE_API_PROXY + '' || 'http://110.42.251.190:9856'
|
||||||
|
|
||||||
|
export const getMusicProxyUrl = (url: string) => {
|
||||||
|
if (!getIsMc()) {
|
||||||
|
return url
|
||||||
|
}
|
||||||
|
const PUrl = url.split('').join('+')
|
||||||
|
return `${ProxyUrl}/mc?url=${PUrl}`
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export const getImgUrl = computed(() => (url: string, size: string = '') => {
|
export const getImgUrl = computed(() => (url: string, size: string = '') => {
|
||||||
const bdUrl = 'https://image.baidu.com/search/down?url='
|
const bdUrl = 'https://image.baidu.com/search/down?url='
|
||||||
|
|||||||
Reference in New Issue
Block a user