From a51b2cd333acb0f64bc33b40551c06010b170189 Mon Sep 17 00:00:00 2001 From: Xinto Date: Fri, 22 Sep 2023 23:09:55 +0400 Subject: [PATCH 1/5] optimize the menu bar for macOS --- .gitignore | 2 ++ src/main/mainWindow.ts | 23 +++++++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 6ee3e115..683ca39e 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 aab75dee..313982d0 100644 --- a/src/main/mainWindow.ts +++ b/src/main/mainWindow.ts @@ -28,6 +28,7 @@ import { Settings, VencordSettings } from "./settings"; import { createSplashWindow } from "./splash"; import { makeLinksOpenExternally } from "./utils/makeLinksOpenExternally"; import { downloadVencordFiles, ensureVencordFiles } from "./utils/vencordLoader"; +import { SettingsRouter } from "@vencord/types/webpack/common"; let isQuitting = false; let tray: Tray; @@ -182,13 +183,31 @@ function initMenuBar(win: BrowserWindow) { } }, isDarwin && { - label: "Hide", + type: "separator" + }, + isDarwin && { + label: "Settings", + accelerator: "CmdOrCtrl+,", + async click() { + mainWin.webContents.executeJavaScript("Vencord.Webpack.Common.SettingsRouter.open()") + } + }, + isDarwin && { + type: "separator" + }, + isDarwin && { + label: "Hide Vesktop", role: "hide" }, isDarwin && { - label: "Hide others", role: "hideOthers" }, + isDarwin && { + role: "unhide", + }, + isDarwin && { + type: "separator" + }, { label: "Quit", accelerator: wantCtrlQ ? "CmdOrCtrl+Q" : void 0, From 376866bb17c1ce4cab287d83d6340fc1fb9044a4 Mon Sep 17 00:00:00 2001 From: Xinto Date: Fri, 22 Sep 2023 23:14:11 +0400 Subject: [PATCH 2/5] add a small comment --- src/main/mainWindow.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/mainWindow.ts b/src/main/mainWindow.ts index 313982d0..c1333ea3 100644 --- a/src/main/mainWindow.ts +++ b/src/main/mainWindow.ts @@ -28,7 +28,6 @@ import { Settings, VencordSettings } from "./settings"; import { createSplashWindow } from "./splash"; import { makeLinksOpenExternally } from "./utils/makeLinksOpenExternally"; import { downloadVencordFiles, ensureVencordFiles } from "./utils/vencordLoader"; -import { SettingsRouter } from "@vencord/types/webpack/common"; let isQuitting = false; let tray: Tray; @@ -196,7 +195,7 @@ function initMenuBar(win: BrowserWindow) { type: "separator" }, isDarwin && { - label: "Hide Vesktop", + label: "Hide Vesktop", //Should probably remove the label, but it says "Hide VencordDesktop" instead of "Hide Vesktop" role: "hide" }, isDarwin && { From 7d8b3469856cf6394f31508130af9dc3a949a7c3 Mon Sep 17 00:00:00 2001 From: Xinto Date: Sat, 23 Sep 2023 00:51:40 +0400 Subject: [PATCH 3/5] group darwin-specific menus --- src/main/mainWindow.ts | 56 ++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/src/main/mainWindow.ts b/src/main/mainWindow.ts index c1333ea3..339a4d4b 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,32 +183,34 @@ function initMenuBar(win: BrowserWindow) { app.quit(); } }, - isDarwin && { - type: "separator" - }, - isDarwin && { - label: "Settings", - accelerator: "CmdOrCtrl+,", - async click() { - mainWin.webContents.executeJavaScript("Vencord.Webpack.Common.SettingsRouter.open()") + ...(!isDarwin ? [] : [ + { + type: "separator" + }, + { + label: "Settings", + accelerator: "CmdOrCtrl+,", + async click() { + mainWin.webContents.executeJavaScript("Vencord.Webpack.Common.SettingsRouter.open()") + } + }, + { + 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" } - }, - isDarwin && { - type: "separator" - }, - isDarwin && { - label: "Hide Vesktop", //Should probably remove the label, but it says "Hide VencordDesktop" instead of "Hide Vesktop" - role: "hide" - }, - isDarwin && { - role: "hideOthers" - }, - isDarwin && { - role: "unhide", - }, - isDarwin && { - type: "separator" - }, + ] satisfies MenuItemList), { label: "Quit", accelerator: wantCtrlQ ? "CmdOrCtrl+Q" : void 0, @@ -231,7 +235,7 @@ function initMenuBar(win: BrowserWindow) { role: "zoomIn", visible: false } - ] satisfies Array; + ] satisfies MenuItemList; const menu = Menu.buildFromTemplate([ { From d198fbb4108d260ed1df7c5aad43ee691d083fed Mon Sep 17 00:00:00 2001 From: Tornike Khintibidze <48173186+X1nto@users.noreply.github.com> Date: Mon, 25 Sep 2023 07:44:15 +0400 Subject: [PATCH 4/5] Apply suggestions from code review fix the settings navigation code Co-authored-by: V --- src/main/mainWindow.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/mainWindow.ts b/src/main/mainWindow.ts index 339a4d4b..633496df 100644 --- a/src/main/mainWindow.ts +++ b/src/main/mainWindow.ts @@ -191,7 +191,7 @@ function initMenuBar(win: BrowserWindow) { label: "Settings", accelerator: "CmdOrCtrl+,", async click() { - mainWin.webContents.executeJavaScript("Vencord.Webpack.Common.SettingsRouter.open()") + mainWin.webContents.executeJavaScript("Vencord.Webpack.Common.SettingsRouter.open('My Account')") } }, { From 4058eeb1f9bdcf32856b7692eb67d84707de3887 Mon Sep 17 00:00:00 2001 From: Xinto Date: Tue, 26 Sep 2023 15:19:59 +0400 Subject: [PATCH 5/5] satisfy eslint --- src/main/mainWindow.ts | 60 ++++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 28 deletions(-) diff --git a/src/main/mainWindow.ts b/src/main/mainWindow.ts index 633496df..57e53e89 100644 --- a/src/main/mainWindow.ts +++ b/src/main/mainWindow.ts @@ -183,34 +183,38 @@ function initMenuBar(win: BrowserWindow) { app.quit(); } }, - ...(!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), + ...(!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,