新增添加歌曲到“我的列表”时,若按住`ctrl`键,则不会自动关闭添加窗口

pull/930/merge
lyswhut 2022-06-04 12:48:26 +08:00
parent 85e4c7555a
commit fcfba8b12c
5 changed files with 55 additions and 1 deletions

View File

@ -2,6 +2,10 @@
- 新增设置-以全屏模式启动设置
### 优化
- 添加歌曲到“我的列表”时,若按住`ctrl`键Mac对应`Command`),则不会自动关闭添加窗口,这对想要将同一首(一批)歌曲添加到多个列表时会很有用
### 修复
- 修复若配置了`http_proxy`环境变量时,会意外使用此代理配置的问题

View File

@ -21,6 +21,7 @@ import { mapMutations } from 'vuex'
import { computed } from '@renderer/utils/vueTools'
import { defaultList, loveList, userLists } from '@renderer/core/share/list'
import { getList } from '@renderer/core/share/utils'
import useKeyDown from '@renderer/utils/compositions/useKeyDown'
export default {
props: {
@ -57,6 +58,8 @@ export default {
},
emits: ['update:show'],
setup(props) {
const keyModDown = useKeyDown('mod')
const lists = computed(() => {
if (!props.musicInfo) return []
const targetMid = props.musicInfo.songmid
@ -67,6 +70,7 @@ export default {
].filter(l => !props.excludeListId.includes(l.id)).map(l => ({ ...l, isExist: getList(l.id).some(s => s.songmid == targetMid) }))
})
return {
keyModDown,
lists,
}
},
@ -103,6 +107,8 @@ export default {
this.isMove
? this.listMove({ fromId: this.fromListId, toId: this.lists[index].id, musicInfo: this.musicInfo })
: this.listAdd({ id: this.lists[index].id, musicInfo: this.musicInfo })
if (this.keyModDown && !this.isMove) return
this.$nextTick(() => {
this.handleClose()
})

View File

@ -20,6 +20,7 @@
import { mapMutations } from 'vuex'
import { computed } from '@renderer/utils/vueTools'
import { defaultList, loveList, userLists } from '@renderer/core/share/list'
import useKeyDown from '@renderer/utils/compositions/useKeyDown'
export default {
props: {
@ -59,6 +60,8 @@ export default {
},
emits: ['update:show', 'confirm'],
setup(props) {
const keyModDown = useKeyDown('mod')
const lists = computed(() => {
return [
defaultList,
@ -67,6 +70,7 @@ export default {
].filter(l => !props.excludeListId.includes(l.id))
})
return {
keyModDown,
lists,
}
},
@ -104,6 +108,8 @@ export default {
this.isMove
? this.listMoveMultiple({ fromId: this.fromListId, toId: this.lists[index].id, list: this.musicList })
: this.listAddMultiple({ id: this.lists[index].id, list: this.musicList })
if (this.keyModDown && !this.isMove) return
this.$nextTick(() => {
this.handleClose()
this.$emit('confirm')

View File

@ -0,0 +1,38 @@
import { onMounted, onBeforeUnmount, ref } from '@renderer/utils/vueTools'
export default name => {
const keyDown = ref(false)
const down = `key_${name}_down`
const up = `key_${name}_up`
const handle_key_down = event => {
if (!keyDown.value) {
// console.log(event)
switch (event.event.target.tagName) {
case 'INPUT':
case 'SELECT':
case 'TEXTAREA':
return
default: if (event.event.target.isContentEditable) return
}
keyDown.value = true
}
}
const handle_key_up = () => {
if (keyDown.value) keyDown.value = false
}
onMounted(() => {
window.eventHub.on(down, handle_key_down)
window.eventHub.on(up, handle_key_up)
})
onBeforeUnmount(() => {
window.eventHub.off(down, handle_key_down)
window.eventHub.off(up, handle_key_up)
})
return keyDown
}

View File

@ -90,7 +90,7 @@ export default {
listItemHeight,
handleSelectData,
removeAllSelect,
} = useList({ list, setting, emit })
} = useList({ list, setting })
const {
handlePlayMusic,