From f8a0544cebf375fe5f336817490d79bf91e4a8e5 Mon Sep 17 00:00:00 2001 From: Damien Erambert Date: Sat, 25 Jul 2026 12:40:22 -0700 Subject: [PATCH] Add a Window menu item that re-opens main window on Mac (#2269) * Add a Window menu item that re-opens main window on Mac * only rebuild menu on macos --- src/main/index.ts | 10 ++++++++++ src/main/menu.ts | 20 +++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/main/index.ts b/src/main/index.ts index 6da74f9e1..e91cb3449 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -772,6 +772,16 @@ async function createWindow(first = true): Promise { mainWindow = null; }); + if (isMacOS()) { + mainWindow.on('show', () => { + rebuildMainMenu(); + }); + + mainWindow.on('hide', () => { + rebuildMainMenu(); + }); + } + mainWindow.on('close', (event) => { store.set('bounds', mainWindow?.getNormalBounds()); store.set('maximized', mainWindow?.isMaximized()); diff --git a/src/main/menu.ts b/src/main/menu.ts index 65bb7c6d3..f304a1e49 100644 --- a/src/main/menu.ts +++ b/src/main/menu.ts @@ -2,6 +2,7 @@ import { BrowserWindow, Menu, MenuItemConstructorOptions, shell } from 'electron import packageJson from '../../package.json'; +import { store } from '/@/main/features/core/settings'; import { PlayerRepeat, PlayerStatus } from '/@/shared/types/types'; export type MenuPlaybackState = { @@ -173,7 +174,24 @@ export default class MenuBuilder { }, ], }; - const subMenuWindow: MenuItemConstructorOptions = { role: 'windowMenu' }; + const subMenuWindow: MenuItemConstructorOptions = { + role: 'windowMenu', + submenu: + store.get('window_exit_to_tray') && !this.mainWindow.isVisible() + ? [ + { + type: 'separator', + }, + { + accelerator: 'CmdOrCtrl+0', + click: () => { + this.mainWindow.show(); + }, + label: 'Feishin', + }, + ] + : undefined, + }; const subMenuPlayback: MenuItemConstructorOptions = { label: 'Playback', submenu: [