修改列表响应式更新机制,尝试修复偶现的删除歌曲列表未更新的问题
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user