修复 MacOS 下点击 dock 右键菜单的退出按钮时,程序没有退出的问题(#1923)
parent
b7bb21f091
commit
69ba619f24
|
@ -5,7 +5,7 @@ import { URL_SCHEME_RXP } from '@common/constants'
|
|||
import { getTheme, initHotKey, initSetting, parseEnvParams } from './utils'
|
||||
import { navigationUrlWhiteList } from '@common/config'
|
||||
import defaultSetting from '@common/defaultSetting'
|
||||
import { closeWindow, isExistWindow as isExistMainWindow, showWindow as showMainWindow } from './modules/winMain'
|
||||
import { isExistWindow as isExistMainWindow, showWindow as showMainWindow } from './modules/winMain'
|
||||
import { createAppEvent, createDislikeEvent, createListEvent } from '@main/event'
|
||||
import { isMac, log } from '@common/utils'
|
||||
import createWorkers from './worker'
|
||||
|
@ -158,6 +158,9 @@ export const listenerAppEvent = (startApp: () => void) => {
|
|||
}
|
||||
})
|
||||
|
||||
app.on('before-quit', () => {
|
||||
global.lx.isSkipTrayQuit = true
|
||||
})
|
||||
app.on('window-all-closed', () => {
|
||||
if (isMac) return
|
||||
|
||||
|
@ -209,7 +212,6 @@ export const initAppSetting = async() => {
|
|||
if (!global.lx) {
|
||||
const config = await initHotKey()
|
||||
global.lx = {
|
||||
isTrafficLightClose: false,
|
||||
isSkipTrayQuit: false,
|
||||
// mainWindowClosed: true,
|
||||
event_app: createAppEvent(),
|
||||
|
@ -275,5 +277,5 @@ export const initAppSetting = async() => {
|
|||
|
||||
export const quitApp = () => {
|
||||
global.lx.isSkipTrayQuit = true
|
||||
closeWindow()
|
||||
app.quit()
|
||||
}
|
||||
|
|
|
@ -13,19 +13,15 @@ const winEvent = () => {
|
|||
if (!browserWindow) return
|
||||
|
||||
browserWindow.on('close', event => {
|
||||
if (
|
||||
global.lx.appSetting['tray.enable'] &&
|
||||
(global.lx.isTrafficLightClose || (isWin && !global.lx.isSkipTrayQuit))
|
||||
) {
|
||||
global.lx.isTrafficLightClose &&= false
|
||||
event.preventDefault()
|
||||
browserWindow!.hide()
|
||||
if (global.lx.isSkipTrayQuit || !global.lx.appSetting['tray.enable']) {
|
||||
browserWindow!.setProgressBar(-1)
|
||||
// global.lx.mainWindowClosed = true
|
||||
global.lx.event_app.main_window_close()
|
||||
return
|
||||
}
|
||||
|
||||
browserWindow!.setProgressBar(-1)
|
||||
// global.lx.mainWindowClosed = true
|
||||
global.lx.event_app.main_window_close()
|
||||
event.preventDefault()
|
||||
browserWindow!.hide()
|
||||
})
|
||||
|
||||
browserWindow.on('closed', () => {
|
||||
|
|
|
@ -61,7 +61,6 @@ export default () => {
|
|||
app.exit(0)
|
||||
return
|
||||
}
|
||||
global.lx.isTrafficLightClose = true
|
||||
closeWindow()
|
||||
})
|
||||
// 全屏
|
||||
|
|
|
@ -11,10 +11,6 @@ interface Lx {
|
|||
config: LX.HotKeyConfigAll
|
||||
state: LX.HotKeyState
|
||||
}
|
||||
/**
|
||||
* 是否红绿灯关闭
|
||||
*/
|
||||
isTrafficLightClose: boolean
|
||||
/**
|
||||
* 是否跳过托盘退出
|
||||
*/
|
||||
|
|
|
@ -94,7 +94,10 @@ export default {
|
|||
}, 2e3)
|
||||
},
|
||||
handleClose(isExit) {
|
||||
if (isExit) { quitApp(true); return }
|
||||
if (isExit) {
|
||||
quitApp(true)
|
||||
return
|
||||
}
|
||||
isShowPact.value = false
|
||||
},
|
||||
openUrl(url) {
|
||||
|
|
Loading…
Reference in New Issue