修复多选机制问题
parent
78c5250f1b
commit
2cabe6e58e
|
@ -1,3 +1,3 @@
|
|||
### 修复
|
||||
|
||||
- 修复开启托盘时,可能导致无法自动更新的问题
|
||||
- 修复按住`Ctrl`等键触发多选机制时不松开按键的情况下切换到其他窗口后再松开按键,这时切回软件不按按键都处在多选模式的问题
|
||||
|
|
|
@ -21,6 +21,9 @@ module.exports = mainWindow => {
|
|||
// mainWindow.on('restore', () => {
|
||||
// mainWindow.webContents.send('restore')
|
||||
// })
|
||||
mainWindow.on('focus', () => {
|
||||
mainWindow.webContents.send('focus')
|
||||
})
|
||||
|
||||
mainWindow.once('ready-to-show', () => {
|
||||
mainWindow.show()
|
||||
|
|
|
@ -1,41 +1,38 @@
|
|||
import mousetrap from 'mousetrap'
|
||||
|
||||
let eventHub
|
||||
|
||||
const bindKeys = [
|
||||
'shift',
|
||||
'mod',
|
||||
'mod+a',
|
||||
]
|
||||
|
||||
const bindKey = () => {
|
||||
mousetrap.reset()
|
||||
mousetrap.bind('shift', (event, combo) => {
|
||||
eventHub.$emit('key_shift_down', { event, combo })
|
||||
return false
|
||||
}, 'keydown')
|
||||
mousetrap.bind('shift', (event, combo) => {
|
||||
eventHub.$emit('key_shift_up', { event, combo })
|
||||
return false
|
||||
}, 'keyup')
|
||||
mousetrap.bind('mod', (event, combo) => {
|
||||
eventHub.$emit('key_mod_down', { event, combo })
|
||||
return false
|
||||
}, 'keydown')
|
||||
mousetrap.bind('mod', (event, combo) => {
|
||||
eventHub.$emit('key_mod_up', { event, combo })
|
||||
return false
|
||||
}, 'keyup')
|
||||
mousetrap.bind('mod+a', (event, combo) => {
|
||||
eventHub.$emit('key_mod+a_down', { event, combo })
|
||||
return false
|
||||
}, 'keydown')
|
||||
mousetrap.bind('mod+a', (event, combo) => {
|
||||
eventHub.$emit('key_mod+a_up', { event, combo })
|
||||
return false
|
||||
}, 'keyup')
|
||||
for (const key of bindKeys) {
|
||||
mousetrap.bind(key, (event, combo) => {
|
||||
eventHub.$emit(`key_${key}_down`, { event, combo })
|
||||
return false
|
||||
}, 'keydown')
|
||||
mousetrap.bind(key, (event, combo) => {
|
||||
eventHub.$emit(`key_${key}_up`, { event, combo })
|
||||
return false
|
||||
}, 'keyup')
|
||||
}
|
||||
}
|
||||
|
||||
const unbindKey = () => {
|
||||
mousetrap.unbind('shift', 'keydown')
|
||||
mousetrap.unbind('shift', 'keyup')
|
||||
mousetrap.unbind('mod', 'keydown')
|
||||
mousetrap.unbind('mod', 'keyup')
|
||||
mousetrap.unbind('mod+a', 'keydown')
|
||||
mousetrap.unbind('mod+a', 'keyup')
|
||||
for (const key of bindKeys) {
|
||||
mousetrap.unbind(key, 'keydown')
|
||||
mousetrap.unbind(key, 'keyup')
|
||||
}
|
||||
}
|
||||
|
||||
const handleFocus = () => {
|
||||
for (const key of bindKeys) {
|
||||
eventHub.$emit(`key_${key}_up`, { combo: key })
|
||||
}
|
||||
}
|
||||
|
||||
export default () => {
|
||||
|
@ -43,4 +40,5 @@ export default () => {
|
|||
|
||||
eventHub.$on('bindKey', bindKey)
|
||||
eventHub.$on('unbindKey', unbindKey)
|
||||
eventHub.$on('focus', handleFocus)
|
||||
}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
import Vue from 'vue'
|
||||
import bindkey from './bindkey'
|
||||
import { rendererOn } from '../../common/ipc'
|
||||
|
||||
window.eventHub = new Vue()
|
||||
|
||||
bindkey()
|
||||
|
||||
rendererOn('focus', () => {
|
||||
window.eventHub.$emit('focus')
|
||||
})
|
|
@ -1,6 +1,8 @@
|
|||
import Vue from 'vue'
|
||||
import { sync } from 'vuex-router-sync'
|
||||
|
||||
import './config/event'
|
||||
|
||||
// Components
|
||||
import './components'
|
||||
|
||||
|
@ -14,14 +16,8 @@ import store from './store'
|
|||
|
||||
import '../common/error'
|
||||
|
||||
import bindkey from './config/bindkey'
|
||||
|
||||
sync(store, router)
|
||||
|
||||
window.eventHub = new Vue()
|
||||
|
||||
bindkey()
|
||||
|
||||
Vue.config.productionTip = false
|
||||
|
||||
new Vue({
|
||||
|
|
Loading…
Reference in New Issue