Files
Melo/src/renderer/views/Download/usePlay.js
T
2022-10-29 11:36:35 +08:00

24 lines
743 B
JavaScript

import { addTempPlayList } from '@renderer/store/player/action'
import { playList } from '@renderer/core/player'
import { LIST_IDS } from '@common/constants'
export default ({ selectedList, list, listAll, removeAllSelect }) => {
const handlePlayMusic = (index) => {
playList(LIST_IDS.DOWNLOAD, listAll.value.indexOf(list.value[index]))
}
const handlePlayMusicLater = (index, single) => {
if (selectedList.value.length && !single) {
addTempPlayList(selectedList.value.map(s => ({ listId: LIST_IDS.DOWNLOAD, musicInfo: s })))
removeAllSelect()
} else {
addTempPlayList([{ listId: LIST_IDS.DOWNLOAD, musicInfo: list.value[index] }])
}
}
return {
handlePlayMusic,
handlePlayMusicLater,
}
}