From 96c3034a07cc7f5320be178006effe8fe47aa8b5 Mon Sep 17 00:00:00 2001 From: lyswhut Date: Sat, 11 Dec 2021 16:24:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=B0=83=E6=95=B4=E5=BD=93?= =?UTF-8?q?=E5=89=8D=E6=92=AD=E6=94=BE=E6=AD=8C=E6=9B=B2=E7=9A=84=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE=E6=97=B6=E4=BC=9A=E5=AF=BC=E8=87=B4=E5=88=87=E6=AD=8C?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/useApp/usePlayer/useWatchList.js | 17 +++++++++++++++-- src/renderer/utils/index.js | 4 ++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/renderer/core/useApp/usePlayer/useWatchList.js b/src/renderer/core/useApp/usePlayer/useWatchList.js index 28491a24..84ba6708 100644 --- a/src/renderer/core/useApp/usePlayer/useWatchList.js +++ b/src/renderer/core/useApp/usePlayer/useWatchList.js @@ -3,10 +3,16 @@ import { onBeforeUnmount } from '@renderer/utils/vueTools' import { player as eventPlayerNames, list as eventListNames } from '@renderer/event/names' import { playInfo, playMusicInfo, updatePlayIndex } from '@renderer/core/share/player' import { getList } from '@renderer/core/share/utils' +import { throttle } from '@renderer/utils' + +const changedListIds = new Set() export default ({ playNext }) => { - const handleListChange = listIds => { - if (!listIds.includes(playInfo.playListId) && !listIds.includes(playMusicInfo.listId)) return + const throttleListChange = throttle(() => { + const isSkip = !changedListIds.has(playInfo.playListId) && !changedListIds.has(playMusicInfo.listId) + changedListIds.clear() + if (isSkip) return + const { playIndex } = updatePlayIndex() if (playIndex < 0 && !playMusicInfo.isTempPlay) { // 歌曲被移除 if (getList(playMusicInfo.listId).length) { @@ -15,6 +21,13 @@ export default ({ playNext }) => { window.eventHub.emit(eventPlayerNames.setStop) } } + }) + + const handleListChange = listIds => { + for (const id of listIds) { + changedListIds.add(id) + } + throttleListChange() } window.eventHub.on(eventListNames.listChange, handleListChange) diff --git a/src/renderer/utils/index.js b/src/renderer/utils/index.js index 57d6ec77..183292df 100644 --- a/src/renderer/utils/index.js +++ b/src/renderer/utils/index.js @@ -402,8 +402,8 @@ export const getPlayList = () => rendererInvoke(NAMES.mainWindow.get_playlist).c let filePath = path.join(dataPath, 'playList.json.bak') rendererInvoke(NAMES.mainWindow.show_dialog, { type: 'error', - message: window.i18n.t('store.state.load_list_file_error_title'), - detail: window.i18n.t('store.state.load_list_file_error_detail', { + message: window.i18n.t('load_list_file_error_title'), + detail: window.i18n.t('load_list_file_error_detail', { path: filePath, detail: error.message, }),