pull/1211/head
lyswhut 2023-02-03 19:41:34 +08:00
parent 4635481c77
commit a8827c361c
5 changed files with 13 additions and 31 deletions

View File

@ -104,12 +104,8 @@ export const downloadInfoUpdate = (lists: LX.Download.ListItem[]) => {
export const downloadInfoRemove = (ids: string[]) => {
deleteDownloadList(ids)
if (list) {
const listSet = new Set<string>()
for (const item of list) listSet.add(item.id)
for (const id of ids) listSet.delete(id)
const newList = list.filter(task => listSet.has(task.id))
list.splice(0, list.length)
for (const item of newList) list.push(item)
const idSet = new Set<string>(ids)
list = list.filter(task => !idSet.has(task.id))
}
}

View File

@ -226,12 +226,8 @@ export const musicsRemove = (listId: string, ids: string[]) => {
let targetList = getListMusics(listId)
if (!targetList.length) return
removeMusicInfos(listId, ids)
const listSet = new Set<string>()
for (const item of targetList) listSet.add(item.id)
for (const id of ids) listSet.delete(id)
const newList = targetList.filter(mInfo => listSet.has(mInfo.id))
targetList.splice(0, targetList.length)
arrPush(targetList, newList)
const idsSet = new Set<string>(ids)
musicLists.set(listId, targetList.filter(mInfo => !idsSet.has(mInfo.id)))
}
/**
@ -267,12 +263,8 @@ export const musicsMove = (fromId: string, toId: string, musicInfos: LX.Music.Mu
break
}
listSet = new Set<string>()
for (const item of fromList) listSet.add(item.id)
for (const id of ids) listSet.delete(id)
const newList = fromList.filter(mInfo => listSet.has(mInfo.id))
fromList.splice(0, fromList.length)
arrPush(fromList, newList)
listSet = new Set<string>(ids)
musicLists.set(fromId, fromList.filter(mInfo => !listSet.has(mInfo.id)))
}
/**

View File

@ -279,8 +279,6 @@ export default {
})
watch(() => props.list, (list) => {
handleReset(list)
}, {
deep: true,
})
onMounted(() => {

View File

@ -368,15 +368,13 @@ export const pauseDownloadTasks = async(list: LX.Download.ListItem[]) => {
export const removeDownloadTasks = async(ids: string[]) => {
await downloadTasksRemove(ids)
const listSet = new Set<string>()
for (const item of downloadList) listSet.add(item.id)
for (const id of ids) listSet.delete(id)
const idsSet = new Set<string>(ids)
const newList = downloadList.filter(task => {
if (runingTask.has(task.id)) {
void window.lx.worker.download.removeTask(task.id)
runingTask.delete(task.id)
}
return listSet.has(task.id)
return !idsSet.has(task.id)
})
downloadList.splice(0, downloadList.length)
arrPush(downloadList, newList)

View File

@ -1,4 +1,4 @@
import { shallowReactive, markRaw, markRawList, toRaw } from '@common/utils/vueTools'
import { markRaw, markRawList, toRaw } from '@common/utils/vueTools'
import {
allMusicList,
defaultList,
@ -16,7 +16,7 @@ export const setUserLists = (lists: LX.List.UserListInfo[]) => {
}
export const setMusicList = (listId: string, musicList: LX.Music.MusicInfo[]) => {
const list = shallowReactive(markRawList(musicList))
const list = markRawList(musicList)
allMusicList.set(listId, list)
return list
}
@ -29,7 +29,7 @@ const overwriteMusicList = (id: string, list: LX.Music.MusicInfo[]) => {
targetList.splice(0, targetList.length)
arrPush(targetList, list)
} else {
allMusicList.set(id, shallowReactive(list))
allMusicList.set(id, list)
}
}
const removeMusicList = (id: string) => {
@ -258,10 +258,8 @@ export const listMusicRemove = (listId: string, ids: string[]): string[] => {
let targetList = allMusicList.get(listId)
if (!targetList) return listId == loveList.id ? [listId] : []
const listSet = new Set<string>()
for (const item of targetList) listSet.add(item.id)
for (const id of ids) listSet.delete(id)
const newList = targetList.filter(mInfo => listSet.has(mInfo.id))
const idsSet = new Set<string>(ids)
const newList = targetList.filter(mInfo => !idsSet.has(mInfo.id))
targetList.splice(0, targetList.length)
arrPush(targetList, newList)