优化大列表增删操作性能

This commit is contained in:
lyswhut
2022-11-09 17:08:12 +08:00
parent 4b22518532
commit 953fc94cb0
7 changed files with 123 additions and 86 deletions
+3 -2
View File
@@ -19,6 +19,7 @@ import { setProgress } from './playProgress'
import { playNext } from '@renderer/core/player'
import { LIST_IDS } from '@common/constants'
import { toRaw } from '@common/utils/vueTools'
import { arrPush, arrUnshift } from '@common/utils/common'
type PlayerMusicInfoKeys = keyof typeof musicInfo
@@ -231,8 +232,8 @@ export const addTempPlayList = (list: LX.Player.TempPlayListItem[]) => {
}
return true
})
if (topList.length) tempPlayList.unshift(...topList.map(({ musicInfo, listId }) => ({ musicInfo, listId, isTempPlay: true })))
if (bottomList.length) tempPlayList.push(...bottomList.map(({ musicInfo, listId }) => ({ musicInfo, listId, isTempPlay: true })))
if (topList.length) arrUnshift(tempPlayList, topList.map(({ musicInfo, listId }) => ({ musicInfo, listId, isTempPlay: true })))
if (bottomList.length) arrPush(tempPlayList, bottomList.map(({ musicInfo, listId }) => ({ musicInfo, listId, isTempPlay: true })))
if (!playMusicInfo.musicInfo) void playNext()
}