升级到 vue3

This commit is contained in:
lyswhut
2021-12-03 22:11:11 +08:00
parent c6635e554a
commit 8059d9cd73
260 changed files with 14443 additions and 10979 deletions
@@ -0,0 +1,60 @@
import { useCommit } from '@renderer/utils/vueTools'
import { defaultList } from '@renderer/core/share/list'
import { getList } from '@renderer/core/share/utils'
export default ({ selectedList, props, removeAllSelect }) => {
let clickTime = 0
let clickIndex = -1
const listAddMultiple = useCommit('list', 'listAddMultiple')
const listAdd = useCommit('list', 'listAdd')
const setList = useCommit('player', 'setList')
const setTempPlayList = useCommit('player', 'setTempPlayList')
const handlePlayMusic = (index, single) => {
let targetSong = props.list[index]
const defaultListMusics = getList(defaultList.id)
if (selectedList.value.length && !single) {
listAddMultiple({ id: defaultList.id, list: [...selectedList.value] })
removeAllSelect()
} else {
listAdd({ id: defaultList.id, musicInfo: targetSong })
}
let targetIndex = defaultListMusics.findIndex(s => s.songmid === targetSong.songmid)
if (targetIndex > -1) {
setList({
listId: defaultList.id,
index: targetIndex,
})
}
}
const handlePlayMusicLater = (index, single) => {
if (selectedList.length && !single) {
setTempPlayList(selectedList.value.map(s => ({ listId: '__temp__', musicInfo: s })))
removeAllSelect()
} else {
setTempPlayList([{ listId: '__temp__', musicInfo: props.list[index] }])
}
}
const doubleClickPlay = index => {
if (
window.performance.now() - clickTime > 400 ||
clickIndex !== index
) {
clickTime = window.performance.now()
clickIndex = index
return
}
handlePlayMusic(index, true)
clickTime = 0
clickIndex = -1
}
return {
handlePlayMusic,
handlePlayMusicLater,
doubleClickPlay,
}
}