50 lines
1.1 KiB
JavaScript
50 lines
1.1 KiB
JavaScript
import { ref, watch, computed } 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'
|
|
|
|
|
|
export default ({ props, onLoadedList }) => {
|
|
const rightClickSelectedIndex = ref(-1)
|
|
const selectedIndex = ref(-1)
|
|
const dom_listContent = ref(null)
|
|
const listRef = ref(null)
|
|
|
|
const excludeListIds = computed(() => ([props.listId]))
|
|
|
|
|
|
const list = ref([])
|
|
watch(() => props.listId, id => {
|
|
getListMusics(id).then(l => {
|
|
list.value = l
|
|
if (id != props.listId) return
|
|
onLoadedList()
|
|
})
|
|
}, {
|
|
immediate: true,
|
|
})
|
|
|
|
const playerInfo = computed(() => ({
|
|
isPlayList: playMusicInfo.listId == props.listId,
|
|
playIndex: playInfo.playIndex,
|
|
}))
|
|
|
|
const setSelectedIndex = index => {
|
|
selectedIndex.value = index
|
|
}
|
|
|
|
const isShowSource = computed(() => appSetting['list.isShowSource'])
|
|
|
|
return {
|
|
rightClickSelectedIndex,
|
|
selectedIndex,
|
|
dom_listContent,
|
|
listRef,
|
|
list,
|
|
playerInfo,
|
|
setSelectedIndex,
|
|
isShowSource,
|
|
excludeListIds,
|
|
}
|
|
}
|