优化逻辑

pull/277/head
lyswhut 2020-06-24 22:55:47 +08:00
parent 69368b884f
commit 93bab6bbdd
3 changed files with 30 additions and 37 deletions

View File

@ -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' },
],
},
]

View File

@ -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

View File

@ -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 })
}
})
}