Skip to content

Commit

Permalink
Fix base url
Browse files Browse the repository at this point in the history
  • Loading branch information
HeHang0 committed Mar 28, 2024
1 parent 02cc363 commit 3b814ff
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ jobs:
cd web
yarn
yarn build:zip
echo '<html><head><script>if(!localStorage.getItem("musiche-proxy-address"))localStorage.setItem("musiche-proxy-address","https://music.picapico.top/proxy");localStorage.setItem("musiche-router-prefix","musiche");let pathname=location.pathname.substring(9);let redirect=pathname?`${(location.search?"&":"?")}redirect=${pathname}`:"";location.href="/musiche"+location.search+redirect;</script></head></html>' > dist/404.html
cd ..\windows
echo "<Weavers><Costura/></Weavers>" > FodyWeavers.xml
mv ..\web\web.zip Resources\web.zip
Expand All @@ -113,6 +112,7 @@ jobs:
cd ..\web
Remove-Item dist -Force -Recurse -ErrorAction SilentlyContinue
yarn build:musiche
echo '<html><head><script>if(!localStorage.getItem("musiche-proxy-address"))localStorage.setItem("musiche-proxy-address","https://music.picapico.top/proxy");let pathname=location.pathname.substring(9);let redirect=pathname?`${(location.search?"&":"?")}redirect=${pathname}`:"";location.href="/musiche"+location.search+redirect;</script></head></html>' > 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
Expand Down
5 changes: 4 additions & 1 deletion web/src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
});

Expand Down
28 changes: 14 additions & 14 deletions web/src/stores/play.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 3 additions & 1 deletion web/src/utils/http.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
4 changes: 3 additions & 1 deletion web/src/utils/logo.ts
Original file line number Diff line number Diff line change
@@ -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';

0 comments on commit 3b814ff

Please sign in to comment.