diff --git a/src/main/index.js b/src/main/index.js
index 05075e0..d50bea0 100644
--- a/src/main/index.js
+++ b/src/main/index.js
@@ -29,7 +29,7 @@ import {
import {
shortKeyUpdater,
initShortKeyRegister
-} from './utils/shortKeyRegister'
+} from './utils/shortKeyHandler'
if (process.platform === 'darwin') {
beforeOpen()
}
@@ -309,9 +309,12 @@ const createSettingWindow = () => {
settingWindow.loadURL(settingWinURL)
settingWindow.on('closed', () => {
+ bus.emit('toggleShortKeyModifiedMode', false)
settingWindow = null
if (process.platform === 'linux') {
- app.quit()
+ process.nextTick(() => {
+ app.quit()
+ })
}
})
createMenu()
@@ -506,8 +509,8 @@ ipcMain.on('getPicBeds', (evt) => {
evt.returnValue = picBeds
})
-ipcMain.on('updateShortKey', (evt, val) => {
- // console.log(val)
+ipcMain.on('toggleShortKeyModifiedMode', (evt, val) => {
+ bus.emit('toggleShortKeyModifiedMode', val)
})
// const shortKeyHash = {
diff --git a/src/main/utils/shortKeyRegister.js b/src/main/utils/shortKeyHandler.js
similarity index 84%
rename from src/main/utils/shortKeyRegister.js
rename to src/main/utils/shortKeyHandler.js
index f608155..7aefe3b 100644
--- a/src/main/utils/shortKeyRegister.js
+++ b/src/main/utils/shortKeyHandler.js
@@ -1,9 +1,16 @@
-import bus from '../utils/eventBus'
+import bus from './eventBus'
+let isInModifiedMode = false // 修改快捷键模式
+bus.on('toggleShortKeyModifiedMode', flag => {
+ isInModifiedMode = flag
+})
/**
*
* @param {string} name
*/
const shortKeyHandler = (name) => {
+ if (isInModifiedMode) {
+ return
+ }
if (name.includes('picgo:')) {
bus.emit(name)
} else if (name.includes('picgo-plugin-')) {
diff --git a/src/renderer/layouts/SettingPage.vue b/src/renderer/layouts/SettingPage.vue
index 421952e..f86228c 100644
--- a/src/renderer/layouts/SettingPage.vue
+++ b/src/renderer/layouts/SettingPage.vue
@@ -91,29 +91,6 @@
-
-
-
-
-
-
-
- 取消
- 确定
-
-
-
-
-
-
-
-
-
- 取消
- 确定
-
-
编辑
@@ -102,13 +102,19 @@ export default {
list: [],
keyBindingVisible: false,
shortKeyName: '',
- shortKey: ''
+ shortKey: '',
+ currentIndex: 0
}
},
created () {
const shortKeyConfig = this.$db.get('settings.shortKey')
this.list = Object.keys(shortKeyConfig).map(item => shortKeyConfig[item])
},
+ watch: {
+ keyBindingVisible (val) {
+ this.$electron.ipcRenderer.send('toggleShortKeyModifiedMode', val)
+ }
+ },
methods: {
calcOrigin (item) {
const [origin] = item.split(':')
@@ -123,9 +129,10 @@ export default {
keyDetect (event) {
this.shortKey = keyDetect(event).join('+')
},
- openKeyBindingDialog (name) {
+ openKeyBindingDialog (name, index) {
this.shortKeyName = name
this.shortKey = this.$db.get(`settings.shortKey.${name}.key`)
+ this.currentIndex = index
this.keyBindingVisible = true
},
cancelKeyBinding () {
@@ -137,8 +144,12 @@ export default {
this.$db.set(`settings.shortKey.${this.shortKeyName}.key`, this.shortKey)
const newKey = this.$db.get(`settings.shortKey.${this.shortKeyName}`)
this.$electron.ipcRenderer.send('updateShortKey', newKey, oldKey)
+ this.list[this.currentIndex].key = this.shortKey
this.keyBindingVisible = false
}
+ },
+ beforeDestroy () {
+ this.$electron.ipcRenderer.send('toggleShortKeyModifiedMode', false)
}
}