Skip to content

Commit

Permalink
fix: 再次修复歌曲切换时导致自定义页面消失的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
QingXia-Ela committed Aug 1, 2024
1 parent 5012dbb commit fa98198
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import NavSearch from '@/components/Input';
import { useStore } from '@nanostores/react';
import $PlayListState from '@/store/pages/playlist';
import SirenStore from '@/store/SirenStore';
import navigate from '@/router/utils/navigate';

interface RightDetailsMiddleSplitProps {
onSearch?: (keyword: string) => void;
Expand All @@ -32,10 +33,13 @@ const RightDetailsMiddleSplit: FunctionComponent<
}, [searchValue]);

const play = () => {
SirenStore.dispatch({
type: 'musicPlay/toAlbum',
cid: store.currentAlbumInfo.cid!,
});
let cid = store.currentAlbumData[0].cid
if (cid) {
SirenStore.dispatch({
type: 'player/selectSong',
cid,
});
}
};
return (
<div className={Styles.middle_control}>
Expand Down
6 changes: 0 additions & 6 deletions src/router/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ const routes: RouteItem[] = [
component: Download,
name: '下载',
},
// {
// type: 'vanilla',
// name: '正在播放',
// element: document.createElement('a'),
// addToNav: true,
// },
];

export default routes;
5 changes: 4 additions & 1 deletion src/store/models/router/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { atom } from 'nanostores';
import SirenStore from '@/store/SirenStore';
import SirenRouter from '@/router/SirenRouter';
import routes from '@/router';

// var a = require("@mui/material")

Expand Down Expand Up @@ -31,8 +32,10 @@ SirenStore.subscribe(() => {
// 音乐切换时,路由也会变化,会导致自定义路由页退出展示
// 发生音乐切换时,路由变化为 `/last/route` -> `/music/cid`
// 因此假如下一个跳转页面是音乐页面则需要拦截此次操作
if (!currentPath.match(namespaceMusicPath))
// @ts-expect-error: path always compareable
if (!currentPath.match(namespaceMusicPath) && !routes.some((route) => route.path === currentPath)) {
$customRouter.set({ ...$customRouter.get(), path });
}
}
});

Expand Down
1 change: 0 additions & 1 deletion src/types/SirenStore/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ const initalProps = {
belong: '',
coverUrl: '',
coverDeUrl: null,
songs: [],
},
},
loading: {
Expand Down

0 comments on commit fa98198

Please sign in to comment.