mirror of
https://github.com/Kuingsmile/PicList.git
synced 2025-03-13 08:28:13 -04:00
🚧 WIP: handle shortcut setting time
This commit is contained in:
parent
b63ac03b84
commit
72e6e2aed5
@ -29,7 +29,7 @@ import {
|
|||||||
import {
|
import {
|
||||||
shortKeyUpdater,
|
shortKeyUpdater,
|
||||||
initShortKeyRegister
|
initShortKeyRegister
|
||||||
} from './utils/shortKeyRegister'
|
} from './utils/shortKeyHandler'
|
||||||
if (process.platform === 'darwin') {
|
if (process.platform === 'darwin') {
|
||||||
beforeOpen()
|
beforeOpen()
|
||||||
}
|
}
|
||||||
@ -309,9 +309,12 @@ const createSettingWindow = () => {
|
|||||||
settingWindow.loadURL(settingWinURL)
|
settingWindow.loadURL(settingWinURL)
|
||||||
|
|
||||||
settingWindow.on('closed', () => {
|
settingWindow.on('closed', () => {
|
||||||
|
bus.emit('toggleShortKeyModifiedMode', false)
|
||||||
settingWindow = null
|
settingWindow = null
|
||||||
if (process.platform === 'linux') {
|
if (process.platform === 'linux') {
|
||||||
|
process.nextTick(() => {
|
||||||
app.quit()
|
app.quit()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
createMenu()
|
createMenu()
|
||||||
@ -506,8 +509,8 @@ ipcMain.on('getPicBeds', (evt) => {
|
|||||||
evt.returnValue = picBeds
|
evt.returnValue = picBeds
|
||||||
})
|
})
|
||||||
|
|
||||||
ipcMain.on('updateShortKey', (evt, val) => {
|
ipcMain.on('toggleShortKeyModifiedMode', (evt, val) => {
|
||||||
// console.log(val)
|
bus.emit('toggleShortKeyModifiedMode', val)
|
||||||
})
|
})
|
||||||
|
|
||||||
// const shortKeyHash = {
|
// const shortKeyHash = {
|
||||||
|
@ -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
|
* @param {string} name
|
||||||
*/
|
*/
|
||||||
const shortKeyHandler = (name) => {
|
const shortKeyHandler = (name) => {
|
||||||
|
if (isInModifiedMode) {
|
||||||
|
return
|
||||||
|
}
|
||||||
if (name.includes('picgo:')) {
|
if (name.includes('picgo:')) {
|
||||||
bus.emit(name)
|
bus.emit(name)
|
||||||
} else if (name.includes('picgo-plugin-')) {
|
} else if (name.includes('picgo-plugin-')) {
|
@ -91,29 +91,6 @@
|
|||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
<el-dialog
|
|
||||||
title="修改快捷键"
|
|
||||||
:visible.sync="keyBindingVisible"
|
|
||||||
>
|
|
||||||
<el-form
|
|
||||||
label-width="80px"
|
|
||||||
>
|
|
||||||
<el-form-item
|
|
||||||
label="快捷上传"
|
|
||||||
>
|
|
||||||
<el-input
|
|
||||||
class="align-center"
|
|
||||||
@keydown.native.prevent="keyDetect('upload', $event)"
|
|
||||||
v-model="shortKey.upload"
|
|
||||||
:autofocus="true"
|
|
||||||
></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
<span slot="footer">
|
|
||||||
<el-button @click="cancelKeyBinding">取消</el-button>
|
|
||||||
<el-button type="primary" @click="confirmKeyBinding">确定</el-button>
|
|
||||||
</span>
|
|
||||||
</el-dialog>
|
|
||||||
<el-dialog
|
<el-dialog
|
||||||
title="自定义链接格式"
|
title="自定义链接格式"
|
||||||
:visible.sync="customLinkVisible"
|
:visible.sync="customLinkVisible"
|
||||||
|
@ -120,30 +120,6 @@
|
|||||||
</el-row>
|
</el-row>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
<el-dialog
|
|
||||||
title="修改上传快捷键"
|
|
||||||
:visible.sync="keyBindingVisible"
|
|
||||||
:modal-append-to-body="false"
|
|
||||||
>
|
|
||||||
<el-form
|
|
||||||
label-width="80px"
|
|
||||||
>
|
|
||||||
<el-form-item
|
|
||||||
label="快捷上传"
|
|
||||||
>
|
|
||||||
<el-input
|
|
||||||
class="align-center"
|
|
||||||
@keydown.native.prevent="keyDetect('upload', $event)"
|
|
||||||
v-model="shortKey.upload"
|
|
||||||
:autofocus="true"
|
|
||||||
></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
<span slot="footer">
|
|
||||||
<el-button @click="cancelKeyBinding" round>取消</el-button>
|
|
||||||
<el-button type="primary" @click="confirmKeyBinding" round>确定</el-button>
|
|
||||||
</span>
|
|
||||||
</el-dialog>
|
|
||||||
<el-dialog
|
<el-dialog
|
||||||
title="自定义链接格式"
|
title="自定义链接格式"
|
||||||
:visible.sync="customLinkVisible"
|
:visible.sync="customLinkVisible"
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
<el-button
|
<el-button
|
||||||
class="edit"
|
class="edit"
|
||||||
size="mini"
|
size="mini"
|
||||||
@click="openKeyBindingDialog(scope.row.name)"
|
@click="openKeyBindingDialog(scope.row.name, scope.$index)"
|
||||||
type="text">
|
type="text">
|
||||||
编辑
|
编辑
|
||||||
</el-button>
|
</el-button>
|
||||||
@ -102,13 +102,19 @@ export default {
|
|||||||
list: [],
|
list: [],
|
||||||
keyBindingVisible: false,
|
keyBindingVisible: false,
|
||||||
shortKeyName: '',
|
shortKeyName: '',
|
||||||
shortKey: ''
|
shortKey: '',
|
||||||
|
currentIndex: 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
const shortKeyConfig = this.$db.get('settings.shortKey')
|
const shortKeyConfig = this.$db.get('settings.shortKey')
|
||||||
this.list = Object.keys(shortKeyConfig).map(item => shortKeyConfig[item])
|
this.list = Object.keys(shortKeyConfig).map(item => shortKeyConfig[item])
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
keyBindingVisible (val) {
|
||||||
|
this.$electron.ipcRenderer.send('toggleShortKeyModifiedMode', val)
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
calcOrigin (item) {
|
calcOrigin (item) {
|
||||||
const [origin] = item.split(':')
|
const [origin] = item.split(':')
|
||||||
@ -123,9 +129,10 @@ export default {
|
|||||||
keyDetect (event) {
|
keyDetect (event) {
|
||||||
this.shortKey = keyDetect(event).join('+')
|
this.shortKey = keyDetect(event).join('+')
|
||||||
},
|
},
|
||||||
openKeyBindingDialog (name) {
|
openKeyBindingDialog (name, index) {
|
||||||
this.shortKeyName = name
|
this.shortKeyName = name
|
||||||
this.shortKey = this.$db.get(`settings.shortKey.${name}.key`)
|
this.shortKey = this.$db.get(`settings.shortKey.${name}.key`)
|
||||||
|
this.currentIndex = index
|
||||||
this.keyBindingVisible = true
|
this.keyBindingVisible = true
|
||||||
},
|
},
|
||||||
cancelKeyBinding () {
|
cancelKeyBinding () {
|
||||||
@ -137,8 +144,12 @@ export default {
|
|||||||
this.$db.set(`settings.shortKey.${this.shortKeyName}.key`, this.shortKey)
|
this.$db.set(`settings.shortKey.${this.shortKeyName}.key`, this.shortKey)
|
||||||
const newKey = this.$db.get(`settings.shortKey.${this.shortKeyName}`)
|
const newKey = this.$db.get(`settings.shortKey.${this.shortKeyName}`)
|
||||||
this.$electron.ipcRenderer.send('updateShortKey', newKey, oldKey)
|
this.$electron.ipcRenderer.send('updateShortKey', newKey, oldKey)
|
||||||
|
this.list[this.currentIndex].key = this.shortKey
|
||||||
this.keyBindingVisible = false
|
this.keyBindingVisible = false
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
beforeDestroy () {
|
||||||
|
this.$electron.ipcRenderer.send('toggleShortKeyModifiedMode', false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user