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: [