新增快捷键设置
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
const { mainHandle, NAMES: { mainWindow: ipcMainWindowNames } } = require('../../common/ipc')
|
||||
|
||||
mainHandle(ipcMainWindowNames.clear_cache, async(event, options) => {
|
||||
if (!global.modals.mainWindow) throw new Error('mainWindow is undefined')
|
||||
return global.modals.mainWindow.webContents.session.clearCache()
|
||||
if (!global.modules.mainWindow) throw new Error('mainWindow is undefined')
|
||||
return global.modules.mainWindow.webContents.session.clearCache()
|
||||
})
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const { mainHandle, NAMES: { mainWindow: ipcMainWindowNames } } = require('../../common/ipc')
|
||||
|
||||
mainHandle(ipcMainWindowNames.get_cache_size, async(event, options) => {
|
||||
if (!global.modals.mainWindow) throw new Error('mainWindow is undefined')
|
||||
return global.modals.mainWindow.webContents.session.getCacheSize()
|
||||
if (!global.modules.mainWindow) throw new Error('mainWindow is undefined')
|
||||
return global.modules.mainWindow.webContents.session.getCacheSize()
|
||||
})
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
const { mainSend, NAMES: { mainWindow: ipcMainWindowNames }, mainOn } = require('../../common/ipc')
|
||||
const { mainWindow: MAIN_WINDOW_EVENT_NAME, hotKey: HOT_KEY_EVENT_NAME } = require('../events/_name')
|
||||
// const { registerHotkey, unRegisterHotkey } = require('../modules/hotKey/utils')
|
||||
|
||||
// mainHandle(ipcMainWindowNames.set_hot_key_config, async(event, { action, data }) => {
|
||||
// switch (action) {
|
||||
// case 'config':
|
||||
// global.lx_event.hotKey.saveConfig(data.data, MAIN_WINDOW_EVENT_NAME.source)
|
||||
// return
|
||||
// case 'register':
|
||||
// return registerHotkey(data)
|
||||
// case 'unregister':
|
||||
// return unRegisterHotkey(data)
|
||||
// }
|
||||
// })
|
||||
|
||||
mainOn(ipcMainWindowNames.quit, () => global.lx_event.mainWindow.quit())
|
||||
mainOn(ipcMainWindowNames.min_toggle, () => global.lx_event.mainWindow.toggleMinimize())
|
||||
mainOn(ipcMainWindowNames.hide_toggle, () => global.lx_event.mainWindow.toggleHide())
|
||||
|
||||
|
||||
global.lx_event.hotKey.on(HOT_KEY_EVENT_NAME.config, (config, source) => {
|
||||
if (!global.modules.mainWindow || source === MAIN_WINDOW_EVENT_NAME.name) return
|
||||
mainSend(global.modules.mainWindow, ipcMainWindowNames.set_hot_key_config, { config, source })
|
||||
})
|
||||
|
||||
global.lx_event.hotKey.on(HOT_KEY_EVENT_NAME.keyDown, ({ type, key }) => {
|
||||
let info = global.appHotKey.config.global.keys[key]
|
||||
if (!info || info.type != MAIN_WINDOW_EVENT_NAME.name) return
|
||||
mainSend(global.modules.mainWindow, ipcMainWindowNames.key_down, { type, key })
|
||||
})
|
||||
@@ -13,6 +13,7 @@ require('./setIgnoreMouseEvent')
|
||||
require('./getEnvParams')
|
||||
require('./setAppSetting')
|
||||
require('./setLyricInfo')
|
||||
require('./hotKey')
|
||||
|
||||
require('./xm_verify')
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ const decodeLyric = async(buf, isGetLyricx) => {
|
||||
}
|
||||
|
||||
mainHandle(ipcMainWindowNames.handle_kw_decode_lyric, async(event, { lrcBase64, isGetLyricx }) => {
|
||||
if (!global.modals.mainWindow) throw new Error('mainWindow is undefined')
|
||||
if (!global.modules.mainWindow) throw new Error('mainWindow is undefined')
|
||||
const lrc = await decodeLyric(Buffer.from(lrcBase64, 'base64'), isGetLyricx)
|
||||
return Buffer.from(lrc).toString('base64')
|
||||
})
|
||||
|
||||
@@ -3,7 +3,7 @@ const { mainOn, NAMES: { mainWindow: ipcMainWindowNames } } = require('../../com
|
||||
|
||||
mainOn(ipcMainWindowNames.progress, (event, params) => {
|
||||
// console.log(params)
|
||||
global.modals.mainWindow && global.modals.mainWindow.setProgressBar(params.status, {
|
||||
global.modules.mainWindow && global.modules.mainWindow.setProgressBar(params.status, {
|
||||
mode: params.mode || 'normal',
|
||||
})
|
||||
})
|
||||
|
||||
@@ -2,7 +2,7 @@ const { mainHandle, NAMES: { mainWindow: ipcMainWindowNames } } = require('../..
|
||||
const { dialog } = require('electron')
|
||||
|
||||
mainHandle(ipcMainWindowNames.select_dir, async(event, options) => {
|
||||
if (!global.modals.mainWindow) throw new Error('mainWindow is undefined')
|
||||
return dialog.showOpenDialog(global.modals.mainWindow, options)
|
||||
if (!global.modules.mainWindow) throw new Error('mainWindow is undefined')
|
||||
return dialog.showOpenDialog(global.modules.mainWindow, options)
|
||||
})
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
const { mainOn, NAMES: { mainWindow: ipcMainWindowNames } } = require('../../common/ipc')
|
||||
|
||||
mainOn(ipcMainWindowNames.set_ignore_mouse_events, (event, isIgnored) => {
|
||||
if (!global.modals.mainWindow) return
|
||||
if (!global.modules.mainWindow) return
|
||||
isIgnored
|
||||
? global.modals.mainWindow.setIgnoreMouseEvents(true, { forward: true })
|
||||
: global.modals.mainWindow.setIgnoreMouseEvents(false)
|
||||
? global.modules.mainWindow.setIgnoreMouseEvents(true, { forward: true })
|
||||
: global.modules.mainWindow.setIgnoreMouseEvents(false)
|
||||
})
|
||||
|
||||
@@ -6,5 +6,5 @@ mainOn(ipcMainWindowNames.set_lyric_info, (event, info) => {
|
||||
global.lx_event.mainWindow.setLyricInfo(info)
|
||||
return
|
||||
}
|
||||
mainSend(global.modals[info.info.modal], info.info.name, info)
|
||||
mainSend(global.modules[info.info.modal], info.info.name, info)
|
||||
})
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const { mainOn, NAMES: { mainWindow: ipcMainWindowNames } } = require('../../common/ipc')
|
||||
|
||||
mainOn(ipcMainWindowNames.set_window_size, (event, options) => {
|
||||
if (!global.modals.mainWindow) return
|
||||
global.modals.mainWindow.setBounds(options)
|
||||
if (!global.modules.mainWindow) return
|
||||
global.modules.mainWindow.setBounds(options)
|
||||
})
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ const { mainHandle, NAMES: { mainWindow: ipcMainWindowNames } } = require('../..
|
||||
const { dialog } = require('electron')
|
||||
|
||||
mainHandle(ipcMainWindowNames.show_save_dialog, async(event, options) => {
|
||||
if (!global.modals.mainWindow) throw new Error('mainWindow is undefined')
|
||||
return dialog.showSaveDialog(global.modals.mainWindow, options)
|
||||
if (!global.modules.mainWindow) throw new Error('mainWindow is undefined')
|
||||
return dialog.showSaveDialog(global.modules.mainWindow, options)
|
||||
})
|
||||
|
||||
|
||||
@@ -2,17 +2,17 @@ const { app } = require('electron')
|
||||
const { mainOn, NAMES: { mainWindow: ipcMainWindowNames } } = require('../../common/ipc')
|
||||
|
||||
mainOn(ipcMainWindowNames.min, event => {
|
||||
if (global.modals.mainWindow) {
|
||||
global.modals.mainWindow.minimize()
|
||||
if (global.modules.mainWindow) {
|
||||
global.modules.mainWindow.minimize()
|
||||
}
|
||||
})
|
||||
mainOn(ipcMainWindowNames.max, event => {
|
||||
if (global.modals.mainWindow) {
|
||||
global.modals.mainWindow.maximize()
|
||||
if (global.modules.mainWindow) {
|
||||
global.modules.mainWindow.maximize()
|
||||
}
|
||||
})
|
||||
mainOn(ipcMainWindowNames.close, (event, isForce) => {
|
||||
if (isForce) return app.exit(0)
|
||||
global.isTrafficLightClose = true
|
||||
if (global.modals.mainWindow) global.modals.mainWindow.close()
|
||||
if (global.modules.mainWindow) global.modules.mainWindow.close()
|
||||
})
|
||||
|
||||
@@ -17,7 +17,7 @@ module.exports = mainWindow => {
|
||||
})
|
||||
|
||||
mainWindow.on('closed', () => {
|
||||
mainWindow = global.modals.mainWindow = null
|
||||
mainWindow = global.modules.mainWindow = null
|
||||
})
|
||||
|
||||
// mainWindow.on('restore', () => {
|
||||
|
||||
@@ -9,16 +9,16 @@ let rejectFn
|
||||
const closeView = async() => {
|
||||
if (!view) return
|
||||
// await view.webContents.session.clearCache()
|
||||
if (global.modals.mainWindow) global.modals.mainWindow.removeBrowserView(view)
|
||||
if (global.modules.mainWindow) global.modules.mainWindow.removeBrowserView(view)
|
||||
await view.webContents.session.clearStorageData()
|
||||
view.destroy()
|
||||
view = null
|
||||
}
|
||||
|
||||
mainHandle(ipcMainWindowNames.handle_xm_verify_open, (event, url) => new Promise((resolve, reject) => {
|
||||
if (!global.modals.mainWindow) return reject(new Error('mainWindow is undefined'))
|
||||
if (!global.modules.mainWindow) return reject(new Error('mainWindow is undefined'))
|
||||
if (view) {
|
||||
global.modals.mainWindow.removeBrowserView(view)
|
||||
global.modules.mainWindow.removeBrowserView(view)
|
||||
view.destroy()
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ mainHandle(ipcMainWindowNames.handle_xm_verify_open, (event, url) => new Promise
|
||||
})
|
||||
})
|
||||
|
||||
global.modals.mainWindow.setBrowserView(view)
|
||||
global.modules.mainWindow.setBrowserView(view)
|
||||
const windowSizeInfo = getWindowSizeInfo(global.appSetting)
|
||||
view.setBounds({ x: (windowSizeInfo.width - 380) / 2, y: ((windowSizeInfo.height - 320 + 52) / 2), width: 380, height: 320 })
|
||||
view.webContents.loadURL(url, {
|
||||
|
||||
@@ -7,7 +7,7 @@ let win
|
||||
const closeWin = async() => {
|
||||
if (!win) return
|
||||
// await win.webContents.session.clearCache()
|
||||
// if (global.modals.mainWindow) global.modals.mainWindow.removeBrowserView(win)
|
||||
// if (global.modules.mainWindow) global.modules.mainWindow.removeBrowserView(win)
|
||||
if (win.isDestroyed()) {
|
||||
win = null
|
||||
return
|
||||
@@ -18,15 +18,15 @@ const closeWin = async() => {
|
||||
}
|
||||
|
||||
mainHandle(ipcMainWindowNames.handle_xm_verify_open, (event, url) => new Promise((resolve, reject) => {
|
||||
if (!global.modals.mainWindow) return reject(new Error('mainWindow is undefined'))
|
||||
if (!global.modules.mainWindow) return reject(new Error('mainWindow is undefined'))
|
||||
if (win) win.destroy()
|
||||
|
||||
let isActioned = false
|
||||
|
||||
const mainWindowSizeInfo = global.modals.mainWindow.getBounds()
|
||||
const mainWindowSizeInfo = global.modules.mainWindow.getBounds()
|
||||
const windowSizeInfo = getWindowSizeInfo(global.appSetting)
|
||||
win = new BrowserWindow({
|
||||
parent: global.modals.mainWindow,
|
||||
parent: global.modules.mainWindow,
|
||||
width: 460,
|
||||
height: 370,
|
||||
resizable: false,
|
||||
|
||||
Reference in New Issue
Block a user