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