新增 我的列表-换源播放 功能

This commit is contained in:
lyswhut
2024-08-17 13:44:11 +08:00
parent bb5b667613
commit 584c12e60f
36 changed files with 559 additions and 93 deletions
@@ -0,0 +1,49 @@
// import { updateListMusicsPosition } from '@renderer/store/list/action'
import { ref, nextTick } from '@common/utils/vueTools'
import { updateListMusics } from '@renderer/store/list/listManage'
import { playList } from '@renderer/core/player'
import { getListMusicsFromCache } from '@renderer/store/list/action'
export default (props, list) => {
const isShowMusicToggleModal = ref(false)
const musicInfo = ref(null)
const handleShowMusicToggleModal = (index) => {
musicInfo.value = list.value[index]
nextTick(() => {
isShowMusicToggleModal.value = true
})
}
const toggleSource = (toggleMusicInfo) => {
const id = musicInfo.value.id
const index = list.value.findIndex(m => m.id == id)
if (index < 0) {
isShowMusicToggleModal.value = false
return
}
musicInfo.value.meta.toggleMusicInfo = toggleMusicInfo
updateListMusics([
{
id: props.listId,
musicInfo: {
...musicInfo.value,
meta: {
...musicInfo.value.meta,
toggleMusicInfo,
},
},
},
])
const rawInfo = getListMusicsFromCache(props.listId)[index]
rawInfo.meta.toggleMusicInfo = toggleMusicInfo
playList(props.listId, index)
}
return {
isShowMusicToggleModal,
selectedToggleMusicInfo: musicInfo,
handleShowMusicToggleModal,
toggleSource,
}
}