From 89af4316d312f37b2c18717b2c7f8de54d2a113f Mon Sep 17 00:00:00 2001 From: Tornike Khintibidze <48173186+X1nto@users.noreply.github.com> Date: Sun, 1 Oct 2023 00:43:27 +0400 Subject: [PATCH] Optimize the menu bar for macOS (#120) Co-authored-by: V --- .gitignore | 2 ++ src/main/mainWindow.ts | 44 +++++++++++++++++++++++++++++++++--------- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 6ee3e11..683ca39 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ dist node_modules .env +.DS_Store +.idea/ \ No newline at end of file diff --git a/src/main/mainWindow.ts b/src/main/mainWindow.ts index aab75de..57e53e8 100644 --- a/src/main/mainWindow.ts +++ b/src/main/mainWindow.ts @@ -147,6 +147,8 @@ async function clearData(win: BrowserWindow) { app.quit(); } +type MenuItemList = Array; + function initMenuBar(win: BrowserWindow) { const isWindows = process.platform === "win32"; const isDarwin = process.platform === "darwin"; @@ -181,14 +183,38 @@ function initMenuBar(win: BrowserWindow) { app.quit(); } }, - isDarwin && { - label: "Hide", - role: "hide" - }, - isDarwin && { - label: "Hide others", - role: "hideOthers" - }, + ...(!isDarwin + ? [] + : ([ + { + type: "separator" + }, + { + label: "Settings", + accelerator: "CmdOrCtrl+,", + async click() { + mainWin.webContents.executeJavaScript( + "Vencord.Webpack.Common.SettingsRouter.open('My Account')" + ); + } + }, + { + type: "separator" + }, + { + label: "Hide Vesktop", // Should probably remove the label, but it says "Hide VencordDesktop" instead of "Hide Vesktop" + role: "hide" + }, + { + role: "hideOthers" + }, + { + role: "unhide" + }, + { + type: "separator" + } + ] satisfies MenuItemList)), { label: "Quit", accelerator: wantCtrlQ ? "CmdOrCtrl+Q" : void 0, @@ -213,7 +239,7 @@ function initMenuBar(win: BrowserWindow) { role: "zoomIn", visible: false } - ] satisfies Array; + ] satisfies MenuItemList; const menu = Menu.buildFromTemplate([ {