From 7b9490e1103aed50adf53fd8bb700785c857231f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=BA=E6=9C=BD?= <107798151+lonelymeko@users.noreply.github.com> Date: Mon, 27 Oct 2025 16:05:32 +0800 Subject: [PATCH] fix(macOS): resolve tray-related issues and set tray minimization as default (#1449) * Add custom macOS-style title bar Introduces a custom MacOSTitleBar component for macOS, updates the Electron window to use 'hiddenInset' titleBarStyle, and adjusts App.vue to conditionally render the new title bar and add appropriate padding. This improves the native look and feel on macOS platforms. * Improve macOS Dock behavior and tray settings fix(macOS): resolve tray-related issues and set tray minimization as default 1. Fix the problem where the app couldn't be reopened after clicking the window's close button (red light) when "minimize to tray" was enabled. Ensured proper window visibility control via `mainWindow.show()` on Dock activation. 2. Resolve the issue where the app couldn't be closed from the Dock when "minimize to tray" was enabled. Added explicit quit state handling (`appIsQuitting = true`) in `before-quit` to bypass tray minimization logic during Dock-initiated quits. 3. Set "minimize to tray" as the default configuration for macOS to align with platform conventions. Implemented platform-specific default values in state initialization. These changes improve macOS compatibility by fixing critical tray interaction issues and aligning default behavior with native user expectations. --- src-electron/main.js | 7 +++++++ src/stores/settings/general.js | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src-electron/main.js b/src-electron/main.js index 281969e3..36da08c2 100644 --- a/src-electron/main.js +++ b/src-electron/main.js @@ -913,6 +913,11 @@ app.whenReady().then(() => { app.on('activate', function () { if (BrowserWindow.getAllWindows().length === 0) { createWindow(); + } else { + // Ensure main window shows when clicking Dock icon (critical for macOS) + if (mainWindow && !mainWindow.isVisible()) { + mainWindow.show(); + } } }); }); @@ -940,6 +945,8 @@ function disposeOverlay() { } app.on('before-quit', function () { + // Mark it as a quitting state to make macOS Dock's "Quit" action take effect. + appIsQuitting = true; disposeOverlay(); }); diff --git a/src/stores/settings/general.js b/src/stores/settings/general.js index b28d42ad..f46b4908 100644 --- a/src/stores/settings/general.js +++ b/src/stores/settings/general.js @@ -21,7 +21,7 @@ export const useGeneralSettingsStore = defineStore('GeneralSettings', () => { const isStartAtWindowsStartup = ref(false); const isStartAsMinimizedState = ref(false); const disableGpuAcceleration = ref(false); - const isCloseToTray = ref(false); + const isCloseToTray = ref(process.platform === 'darwin' ? true : false); const disableVrOverlayGpuAcceleration = ref(false); const localFavoriteFriendsGroups = ref([]); const udonExceptionLogging = ref(false);