修改列表响应式更新机制,尝试修复偶现的删除歌曲列表未更新的问题

This commit is contained in:
lyswhut
2023-02-03 19:41:22 +08:00
parent c6f9e421c1
commit 4635481c77
3 changed files with 18 additions and 4 deletions
+1 -1
View File
@@ -25,7 +25,7 @@ export default (activeTab) => {
case 'finished':
return listAll.value.filter(i => i.status == downloadStatus.COMPLETED)
default:
return listAll.value
return [...listAll.value]
}
})
@@ -1,4 +1,4 @@
import { ref, watch, computed } from '@common/utils/vueTools'
import { ref, watch, computed, onBeforeUnmount } from '@common/utils/vueTools'
import { playMusicInfo, playInfo } from '@renderer/store/player/state'
import { getListMusics } from '@renderer/store/list/action'
import { appSetting } from '@renderer/store/setting'
@@ -16,7 +16,7 @@ export default ({ props, onLoadedList }) => {
const list = ref([])
watch(() => props.listId, id => {
getListMusics(id).then(l => {
list.value = l
list.value = [...l]
if (id != props.listId) return
onLoadedList()
})
@@ -35,6 +35,19 @@ export default ({ props, onLoadedList }) => {
const isShowSource = computed(() => appSetting['list.isShowSource'])
const handleMyListUpdate = (ids) => {
if (!ids.includes(props.listId)) return
getListMusics(props.listId).then(l => {
list.value = [...l]
})
}
window.app_event.on('myListUpdate', handleMyListUpdate)
onBeforeUnmount(() => {
window.app_event.off('myListUpdate', handleMyListUpdate)
})
return {
rightClickSelectedIndex,
selectedIndex,