From 69ba619f246cd38ac16345443ba51fb54e30d56d Mon Sep 17 00:00:00 2001 From: lyswhut Date: Mon, 3 Jun 2024 18:29:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20MacOS=20=E4=B8=8B=E7=82=B9?= =?UTF-8?q?=E5=87=BB=20dock=20=E5=8F=B3=E9=94=AE=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E7=9A=84=E9=80=80=E5=87=BA=E6=8C=89=E9=92=AE=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E6=B2=A1=E6=9C=89=E9=80=80=E5=87=BA=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=EF=BC=88#1923=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/app.ts | 8 +++++--- src/main/modules/winMain/main.ts | 16 ++++++---------- src/main/modules/winMain/rendererEvent/app.ts | 1 - src/main/types/app.d.ts | 4 ---- src/renderer/components/layout/PactModal.vue | 5 ++++- 5 files changed, 15 insertions(+), 19 deletions(-) diff --git a/src/main/app.ts b/src/main/app.ts index 512e7b4a..9cfd4fd8 100644 --- a/src/main/app.ts +++ b/src/main/app.ts @@ -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() } diff --git a/src/main/modules/winMain/main.ts b/src/main/modules/winMain/main.ts index ef8ef170..35aa651e 100644 --- a/src/main/modules/winMain/main.ts +++ b/src/main/modules/winMain/main.ts @@ -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', () => { diff --git a/src/main/modules/winMain/rendererEvent/app.ts b/src/main/modules/winMain/rendererEvent/app.ts index 2e6b5574..677f5a11 100644 --- a/src/main/modules/winMain/rendererEvent/app.ts +++ b/src/main/modules/winMain/rendererEvent/app.ts @@ -61,7 +61,6 @@ export default () => { app.exit(0) return } - global.lx.isTrafficLightClose = true closeWindow() }) // 全屏 diff --git a/src/main/types/app.d.ts b/src/main/types/app.d.ts index 2b3b316a..c661a2d6 100644 --- a/src/main/types/app.d.ts +++ b/src/main/types/app.d.ts @@ -11,10 +11,6 @@ interface Lx { config: LX.HotKeyConfigAll state: LX.HotKeyState } - /** - * 是否红绿灯关闭 - */ - isTrafficLightClose: boolean /** * 是否跳过托盘退出 */ diff --git a/src/renderer/components/layout/PactModal.vue b/src/renderer/components/layout/PactModal.vue index 4f4ae918..5af7758e 100644 --- a/src/renderer/components/layout/PactModal.vue +++ b/src/renderer/components/layout/PactModal.vue @@ -94,7 +94,10 @@ export default { }, 2e3) }, handleClose(isExit) { - if (isExit) { quitApp(true); return } + if (isExit) { + quitApp(true) + return + } isShowPact.value = false }, openUrl(url) {