新增快捷键设置

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
+30 -8
View File
@@ -1,5 +1,6 @@
const { common: COMMON_EVENT_NAME, winLyric: WIN_LYRIC_EVENT_NAME, mainWindow: MAIN_WINDOW_EVENT_NAME } = require('../../events/_name')
const { common: COMMON_EVENT_NAME, winLyric: WIN_LYRIC_EVENT_NAME, hotKey: HOT_KEY_EVENT_NAME, mainWindow: MAIN_WINDOW_EVENT_NAME } = require('../../events/_name')
const { mainSend, NAMES: { winLyric: ipcWinLyricNames } } = require('../../../common/ipc')
const { desktop_lyric } = require('../../../common/hotKey')
let isLock = null
let isEnable = null
@@ -14,19 +15,19 @@ const setLrcConfig = isForceSet => {
global.lx_event.winLyric.close()
}
}
if (global.modals.lyricWindow) {
mainSend(global.modals.lyricWindow, ipcWinLyricNames.set_lyric_config, desktopLyric)
if (global.modules.lyricWindow) {
mainSend(global.modules.lyricWindow, ipcWinLyricNames.set_lyric_config, desktopLyric)
if (isForceSet || isLock != desktopLyric.isLock) {
isLock = desktopLyric.isLock
if (desktopLyric.isLock) {
global.modals.lyricWindow.setIgnoreMouseEvents(true, { forward: false })
global.modules.lyricWindow.setIgnoreMouseEvents(true, { forward: false })
} else {
global.modals.lyricWindow.setIgnoreMouseEvents(false)
global.modules.lyricWindow.setIgnoreMouseEvents(false)
}
}
if (isForceSet || isAlwaysOnTop != desktopLyric.isAlwaysOnTop) {
isAlwaysOnTop = desktopLyric.isAlwaysOnTop
global.modals.lyricWindow.setAlwaysOnTop(desktopLyric.isAlwaysOnTop, 'screen-saver')
global.modules.lyricWindow.setAlwaysOnTop(desktopLyric.isAlwaysOnTop, 'screen-saver')
}
}
}
@@ -37,6 +38,27 @@ global.lx_event.common.on(COMMON_EVENT_NAME.config, name => {
global.lx_event.winLyric.on(WIN_LYRIC_EVENT_NAME.inited, () => setLrcConfig(true))
global.lx_event.mainWindow.on(MAIN_WINDOW_EVENT_NAME.setLyricInfo, info => {
if (!global.modals.lyricWindow) return
mainSend(global.modals.lyricWindow, ipcWinLyricNames.set_lyric_info, info)
if (!global.modules.lyricWindow) return
mainSend(global.modules.lyricWindow, ipcWinLyricNames.set_lyric_info, info)
})
global.lx_event.hotKey.on(HOT_KEY_EVENT_NAME.keyDown, ({ type, key }) => {
let info = global.appHotKey.config.global.keys[key]
if (!info || info.type != WIN_LYRIC_EVENT_NAME.name) return
let desktopLyricSetting = JSON.parse(JSON.stringify(global.appSetting.desktopLyric))
let settingKey
switch (info.action) {
case desktop_lyric.toggle_visible.action:
settingKey = 'enable'
break
case desktop_lyric.toggle_lock.action:
settingKey = 'isLock'
break
case desktop_lyric.toggle_always_top.action:
settingKey = 'isAlwaysOnTop'
break
}
desktopLyricSetting[settingKey] = !desktopLyricSetting[settingKey]
global.lx_event.common.setAppConfig({ desktopLyric: desktopLyricSetting }, null)
})
+8 -8
View File
@@ -36,7 +36,7 @@ const winEvent = lyricWindow => {
// })
lyricWindow.on('closed', () => {
lyricWindow = global.modals.lyricWindow = null
lyricWindow = global.modules.lyricWindow = null
})
@@ -62,7 +62,7 @@ const winEvent = lyricWindow => {
lyricWindow.once('ready-to-show', () => {
lyricWindow.show()
let config = global.appSetting.desktopLyric
global.modals.lyricWindow.setBounds({
global.modules.lyricWindow.setBounds({
height: config.height,
width: config.width,
y: config.y,
@@ -74,7 +74,7 @@ const winEvent = lyricWindow => {
const createWindow = () => {
if (global.modals.lyricWindow) return
if (global.modules.lyricWindow) return
if (!global.appSetting.desktopLyric.enable) return
// const windowSizeInfo = getWindowSizeInfo(global.appSetting)
const { x, y, width, height, isAlwaysOnTop } = global.appSetting.desktopLyric
@@ -84,7 +84,7 @@ const createWindow = () => {
/**
* Initial window options
*/
global.modals.lyricWindow = new BrowserWindow({
global.modules.lyricWindow = new BrowserWindow({
height: height > screenHeight ? screenHeight : height,
width: width > screenWidth ? screenWidth : width,
x: Math.max(-8, screenWidth < (width + x) ? screenWidth - width : x),
@@ -110,13 +110,13 @@ const createWindow = () => {
},
})
global.modals.lyricWindow.loadURL(winURL)
global.modules.lyricWindow.loadURL(winURL)
winEvent(global.modals.lyricWindow)
winEvent(global.modules.lyricWindow)
// mainWindow.webContents.openDevTools()
}
const closeWindow = () => {
if (!global.modals.lyricWindow) return
global.modals.lyricWindow.close()
if (!global.modules.lyricWindow) return
global.modules.lyricWindow.close()
}
+5 -5
View File
@@ -10,8 +10,8 @@ const {
const { winLyric: WIN_LYRIC_EVENT_NAME } = require('../../events/_name')
mainOn(ipcWinLyricNames.get_lyric_info, (event, action) => {
if (!global.modals.mainWindow) return
mainSend(global.modals.mainWindow, ipcMainWindowNames.get_lyric_info, {
if (!global.modules.mainWindow) return
mainSend(global.modules.mainWindow, ipcMainWindowNames.get_lyric_info, {
name: ipcWinLyricNames.set_lyric_info,
modal: 'lyricWindow',
action,
@@ -32,8 +32,8 @@ let winY
let wasW
let wasY
mainOn(ipcWinLyricNames.set_win_bounds, (event, { x = 0, y = 0, w = 0, h = 0 }) => {
if (!global.modals.lyricWindow) return
bounds = global.modals.lyricWindow.getBounds()
if (!global.modules.lyricWindow) return
bounds = global.modules.lyricWindow.getBounds()
wasW = global.envParams.workAreaSize.width
wasY = global.envParams.workAreaSize.height + 8
@@ -71,5 +71,5 @@ mainOn(ipcWinLyricNames.set_win_bounds, (event, { x = 0, y = 0, w = 0, h = 0 })
}
// console.log(bounds)
global.modals.lyricWindow.setBounds(bounds)
global.modules.lyricWindow.setBounds(bounds)
})