diff --git a/src/renderer/components/Lyric/Player.tsx b/src/renderer/components/Lyric/Player.tsx index 05d13ee..dfeb5b6 100644 --- a/src/renderer/components/Lyric/Player.tsx +++ b/src/renderer/components/Lyric/Player.tsx @@ -102,7 +102,7 @@ const Controls = () => { return (
- {mode === PlayerMode.PLAYLIST && ( + {mode === PlayerMode.TrackList && ( track && player.prevTrack()} disabled={!track} diff --git a/src/renderer/components/Player.tsx b/src/renderer/components/Player.tsx index 789ec7c..0be4d42 100644 --- a/src/renderer/components/Player.tsx +++ b/src/renderer/components/Player.tsx @@ -95,7 +95,7 @@ const MediaControls = () => { return (
- {mode === PlayerMode.PLAYLIST && ( + {mode === PlayerMode.TrackList && ( track && player.prevTrack()} disabled={!track} diff --git a/src/renderer/components/Sidebar.tsx b/src/renderer/components/Sidebar.tsx index 6196f04..cab86f5 100644 --- a/src/renderer/components/Sidebar.tsx +++ b/src/renderer/components/Sidebar.tsx @@ -83,7 +83,7 @@ const Playlists = () => { > {playlist.name} {playlistMode === TrackListSourceType.PLAYLIST && - mode === Mode.PLAYLIST && + mode === Mode.TrackList && currentPlaylistID === playlist.id && ( )} diff --git a/src/renderer/pages/Album.tsx b/src/renderer/pages/Album.tsx index 863f62c..c8fa19a 100644 --- a/src/renderer/pages/Album.tsx +++ b/src/renderer/pages/Album.tsx @@ -37,10 +37,15 @@ const PlayButton = ({ const playerSnapshot = useSnapshot(player) const isThisAlbumPlaying = useMemo( () => - playerSnapshot.mode === PlayerMode.PLAYLIST && + playerSnapshot.mode === PlayerMode.TrackList && playerSnapshot.trackListSource?.type === TrackListSourceType.ALBUM && playerSnapshot.trackListSource?.id === album?.id, - [playerSnapshot.trackListSource, album?.id] + [ + playerSnapshot.mode, + playerSnapshot.trackListSource?.type, + playerSnapshot.trackListSource?.id, + album?.id, + ] ) const isPlaying = diff --git a/src/renderer/pages/Playlist.tsx b/src/renderer/pages/Playlist.tsx index ab76a4a..639d4ae 100644 --- a/src/renderer/pages/Playlist.tsx +++ b/src/renderer/pages/Playlist.tsx @@ -32,10 +32,15 @@ const PlayButton = ({ const playerSnapshot = useSnapshot(player) const isThisPlaylistPlaying = useMemo( () => - playerSnapshot.mode === PlayerMode.PLAYLIST && + playerSnapshot.mode === PlayerMode.TrackList && playerSnapshot.trackListSource?.type === TrackListSourceType.PLAYLIST && playerSnapshot.trackListSource?.id === playlist?.id, - [playerSnapshot.trackListSource, playlist?.id] + [ + playerSnapshot.mode, + playerSnapshot.trackListSource?.id, + playerSnapshot.trackListSource?.type, + playlist?.id, + ] ) const wrappedHandlePlay = () => { diff --git a/src/renderer/utils/player.ts b/src/renderer/utils/player.ts index 135c5f5..58c9995 100644 --- a/src/renderer/utils/player.ts +++ b/src/renderer/utils/player.ts @@ -22,7 +22,7 @@ interface TrackListSource { id: number } export enum Mode { - PLAYLIST = 'playlist', + TrackList = 'trackList', FM = 'fm', } export enum State { @@ -49,7 +49,7 @@ export class Player { private _volume: number = 1 // 0 to 1 state: State = State.INITIALIZING - mode: Mode = Mode.PLAYLIST + mode: Mode = Mode.TrackList trackList: TrackID[] = [] trackListSource: TrackListSource | null = null fmTrackList: TrackID[] = [] @@ -115,7 +115,7 @@ export class Player { * Get current playing track ID */ get trackID(): TrackID { - if (this.mode === Mode.PLAYLIST) { + if (this.mode === Mode.TrackList) { const { trackList, _trackIndex } = this return trackList[_trackIndex] ?? 0 } @@ -199,7 +199,7 @@ export class Player { toast('加载歌曲信息失败') return } - if (this.mode === Mode.PLAYLIST) this._track = track + if (this.mode === Mode.TrackList) this._track = track if (this.mode === Mode.FM) this.fmTrack = track this._playAudio() } @@ -370,7 +370,7 @@ export class Player { * @param {null|number} autoPlayTrackID */ playAList(list: TrackID[], autoPlayTrackID?: null | number) { - this.mode = Mode.PLAYLIST + this.mode = Mode.TrackList this.trackList = list this._trackIndex = autoPlayTrackID ? list.findIndex(t => t === autoPlayTrackID)