diff --git a/src/common/constants.ts b/src/common/constants.ts index df76ee2b..f4cb61a7 100644 --- a/src/common/constants.ts +++ b/src/common/constants.ts @@ -23,6 +23,7 @@ export const LIST_IDS = { LOVE: 'love', TEMP: 'temp', DOWNLOAD: 'download', + PLAY_LATER: null, } as const export const DATA_KEYS = { diff --git a/src/renderer/components/layout/PlayBar/FullWidthProgress.vue b/src/renderer/components/layout/PlayBar/FullWidthProgress.vue index 190648a5..81da80ce 100644 --- a/src/renderer/components/layout/PlayBar/FullWidthProgress.vue +++ b/src/renderer/components/layout/PlayBar/FullWidthProgress.vue @@ -65,6 +65,7 @@ import { } from '@renderer/store/player/action' import { appSetting } from '@renderer/store/setting' import { togglePlay, playNext, playPrev } from '@renderer/core/player' +import { LIST_IDS } from '@common/constants' export default { name: 'CorePlayBar', @@ -98,7 +99,7 @@ export default { const handleToMusicLocation = () => { const listId = playMusicInfo.listId - if (!listId || listId == '__temp__' || listId == 'download' || !playMusicInfo.musicInfo) return + if (!listId || listId == LIST_IDS.DOWNLOAD || !playMusicInfo.musicInfo) return if (playInfo.playIndex == -1) return router.push({ path: '/list', diff --git a/src/renderer/components/layout/PlayBar/MiddleWidthProgress.vue b/src/renderer/components/layout/PlayBar/MiddleWidthProgress.vue index 1a2cf037..022954d0 100644 --- a/src/renderer/components/layout/PlayBar/MiddleWidthProgress.vue +++ b/src/renderer/components/layout/PlayBar/MiddleWidthProgress.vue @@ -65,6 +65,7 @@ import { } from '@renderer/store/player/action' import { appSetting } from '@renderer/store/setting' import { togglePlay, playNext, playPrev } from '@renderer/core/player' +import { LIST_IDS } from '@common/constants' export default { name: 'CorePlayBar', @@ -98,7 +99,7 @@ export default { const handleToMusicLocation = () => { const listId = playMusicInfo.listId - if (!listId || listId == '__temp__' || listId == 'download' || !playMusicInfo.musicInfo) return + if (!listId || listId == LIST_IDS.DOWNLOAD || !playMusicInfo.musicInfo) return if (playInfo.playIndex == -1) return router.push({ path: '/list', diff --git a/src/renderer/components/layout/PlayBar/MiniWidthProgress.vue b/src/renderer/components/layout/PlayBar/MiniWidthProgress.vue index 2e1854fc..ff7e077f 100644 --- a/src/renderer/components/layout/PlayBar/MiniWidthProgress.vue +++ b/src/renderer/components/layout/PlayBar/MiniWidthProgress.vue @@ -67,6 +67,7 @@ import { } from '@renderer/store/player/action' import { appSetting } from '@renderer/store/setting' import { togglePlay, playNext, playPrev } from '@renderer/core/player' +import { LIST_IDS } from '@common/constants' export default { name: 'CorePlayBar', @@ -100,7 +101,7 @@ export default { const handleToMusicLocation = () => { const listId = playMusicInfo.listId - if (!listId || listId == '__temp__' || listId == 'download' || !playMusicInfo.musicInfo) return + if (!listId || listId == LIST_IDS.DOWNLOAD || !playMusicInfo.musicInfo) return if (playInfo.playIndex == -1) return router.push({ path: '/list', diff --git a/src/renderer/components/material/OnlineList/usePlay.ts b/src/renderer/components/material/OnlineList/usePlay.ts index eb9f3bfe..7cd4aada 100644 --- a/src/renderer/components/material/OnlineList/usePlay.ts +++ b/src/renderer/components/material/OnlineList/usePlay.ts @@ -5,6 +5,7 @@ import { addTempPlayList } from '@renderer/store/player/action' import { appSetting } from '@renderer/store/setting' import { Ref } from '@common/utils/vueTools' import { playList } from '@renderer/core/player' +import { LIST_IDS } from '@common/constants' export default ({ selectedList, props, removeAllSelect, emit }: { selectedList: Ref @@ -34,10 +35,10 @@ export default ({ selectedList, props, removeAllSelect, emit }: { const handlePlayMusicLater = (index: number, single: boolean) => { if (selectedList.value.length && !single) { - addTempPlayList(selectedList.value.map(s => ({ listId: '__temp__', musicInfo: s }))) + addTempPlayList(selectedList.value.map(s => ({ listId: LIST_IDS.PLAY_LATER, musicInfo: s }))) removeAllSelect() } else { - addTempPlayList([{ listId: '__temp__', musicInfo: props.list[index] }]) + addTempPlayList([{ listId: LIST_IDS.PLAY_LATER, musicInfo: props.list[index] }]) } } diff --git a/src/renderer/core/player/action.ts b/src/renderer/core/player/action.ts index ccf1d37a..7fef31b8 100644 --- a/src/renderer/core/player/action.ts +++ b/src/renderer/core/player/action.ts @@ -111,7 +111,7 @@ const handleRestorePlay = async(restorePlayInfo: LX.Player.SavedPlayInfo) => { }) - void getPicPath({ musicInfo, listId: playMusicInfo.isTempPlay ? null : playMusicInfo.listId }).then((url: string) => { + void getPicPath({ musicInfo, listId: playMusicInfo.listId }).then((url: string) => { if (musicInfo.id != playMusicInfo.musicInfo?.id) return setMusicInfo({ pic: url }) window.app_event.picUpdated() @@ -158,11 +158,11 @@ const handlePlay = () => { if (!musicInfo) return - if (appSetting['player.togglePlayMethod'] == 'random' && !playMusicInfo.isTempPlay) addPlayedList({ ...(playMusicInfo as LX.Player.PlayMusicInfo) }) + if (appSetting['player.togglePlayMethod'] == 'random' && playMusicInfo.listId) addPlayedList({ ...(playMusicInfo as LX.Player.PlayMusicInfo) }) setMusicUrl(musicInfo) - void getPicPath({ musicInfo, listId: playMusicInfo.isTempPlay ? null : playMusicInfo.listId }).then((url: string) => { + void getPicPath({ musicInfo, listId: playMusicInfo.listId }).then((url: string) => { if (musicInfo.id != playMusicInfo.musicInfo?.id) return setMusicInfo({ pic: url }) window.app_event.picUpdated() diff --git a/src/renderer/core/useApp/useDeeplink/useMusicAction.js b/src/renderer/core/useApp/useDeeplink/useMusicAction.js index b6c8fde6..03daf7a1 100644 --- a/src/renderer/core/useApp/useDeeplink/useMusicAction.js +++ b/src/renderer/core/useApp/useDeeplink/useMusicAction.js @@ -9,6 +9,7 @@ import { dataVerify, qualityFilter, sources } from './utils' import { focusWindow } from '@renderer/utils/ipc' import { playNext } from '@renderer/core/player/action' import { toNewMusicInfo } from '@common/utils/tools' +import { LIST_IDS } from '@common/constants' const useSearchMusic = () => { const router = useRouter() @@ -153,7 +154,7 @@ const usePlayMusic = () => { musicInfo = toNewMusicInfo(musicInfo) markRaw(musicInfo) const isPlaying = !!playMusicInfo.musicInfo - addTempPlayList([{ listId: '__temp__', musicInfo, isTop: true }]) + addTempPlayList([{ listId: LIST_IDS.PLAY_LATER, musicInfo, isTop: true }]) if (isPlaying) playNext() } } diff --git a/src/renderer/core/useApp/usePlayer/usePlayProgress.ts b/src/renderer/core/useApp/usePlayer/usePlayProgress.ts index c03d8e83..fe697488 100644 --- a/src/renderer/core/useApp/usePlayer/usePlayProgress.ts +++ b/src/renderer/core/useApp/usePlayer/usePlayProgress.ts @@ -107,7 +107,7 @@ export default () => { setMaxplayTime(getDuration()) if (playMusicInfo.musicInfo && 'source' in playMusicInfo.musicInfo && !playMusicInfo.musicInfo.interval) { - console.log(formatPlayTime2(playProgress.maxPlayTime)) + // console.log(formatPlayTime2(playProgress.maxPlayTime)) if (playMusicInfo.listId) { void updateListMusics([{ diff --git a/src/renderer/core/useApp/usePlayer/useWatchList.ts b/src/renderer/core/useApp/usePlayer/useWatchList.ts index b1dd41c4..d6dc6160 100644 --- a/src/renderer/core/useApp/usePlayer/useWatchList.ts +++ b/src/renderer/core/useApp/usePlayer/useWatchList.ts @@ -9,7 +9,7 @@ const changedListIds = new Set() export default () => { const throttleListChange = throttle(() => { - const isSkip = !changedListIds.has(playInfo.playerListId) && !changedListIds.has(playMusicInfo.listId) + const isSkip = playMusicInfo.listId && !changedListIds.has(playInfo.playerListId) && !changedListIds.has(playMusicInfo.listId) changedListIds.clear() if (isSkip) return diff --git a/src/renderer/store/player/action.ts b/src/renderer/store/player/action.ts index a8c5ead4..ef687092 100644 --- a/src/renderer/store/player/action.ts +++ b/src/renderer/store/player/action.ts @@ -224,7 +224,7 @@ export const clearPlayedList = () => { * @param list 歌曲列表 */ export const addTempPlayList = (list: LX.Player.TempPlayListItem[]) => { - const topList: Array<{ listId: string, musicInfo: LX.Music.MusicInfo | LX.Download.ListItem }> = [] + const topList: Array> = [] const bottomList = list.filter(({ isTop, ...musicInfo }) => { if (isTop) { topList.push(musicInfo) diff --git a/src/renderer/types/player.d.ts b/src/renderer/types/player.d.ts index 5856b294..f627e71f 100644 --- a/src/renderer/types/player.d.ts +++ b/src/renderer/types/player.d.ts @@ -9,7 +9,7 @@ declare namespace LX { /** * 当前播放歌曲的列表 id */ - listId: string + listId: string | null /** * 是否属于 “稍后播放” */ @@ -35,7 +35,7 @@ declare namespace LX { /** * 播放列表id */ - listId: string + listId: string | null /** * 歌曲信息 */