From 67ed529e8c776b3f62e0cc570c85814db6a438d3 Mon Sep 17 00:00:00 2001 From: mackt <1033530438@qq.com> Date: Fri, 26 Apr 2024 22:35:02 +0500 Subject: [PATCH] =?UTF-8?q?update(Auth):=20=E6=92=AD=E6=94=BE=E8=A1=8C?= =?UTF-8?q?=E4=B8=BA=E9=89=B4=E6=9D=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/my/collect/song/page.tsx | 3 ++- src/app/my/collect/vol/page.tsx | 3 ++- src/components/Button/ButtonFM.tsx | 3 ++- src/components/Journal/VolPlayButton.tsx | 3 ++- src/components/SongCard/SongCardList.tsx | 3 ++- src/store/audio.ts | 14 ++++++++------ 6 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/app/my/collect/song/page.tsx b/src/app/my/collect/song/page.tsx index 5b15536..a4b7d23 100644 --- a/src/app/my/collect/song/page.tsx +++ b/src/app/my/collect/song/page.tsx @@ -50,7 +50,8 @@ export default function Journal() { return; } - setPlayListInfo({ type: 'collectSingle', id: null }); + const res = setPlayListInfo({ type: 'collectSingle', id: null }); + if (!res) return; setPlayList(songList); setAudioId(id); }; diff --git a/src/app/my/collect/vol/page.tsx b/src/app/my/collect/vol/page.tsx index 30bc493..620f000 100644 --- a/src/app/my/collect/vol/page.tsx +++ b/src/app/my/collect/vol/page.tsx @@ -65,7 +65,8 @@ export default function Journal() { return; } - setPlayListInfo({ type: 'collectVol', id: null }); + const res = setPlayListInfo({ type: 'collectVol', id: null }); + if (!res) return; setPlayList(songList); setAudioId(songList[0].id); }; diff --git a/src/components/Button/ButtonFM.tsx b/src/components/Button/ButtonFM.tsx index a3a048a..d19ddb5 100644 --- a/src/components/Button/ButtonFM.tsx +++ b/src/components/Button/ButtonFM.tsx @@ -48,10 +48,11 @@ export default function ButtonFM() { const res = await apiGetSongRandom(5); if (res.code === 200 && res.data.length > 0) { - setPlayListInfo({ + const setRes = setPlayListInfo({ type: 'fm', id: null, }); + if (!setRes) return; setPlayList(res.data); setPlayOrder('list_loop'); setPlayQueue([res.data[0]]); diff --git a/src/components/Journal/VolPlayButton.tsx b/src/components/Journal/VolPlayButton.tsx index 4b57f98..675f197 100644 --- a/src/components/Journal/VolPlayButton.tsx +++ b/src/components/Journal/VolPlayButton.tsx @@ -32,10 +32,11 @@ export default function VolPlayButton({ const handlePlay = (state: boolean) => { if (state && !isCurrentVol) { - setPlayListInfo({ + const res = setPlayListInfo({ type: 'vol', id: journalInfo.id, }); + if (!res) return; setPlayList(songList); setAudioId(songList[0].id); } diff --git a/src/components/SongCard/SongCardList.tsx b/src/components/SongCard/SongCardList.tsx index 8523752..3e89f7c 100644 --- a/src/components/SongCard/SongCardList.tsx +++ b/src/components/SongCard/SongCardList.tsx @@ -48,7 +48,8 @@ export default function SongCardList({ listInfo, songList, className, collectTyp } // 重新设置播放列表 - setPlayListInfo(listInfo as IPlayListInfo); + const res = setPlayListInfo(listInfo as IPlayListInfo); + if (!res) return; setPlayList(songList); setAudioId(id); }; diff --git a/src/store/audio.ts b/src/store/audio.ts index a9de258..54f6115 100644 --- a/src/store/audio.ts +++ b/src/store/audio.ts @@ -33,7 +33,7 @@ interface AuioState { setShow: (value: boolean) => void; // 显示/隐藏单曲卡片 setShowCard: (value: boolean) => void; - setPlayListInfo: (info: IPlayListInfo) => void; + setPlayListInfo: (info: IPlayListInfo) => boolean; // 设置播放列表 updatePlayList: (list: SongInfo[]) => void; // 设置播放列表 @@ -205,11 +205,17 @@ const useAudioState = create()( }), ), setPlayListInfo: (list) => { + if (!checkAuthOffline()) { + openLogin(); + return false; + } + set( produce((state) => { state.playListInfo = list; }), ); + return true; }, updatePlayList: (list) => { set( @@ -219,11 +225,6 @@ const useAudioState = create()( ); }, setPlayList: (list) => { - if (!checkAuthOffline()) { - openLogin(); - return; - } - set( produce((state) => { state.playList = list; @@ -231,6 +232,7 @@ const useAudioState = create()( state.playQueue = list; }), ); + return true; }, setPlayQueue: (list) => { set(