Skip to content

Commit c0515c9

Browse files
committed
修复去重列表移除歌曲后列表没有刷新的问题
1 parent e81d594 commit c0515c9

1 file changed

Lines changed: 8 additions & 10 deletions

File tree

src/renderer/views/List/MyList/components/DuplicateMusicModal.vue

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
</template>
3737

3838
<script>
39-
import { shallowReactive, watch, toRaw, computed } from '@common/utils/vueTools'
39+
import { ref, watch, computed, markRawList } from '@common/utils/vueTools'
4040
import { playList } from '@renderer/core/player'
4141
import { getListMusics, removeListMusics } from '@renderer/store/list/action'
4242
import { isFullscreen } from '@renderer/store'
@@ -56,33 +56,31 @@ export default {
5656
},
5757
emits: ['update:visible'],
5858
setup(props) {
59-
const duplicateList = shallowReactive([])
59+
const duplicateList = ref([])
6060
const listItemHeight = computed(() => {
6161
return Math.ceil((isFullscreen.value ? getFontSizeWithScreen() : appSetting['common.fontSize']) * 3.2)
6262
})
6363
6464
const handlePlay = (index) => {
65-
const { index: musicInfoIndex } = duplicateList[index]
65+
const { index: musicInfoIndex } = duplicateList.value[index]
6666
playList(props.listInfo.id, musicInfoIndex)
6767
}
6868
const handleFilterList = async() => {
6969
// console.time('filter')
70-
duplicateList.splice(
71-
0,
72-
duplicateList.length,
73-
...(await window.lx.worker.main.filterDuplicateMusic(toRaw(await getListMusics(props.listInfo.id)))))
74-
70+
duplicateList.value = markRawList(await window.lx.worker.main.filterDuplicateMusic(await getListMusics(props.listInfo.id)))
71+
// console.log(duplicateList.value)
7572
// console.timeEnd('filter')
7673
}
7774
const handleRemove = async(index) => {
78-
const { musicInfo: targetMusicInfo } = duplicateList.splice(index, 1)[0]
75+
const { musicInfo: targetMusicInfo } = duplicateList.value.splice(index, 1)[0]
76+
duplicateList.value = [...duplicateList.value]
7977
await removeListMusics({ listId: props.listInfo.id, ids: [targetMusicInfo.id] })
8078
await handleFilterList()
8179
}
8280
8381
watch(() => props.visible, (visible) => {
8482
if (visible) {
85-
if (duplicateList.length) duplicateList.splice(0, duplicateList.length)
83+
if (duplicateList.value.length) duplicateList.value = []
8684
handleFilterList()
8785
}
8886
})

0 commit comments

Comments
 (0)