修复去重列表移除歌曲后列表没有刷新的问题
parent
e81d594d01
commit
c0515c9c4f
|
@ -36,7 +36,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { shallowReactive, watch, toRaw, computed } from '@common/utils/vueTools'
|
import { ref, watch, computed, markRawList } from '@common/utils/vueTools'
|
||||||
import { playList } from '@renderer/core/player'
|
import { playList } from '@renderer/core/player'
|
||||||
import { getListMusics, removeListMusics } from '@renderer/store/list/action'
|
import { getListMusics, removeListMusics } from '@renderer/store/list/action'
|
||||||
import { isFullscreen } from '@renderer/store'
|
import { isFullscreen } from '@renderer/store'
|
||||||
|
@ -56,33 +56,31 @@ export default {
|
||||||
},
|
},
|
||||||
emits: ['update:visible'],
|
emits: ['update:visible'],
|
||||||
setup(props) {
|
setup(props) {
|
||||||
const duplicateList = shallowReactive([])
|
const duplicateList = ref([])
|
||||||
const listItemHeight = computed(() => {
|
const listItemHeight = computed(() => {
|
||||||
return Math.ceil((isFullscreen.value ? getFontSizeWithScreen() : appSetting['common.fontSize']) * 3.2)
|
return Math.ceil((isFullscreen.value ? getFontSizeWithScreen() : appSetting['common.fontSize']) * 3.2)
|
||||||
})
|
})
|
||||||
|
|
||||||
const handlePlay = (index) => {
|
const handlePlay = (index) => {
|
||||||
const { index: musicInfoIndex } = duplicateList[index]
|
const { index: musicInfoIndex } = duplicateList.value[index]
|
||||||
playList(props.listInfo.id, musicInfoIndex)
|
playList(props.listInfo.id, musicInfoIndex)
|
||||||
}
|
}
|
||||||
const handleFilterList = async() => {
|
const handleFilterList = async() => {
|
||||||
// console.time('filter')
|
// console.time('filter')
|
||||||
duplicateList.splice(
|
duplicateList.value = markRawList(await window.lx.worker.main.filterDuplicateMusic(await getListMusics(props.listInfo.id)))
|
||||||
0,
|
// console.log(duplicateList.value)
|
||||||
duplicateList.length,
|
|
||||||
...(await window.lx.worker.main.filterDuplicateMusic(toRaw(await getListMusics(props.listInfo.id)))))
|
|
||||||
|
|
||||||
// console.timeEnd('filter')
|
// console.timeEnd('filter')
|
||||||
}
|
}
|
||||||
const handleRemove = async(index) => {
|
const handleRemove = async(index) => {
|
||||||
const { musicInfo: targetMusicInfo } = duplicateList.splice(index, 1)[0]
|
const { musicInfo: targetMusicInfo } = duplicateList.value.splice(index, 1)[0]
|
||||||
|
duplicateList.value = [...duplicateList.value]
|
||||||
await removeListMusics({ listId: props.listInfo.id, ids: [targetMusicInfo.id] })
|
await removeListMusics({ listId: props.listInfo.id, ids: [targetMusicInfo.id] })
|
||||||
await handleFilterList()
|
await handleFilterList()
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(() => props.visible, (visible) => {
|
watch(() => props.visible, (visible) => {
|
||||||
if (visible) {
|
if (visible) {
|
||||||
if (duplicateList.length) duplicateList.splice(0, duplicateList.length)
|
if (duplicateList.value.length) duplicateList.value = []
|
||||||
handleFilterList()
|
handleFilterList()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue