From 3b814ffe3c5215b9e116963108bcae2d49330f4b Mon Sep 17 00:00:00 2001 From: He Hang Date: Thu, 28 Mar 2024 19:00:19 +0800 Subject: [PATCH] Fix base url --- .github/workflows/web.yml | 2 +- web/src/router/index.ts | 5 ++++- web/src/stores/play.ts | 28 ++++++++++++++-------------- web/src/utils/http.ts | 4 +++- web/src/utils/logo.ts | 4 +++- 5 files changed, 25 insertions(+), 18 deletions(-) diff --git a/.github/workflows/web.yml b/.github/workflows/web.yml index 90b5624..d7cc0ea 100644 --- a/.github/workflows/web.yml +++ b/.github/workflows/web.yml @@ -101,7 +101,6 @@ jobs: cd web yarn yarn build:zip - echo '' > dist/404.html cd ..\windows echo "" > FodyWeavers.xml mv ..\web\web.zip Resources\web.zip @@ -113,6 +112,7 @@ jobs: cd ..\web Remove-Item dist -Force -Recurse -ErrorAction SilentlyContinue yarn build:musiche + echo '' > 404.html cd .. copy windows\bin\Release\net472\Musiche.exe web\dist\Musiche.exe -ErrorAction SilentlyContinue copy windows\bin\Publish\net6.0-windows\Musiche.exe web\dist\Musiche.net6.exe -ErrorAction SilentlyContinue diff --git a/web/src/router/index.ts b/web/src/router/index.ts index 1547a56..8efcf48 100644 --- a/web/src/router/index.ts +++ b/web/src/router/index.ts @@ -96,7 +96,10 @@ const routers: RouteRecordRaw[] = [ ]; routers.push({ path: '/:catchAll(.*)', redirect: '/recommend' }); const router = createRouter({ - history: createWebHistory(`${import.meta.env.BASE_URL}` || undefined), + history: createWebHistory( + `${import.meta.env.BASE_URL != '/' ? import.meta.env.BASE_URL : ''}` || + undefined + ), routes: routers }); diff --git a/web/src/stores/play.ts b/web/src/stores/play.ts index 6a898ee..85f17c3 100644 --- a/web/src/stores/play.ts +++ b/web/src/stores/play.ts @@ -287,21 +287,21 @@ export const usePlayStore = defineStore('play', { }, async updateRemoteList() { if (!this.config.list) return; - await musicOperate( - '/updatelist', - JSON.stringify({ - music: this.music, - playlist: this.musicList.map(m => ({ - ...m, - cookie: api.getCookie(m.type), - url: '', - lover: !!this.myLover[m.type + m.id] - })) - }), - { - 'content-type': 'application/json' - } + const data: any = { + music: this.music, + playlist: this.musicList.map(m => ({ + ...m, + cookie: api.getCookie(m.type), + url: '', + lover: !!this.myLover[m.type + m.id] + })) + }; + data.music = data.playlist.find( + (m: Music) => m.type == this.music.type && m.id == this.music.id ); + await musicOperate('/updatelist', JSON.stringify(data), { + 'content-type': 'application/json' + }); }, async play(music?: Music, musicList?: Music[]) { if (this.preparePlay) { diff --git a/web/src/utils/http.ts b/web/src/utils/http.ts index d505031..9607eaf 100644 --- a/web/src/utils/http.ts +++ b/web/src/utils/http.ts @@ -1,6 +1,8 @@ import { AudioPlayer } from './audio'; import { ProxyRequestData } from './type'; -const history = `${import.meta.env.BASE_URL}`; +const history = `${ + import.meta.env.BASE_URL != '/' ? import.meta.env.BASE_URL : '' +}`; export const httpAddress = import.meta.env.DEV ? '127.0.0.1:54621' diff --git a/web/src/utils/logo.ts b/web/src/utils/logo.ts index 5fdfeb2..9d212d0 100644 --- a/web/src/utils/logo.ts +++ b/web/src/utils/logo.ts @@ -1,3 +1,5 @@ -const imagePrefix = `${import.meta.env.BASE_URL}`; +const imagePrefix = `${ + import.meta.env.BASE_URL != '/' ? import.meta.env.BASE_URL : '' +}`; export const LogoImage = imagePrefix + '/logo.png'; export const LogoCircleImage = imagePrefix + '/logo-circle.png';