新增快捷键设置

This commit is contained in:
lyswhut
2020-06-24 01:20:56 +08:00
parent 2424c76c50
commit 9b82cdfe53
58 changed files with 2254 additions and 1450 deletions
+5 -5
View File
@@ -61,10 +61,10 @@ function sendStatusToWindow(text) {
let waitEvent = []
const handleSendEvent = action => {
if (global.modals.mainWindow) {
if (global.modules.mainWindow) {
setTimeout(() => { // 延迟发送事件,过早发送可能渲染进程还没启动完成
if (!global.modals.mainWindow) return
mainSend(global.modals.mainWindow, action.type, action.info)
if (!global.modules.mainWindow) return
mainSend(global.modules.mainWindow, action.type, action.info)
}, 2000)
} else {
waitEvent.push(action)
@@ -76,8 +76,8 @@ module.exports = () => {
if (waitEvent.length) {
waitEvent.forEach((event, index) => {
setTimeout(() => { // 延迟发送事件,过早发送可能渲染进程还没启动完成
if (!global.modals.mainWindow) return
mainSend(global.modals.mainWindow, event.type, event.info)
if (!global.modules.mainWindow) return
mainSend(global.modules.mainWindow, event.type, event.info)
}, 2000 * (index + 1))
})
waitEvent = []
+26 -4
View File
@@ -1,19 +1,41 @@
const Store = require('electron-store')
const { windowSizeList } = require('../../common/config')
const { objectDeepMerge } = require('../../common/utils')
const { objectDeepMerge, throttle } = require('../../common/utils')
exports.getWindowSizeInfo = ({ windowSizeId = 1 } = {}) => {
return windowSizeList.find(i => i.id === windowSizeId) || windowSizeList[0]
}
const electronStore_config = new Store({
name: 'config',
})
exports.getAppSetting = () => {
const electronStore_config = new Store({
name: 'config',
})
return electronStore_config.get('setting')
}
const electronStore_hotKey = new Store({
name: 'hotKey',
})
exports.getAppHotKeyConfig = () => {
return {
global: electronStore_hotKey.get('global'),
local: electronStore_hotKey.get('local'),
}
}
const saveHotKeyConfig = throttle(config => {
for (const key of Object.keys(config)) {
global.appHotKey.config[key] = config[key]
electronStore_hotKey.set(key, config[key])
}
})
exports.saveAppHotKeyConfig = config => {
saveHotKeyConfig(config)
}
const saveSetting = throttle(n => {
electronStore_config.set('setting', n)
})
exports.updateSetting = settings => {
objectDeepMerge(global.appSetting, settings)
saveSetting(global.appSetting)
}