From a1780bc9d44e071a63dbdf3f08bd511dab2580be Mon Sep 17 00:00:00 2001 From: alger Date: Wed, 20 Dec 2023 15:53:33 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(music):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E8=A7=A3=E6=9E=90=20=E5=B9=B6=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E8=8E=B7=E5=8F=96url=E7=9A=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.production | 2 +- src/hooks/MusicHook.ts | 13 ++++++++ src/layout/components/PlayBar.vue | 50 ++++--------------------------- src/store/index.ts | 24 ++++++++++----- vite.config.ts | 2 +- 5 files changed, 36 insertions(+), 55 deletions(-) diff --git a/.env.production b/.env.production index 0b6befa..0a70917 100644 --- a/.env.production +++ b/.env.production @@ -1,4 +1,4 @@ VITE_API = http://110.42.251.190:9898 VITE_API_MT = http://mt.myalger.top -VITE_API_MUSIC = http://myalger.top:4000 +VITE_API_MUSIC = http://110.42.251.190:4100 VITE_API_PROXY = http://110.42.251.190:9856 \ No newline at end of file diff --git a/src/hooks/MusicHook.ts b/src/hooks/MusicHook.ts index 07d15c3..ae48417 100644 --- a/src/hooks/MusicHook.ts +++ b/src/hooks/MusicHook.ts @@ -1,5 +1,6 @@ import { getMusicLrc } from '@/api/music' import { ILyric } from '@/type/lyric' +import { getIsMc } from '@/utils' import { ref } from 'vue' interface ILrcData { @@ -89,6 +90,17 @@ const setAudioTime = (index: any, audio: HTMLAudioElement) => { 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 { lrcData, lrcArray, @@ -101,4 +113,5 @@ export { setAudioTime, nowTime, allTime, + getMusicProxyUrl, } diff --git a/src/layout/components/PlayBar.vue b/src/layout/components/PlayBar.vue index 093b6cf..37d7e20 100644 --- a/src/layout/components/PlayBar.vue +++ b/src/layout/components/PlayBar.vue @@ -62,12 +62,12 @@ 喜欢 - +