From 93bab6bbdd31a64b082ce30021d5a5edd2da862f Mon Sep 17 00:00:00 2001 From: lyswhut Date: Wed, 24 Jun 2020 22:55:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/modules/appMenu.js | 16 ++++++------ src/main/modules/winLyric/event.js | 40 +++++++++++++++--------------- src/main/modules/winLyric/index.js | 11 +++----- 3 files changed, 30 insertions(+), 37 deletions(-) diff --git a/src/main/modules/appMenu.js b/src/main/modules/appMenu.js index 2af38e4a..095be8e1 100644 --- a/src/main/modules/appMenu.js +++ b/src/main/modules/appMenu.js @@ -9,8 +9,6 @@ if (isMac) { { label: '关于洛雪音乐', role: 'about' }, { type: 'separator' }, { label: '隐藏', role: 'hide' }, - { label: '显示其他', role: 'hideothers' }, - { label: '显示全部', role: 'unhide' }, { type: 'separator' }, { label: '退出', @@ -26,20 +24,20 @@ if (isMac) { label: '窗口', role: 'window', submenu: [ - { label: '最小化', role: 'minimize' }, + { label: '最小化', role: 'minimize', accelerator: 'Command+W' }, { label: '关闭', role: 'close' }, ], }, { label: '编辑', submenu: [ - { label: '撤销', accelerator: 'CmdOrCtrl+Z', role: 'undo' }, - { label: '恢复', accelerator: 'Shift+CmdOrCtrl+Z', role: 'redo' }, + { label: '撤销', accelerator: 'Command+Z', role: 'undo' }, + { label: '恢复', accelerator: 'Shift+Command+Z', role: 'redo' }, { type: 'separator' }, - { label: '剪切', accelerator: 'CmdOrCtrl+X', role: 'cut' }, - { label: '复制', accelerator: 'CmdOrCtrl+C', role: 'copy' }, - { label: '粘贴', accelerator: 'CmdOrCtrl+V', role: 'paste' }, - { label: '选择全部', accelerator: 'CmdOrCtrl+A', role: 'selectAll' }, + { label: '剪切', accelerator: 'Command+X', role: 'cut' }, + { label: '复制', accelerator: 'Command+C', role: 'copy' }, + { label: '粘贴', accelerator: 'Command+V', role: 'paste' }, + { label: '选择全部', accelerator: 'Command+A', role: 'selectAll' }, ], }, ] diff --git a/src/main/modules/winLyric/event.js b/src/main/modules/winLyric/event.js index 8507cc16..49912d91 100644 --- a/src/main/modules/winLyric/event.js +++ b/src/main/modules/winLyric/event.js @@ -5,8 +5,26 @@ const { desktop_lyric } = require('../../../common/hotKey') let isLock = null let isEnable = null let isAlwaysOnTop = null -const setLrcConfig = isForceSet => { +const setLrcConfig = () => { let desktopLyric = global.appSetting.desktopLyric + if (global.modules.lyricWindow) { + mainSend(global.modules.lyricWindow, ipcWinLyricNames.set_lyric_config, { + config: desktopLyric, + languageId: global.appSetting.langId, + }) + if (isLock != desktopLyric.isLock) { + isLock = desktopLyric.isLock + if (desktopLyric.isLock) { + global.modules.lyricWindow.setIgnoreMouseEvents(true, { forward: false }) + } else { + global.modules.lyricWindow.setIgnoreMouseEvents(false) + } + } + if (isAlwaysOnTop != desktopLyric.isAlwaysOnTop) { + isAlwaysOnTop = desktopLyric.isAlwaysOnTop + global.modules.lyricWindow.setAlwaysOnTop(desktopLyric.isAlwaysOnTop, 'screen-saver') + } + } if (isEnable != desktopLyric.enable) { isEnable = desktopLyric.enable if (desktopLyric.enable) { @@ -15,30 +33,12 @@ const setLrcConfig = isForceSet => { global.lx_event.winLyric.close() } } - if (global.modules.lyricWindow) { - mainSend(global.modules.lyricWindow, ipcWinLyricNames.set_lyric_config, { - config: desktopLyric, - languageId: global.appSetting.langId, - }) - if (isForceSet || isLock != desktopLyric.isLock) { - isLock = desktopLyric.isLock - if (desktopLyric.isLock) { - global.modules.lyricWindow.setIgnoreMouseEvents(true, { forward: false }) - } else { - global.modules.lyricWindow.setIgnoreMouseEvents(false) - } - } - if (isForceSet || isAlwaysOnTop != desktopLyric.isAlwaysOnTop) { - isAlwaysOnTop = desktopLyric.isAlwaysOnTop - global.modules.lyricWindow.setAlwaysOnTop(desktopLyric.isAlwaysOnTop, 'screen-saver') - } - } } global.lx_event.common.on(COMMON_EVENT_NAME.config, name => { if (WIN_LYRIC_EVENT_NAME.name === name) return setLrcConfig(false) }) -global.lx_event.winLyric.on(WIN_LYRIC_EVENT_NAME.inited, () => setLrcConfig(true)) +// 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.modules.lyricWindow) return diff --git a/src/main/modules/winLyric/index.js b/src/main/modules/winLyric/index.js index bb921d2f..e4bb13a9 100644 --- a/src/main/modules/winLyric/index.js +++ b/src/main/modules/winLyric/index.js @@ -61,14 +61,9 @@ const winEvent = lyricWindow => { lyricWindow.once('ready-to-show', () => { lyricWindow.show() - let config = global.appSetting.desktopLyric - global.modules.lyricWindow.setBounds({ - height: config.height, - width: config.width, - y: config.y, - x: config.x, - }) - global.lx_event.winLyric.inited() + if (global.appSetting.desktopLyric.isLock) { + global.modules.lyricWindow.setIgnoreMouseEvents(true, { forward: false }) + } }) }