修复mac下只能全选一次的问题

pull/225/head
lyswhut 2020-05-01 20:02:18 +08:00
parent afc81b6308
commit 3be3b0ca36
5 changed files with 134 additions and 82 deletions

View File

@ -122,6 +122,7 @@ export default {
isShiftDown: false,
isModDown: false,
isADown: false,
aDownTimeout: null,
},
}
},
@ -133,41 +134,53 @@ export default {
},
methods: {
listenEvent() {
window.eventHub.$on('shift_down', this.handle_shift_down)
window.eventHub.$on('shift_up', this.handle_shift_up)
window.eventHub.$on('mod_down', this.handle_mod_down)
window.eventHub.$on('mod_up', this.handle_mod_up)
window.eventHub.$on('mod+a_down', this.handle_mod_a_down)
window.eventHub.$on('mod+a_up', this.handle_mod_a_up)
window.eventHub.$on('key_shift_down', this.handle_key_shift_down)
window.eventHub.$on('key_shift_up', this.handle_key_shift_up)
window.eventHub.$on('key_mod_down', this.handle_key_mod_down)
window.eventHub.$on('key_mod_up', this.handle_key_mod_up)
window.eventHub.$on('key_mod+a_down', this.handle_key_mod_a_down)
window.eventHub.$on('key_mod+a_up', this.handle_key_mod_a_up)
},
unlistenEvent() {
window.eventHub.$off('shift_down', this.handle_shift_down)
window.eventHub.$off('shift_up', this.handle_shift_up)
window.eventHub.$off('mod_down', this.handle_mod_down)
window.eventHub.$off('mod_up', this.handle_mod_up)
window.eventHub.$off('mod+a_down', this.handle_mod_a_down)
window.eventHub.$off('mod+a_up', this.handle_mod_a_up)
window.eventHub.$off('key_shift_down', this.handle_key_shift_down)
window.eventHub.$off('key_shift_up', this.handle_key_shift_up)
window.eventHub.$off('key_mod_down', this.handle_key_mod_down)
window.eventHub.$off('key_mod_up', this.handle_key_mod_up)
window.eventHub.$off('key_mod+a_down', this.handle_key_mod_a_down)
window.eventHub.$off('key_mod+a_up', this.handle_key_mod_a_up)
},
handle_shift_down() {
handle_key_shift_down() {
if (!this.keyEvent.isShiftDown) this.keyEvent.isShiftDown = true
},
handle_shift_up() {
handle_key_shift_up() {
if (this.keyEvent.isShiftDown) this.keyEvent.isShiftDown = false
},
handle_mod_down() {
handle_key_mod_down() {
if (!this.keyEvent.isModDown) this.keyEvent.isModDown = true
},
handle_mod_up() {
handle_key_mod_up() {
if (this.keyEvent.isModDown) this.keyEvent.isModDown = false
},
handle_mod_a_down() {
handle_key_mod_a_down() {
if (!this.keyEvent.isADown) {
this.keyEvent.isModDown = false
this.keyEvent.isADown = true
this.handleSelectAllData()
if (this.keyEvent.aDownTimeout) clearTimeout(this.keyEvent.aDownTimeout)
this.keyEvent.aDownTimeout = setTimeout(() => {
this.keyEvent.aDownTimeout = null
this.keyEvent.isADown = false
}, 500)
}
},
handle_mod_a_up() {
if (this.keyEvent.isADown) this.keyEvent.isADown = false
handle_key_mod_a_up() {
if (this.keyEvent.isADown) {
if (this.keyEvent.aDownTimeout) {
clearTimeout(this.keyEvent.aDownTimeout)
this.keyEvent.aDownTimeout = null
}
this.keyEvent.isADown = false
}
},
handleDoubleClick(event, index) {
if (event.target.classList.contains('select')) return

View File

@ -4,27 +4,27 @@ let eventHub
const bindKey = () => {
mousetrap.reset()
mousetrap.bind('shift', (event, combo) => {
eventHub.$emit('shift_down', { event, combo })
eventHub.$emit('key_shift_down', { event, combo })
return false
}, 'keydown')
mousetrap.bind('shift', (event, combo) => {
eventHub.$emit('shift_up', { event, combo })
eventHub.$emit('key_shift_up', { event, combo })
return false
}, 'keyup')
mousetrap.bind('mod', (event, combo) => {
eventHub.$emit('mod_down', { event, combo })
eventHub.$emit('key_mod_down', { event, combo })
return false
}, 'keydown')
mousetrap.bind('mod', (event, combo) => {
eventHub.$emit('mod_up', { event, combo })
eventHub.$emit('key_mod_up', { event, combo })
return false
}, 'keyup')
mousetrap.bind('mod+a', (event, combo) => {
eventHub.$emit('mod+a_down', { event, combo })
eventHub.$emit('key_mod+a_down', { event, combo })
return false
}, 'keydown')
mousetrap.bind('mod+a', (event, combo) => {
eventHub.$emit('mod+a_up', { event, combo })
eventHub.$emit('key_mod+a_up', { event, combo })
return false
}, 'keyup')
}

View File

@ -74,6 +74,7 @@ export default {
isShiftDown: false,
isModDown: false,
isADown: false,
aDownTimeout: null,
},
}
},
@ -129,41 +130,53 @@ export default {
...mapActions('download', ['removeTask', 'removeTasks', 'startTask', 'startTasks', 'pauseTask', 'pauseTasks']),
...mapMutations('player', ['setList']),
listenEvent() {
window.eventHub.$on('shift_down', this.handle_shift_down)
window.eventHub.$on('shift_up', this.handle_shift_up)
window.eventHub.$on('mod_down', this.handle_mod_down)
window.eventHub.$on('mod_up', this.handle_mod_up)
window.eventHub.$on('mod+a_down', this.handle_mod_a_down)
window.eventHub.$on('mod+a_up', this.handle_mod_a_up)
window.eventHub.$on('key_shift_down', this.handle_key_shift_down)
window.eventHub.$on('key_shift_up', this.handle_key_shift_up)
window.eventHub.$on('key_mod_down', this.handle_key_mod_down)
window.eventHub.$on('key_mod_up', this.handle_key_mod_up)
window.eventHub.$on('key_mod+a_down', this.handle_mod_a_down)
window.eventHub.$on('key_mod+a_up', this.handle_mod_a_up)
},
unlistenEvent() {
window.eventHub.$off('shift_down', this.handle_shift_down)
window.eventHub.$off('shift_up', this.handle_shift_up)
window.eventHub.$off('mod_down', this.handle_mod_down)
window.eventHub.$off('mod_up', this.handle_mod_up)
window.eventHub.$off('mod+a_down', this.handle_mod_a_down)
window.eventHub.$off('mod+a_up', this.handle_mod_a_up)
window.eventHub.$off('key_shift_down', this.handle_key_shift_down)
window.eventHub.$off('key_shift_up', this.handle_key_shift_up)
window.eventHub.$off('key_mod_down', this.handle_key_mod_down)
window.eventHub.$off('key_mod_up', this.handle_key_mod_up)
window.eventHub.$off('key_mod+a_down', this.handle_mod_a_down)
window.eventHub.$off('key_mod+a_up', this.handle_mod_a_up)
},
handle_shift_down() {
handle_key_shift_down() {
if (!this.keyEvent.isShiftDown) this.keyEvent.isShiftDown = true
},
handle_shift_up() {
handle_key_shift_up() {
if (this.keyEvent.isShiftDown) this.keyEvent.isShiftDown = false
},
handle_mod_down() {
handle_key_mod_down() {
if (!this.keyEvent.isModDown) this.keyEvent.isModDown = true
},
handle_mod_up() {
handle_key_mod_up() {
if (this.keyEvent.isModDown) this.keyEvent.isModDown = false
},
handle_mod_a_down() {
handle_key_mod_a_down() {
if (!this.keyEvent.isADown) {
this.keyEvent.isModDown = false
this.keyEvent.isADown = true
this.handleSelectAllData()
if (this.keyEvent.aDownTimeout) clearTimeout(this.keyEvent.aDownTimeout)
this.keyEvent.aDownTimeout = setTimeout(() => {
this.keyEvent.aDownTimeout = null
this.keyEvent.isADown = false
}, 500)
}
},
handle_mod_a_up() {
if (this.keyEvent.isADown) this.keyEvent.isADown = false
handle_key_mod_a_up() {
if (this.keyEvent.isADown) {
if (this.keyEvent.aDownTimeout) {
clearTimeout(this.keyEvent.aDownTimeout)
this.keyEvent.aDownTimeout = null
}
this.keyEvent.isADown = false
}
},
handleDoubleClick(event, index) {
if (event.target.classList.contains('select')) return

View File

@ -72,6 +72,7 @@ export default {
isShiftDown: false,
isModDown: false,
isADown: false,
aDownTimeout: null,
},
}
},
@ -188,41 +189,53 @@ export default {
setPlayList: 'setList',
}),
listenEvent() {
window.eventHub.$on('shift_down', this.handle_shift_down)
window.eventHub.$on('shift_up', this.handle_shift_up)
window.eventHub.$on('mod_down', this.handle_mod_down)
window.eventHub.$on('mod_up', this.handle_mod_up)
window.eventHub.$on('mod+a_down', this.handle_mod_a_down)
window.eventHub.$on('mod+a_up', this.handle_mod_a_up)
window.eventHub.$on('key_shift_down', this.handle_key_shift_down)
window.eventHub.$on('key_shift_up', this.handle_key_shift_up)
window.eventHub.$on('key_mod_down', this.handle_key_mod_down)
window.eventHub.$on('key_mod_up', this.handle_key_mod_up)
window.eventHub.$on('key_mod+a_down', this.handle_mod_a_down)
window.eventHub.$on('key_mod+a_up', this.handle_mod_a_up)
},
unlistenEvent() {
window.eventHub.$off('shift_down', this.handle_shift_down)
window.eventHub.$off('shift_up', this.handle_shift_up)
window.eventHub.$off('mod_down', this.handle_mod_down)
window.eventHub.$off('mod_up', this.handle_mod_up)
window.eventHub.$off('mod+a_down', this.handle_mod_a_down)
window.eventHub.$off('mod+a_up', this.handle_mod_a_up)
window.eventHub.$off('key_shift_down', this.handle_key_shift_down)
window.eventHub.$off('key_shift_up', this.handle_key_shift_up)
window.eventHub.$off('key_mod_down', this.handle_key_mod_down)
window.eventHub.$off('key_mod_up', this.handle_key_mod_up)
window.eventHub.$off('key_mod+a_down', this.handle_mod_a_down)
window.eventHub.$off('key_mod+a_up', this.handle_mod_a_up)
},
handle_shift_down() {
handle_key_shift_down() {
if (!this.keyEvent.isShiftDown) this.keyEvent.isShiftDown = true
},
handle_shift_up() {
handle_key_shift_up() {
if (this.keyEvent.isShiftDown) this.keyEvent.isShiftDown = false
},
handle_mod_down() {
handle_key_mod_down() {
if (!this.keyEvent.isModDown) this.keyEvent.isModDown = true
},
handle_mod_up() {
handle_key_mod_up() {
if (this.keyEvent.isModDown) this.keyEvent.isModDown = false
},
handle_mod_a_down() {
handle_key_mod_a_down() {
if (!this.keyEvent.isADown) {
this.keyEvent.isModDown = false
this.keyEvent.isADown = true
this.handleSelectAllData()
if (this.keyEvent.aDownTimeout) clearTimeout(this.keyEvent.aDownTimeout)
this.keyEvent.aDownTimeout = setTimeout(() => {
this.keyEvent.aDownTimeout = null
this.keyEvent.isADown = false
}, 500)
}
},
handle_mod_a_up() {
if (this.keyEvent.isADown) this.keyEvent.isADown = false
handle_key_mod_a_up() {
if (this.keyEvent.isADown) {
if (this.keyEvent.aDownTimeout) {
clearTimeout(this.keyEvent.aDownTimeout)
this.keyEvent.aDownTimeout = null
}
this.keyEvent.isADown = false
}
},
handleDelayShow() {
this.clearDelayTimeout()

View File

@ -82,6 +82,7 @@ export default {
isShiftDown: false,
isModDown: false,
isADown: false,
aDownTimeout: null,
},
}
},
@ -166,41 +167,53 @@ export default {
getHotSearch: 'getList',
}),
listenEvent() {
window.eventHub.$on('shift_down', this.handle_shift_down)
window.eventHub.$on('shift_up', this.handle_shift_up)
window.eventHub.$on('mod_down', this.handle_mod_down)
window.eventHub.$on('mod_up', this.handle_mod_up)
window.eventHub.$on('mod+a_down', this.handle_mod_a_down)
window.eventHub.$on('mod+a_up', this.handle_mod_a_up)
window.eventHub.$on('key_shift_down', this.handle_key_shift_down)
window.eventHub.$on('key_shift_up', this.handle_key_shift_up)
window.eventHub.$on('key_mod_down', this.handle_key_mod_down)
window.eventHub.$on('key_mod_up', this.handle_key_mod_up)
window.eventHub.$on('key_mod+a_down', this.handle_mod_a_down)
window.eventHub.$on('key_mod+a_up', this.handle_mod_a_up)
},
unlistenEvent() {
window.eventHub.$off('shift_down', this.handle_shift_down)
window.eventHub.$off('shift_up', this.handle_shift_up)
window.eventHub.$off('mod_down', this.handle_mod_down)
window.eventHub.$off('mod_up', this.handle_mod_up)
window.eventHub.$off('mod+a_down', this.handle_mod_a_down)
window.eventHub.$off('mod+a_up', this.handle_mod_a_up)
window.eventHub.$off('key_shift_down', this.handle_key_shift_down)
window.eventHub.$off('key_shift_up', this.handle_key_shift_up)
window.eventHub.$off('key_mod_down', this.handle_key_mod_down)
window.eventHub.$off('key_mod_up', this.handle_key_mod_up)
window.eventHub.$off('key_mod+a_down', this.handle_mod_a_down)
window.eventHub.$off('key_mod+a_up', this.handle_mod_a_up)
},
handle_shift_down() {
handle_key_shift_down() {
if (!this.keyEvent.isShiftDown) this.keyEvent.isShiftDown = true
},
handle_shift_up() {
handle_key_shift_up() {
if (this.keyEvent.isShiftDown) this.keyEvent.isShiftDown = false
},
handle_mod_down() {
handle_key_mod_down() {
if (!this.keyEvent.isModDown) this.keyEvent.isModDown = true
},
handle_mod_up() {
handle_key_mod_up() {
if (this.keyEvent.isModDown) this.keyEvent.isModDown = false
},
handle_mod_a_down() {
handle_key_mod_a_down() {
if (!this.keyEvent.isADown) {
this.keyEvent.isModDown = false
this.keyEvent.isADown = true
this.handleSelectAllData()
if (this.keyEvent.aDownTimeout) clearTimeout(this.keyEvent.aDownTimeout)
this.keyEvent.aDownTimeout = setTimeout(() => {
this.keyEvent.aDownTimeout = null
this.keyEvent.isADown = false
}, 500)
}
},
handle_mod_a_up() {
if (this.keyEvent.isADown) this.keyEvent.isADown = false
handle_key_mod_a_up() {
if (this.keyEvent.isADown) {
if (this.keyEvent.aDownTimeout) {
clearTimeout(this.keyEvent.aDownTimeout)
this.keyEvent.aDownTimeout = null
}
this.keyEvent.isADown = false
}
},
handleSearch(text, page) {
if (text === '') return this.clearList()