feat: reuse built-in menus in system menubar (#12)

* fix: add edit menu on macOS to allow clipboard actions

* feat: reuse more built-in menus

* re-add zoom shortcut fix

---------

Co-authored-by: V <vendicated@riseup.net>
This commit is contained in:
Ryan Cao 2023-04-15 18:37:52 +08:00 committed by GitHub
parent 70dd38f79d
commit 583680d311
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -84,9 +84,11 @@ function initMenuBar(win: BrowserWindow) {
const menu = Menu.buildFromTemplate([
{
label: "Vencord Desktop",
role: "appMenu",
submenu: [
{
label: "About Vencord Desktop",
role: "about",
click: createAboutWindow
},
{
@ -98,28 +100,6 @@ function initMenuBar(win: BrowserWindow) {
},
toolTip: "Vencord Desktop will automatically restart after this operation"
},
{
label: "Toggle Developer Tools",
accelerator: "CmdOrCtrl+Shift+I",
click() {
BrowserWindow.getFocusedWindow()!.webContents.toggleDevTools();
}
},
{
label: "Toggle Developer Tools (Hidden)",
accelerator: "F12",
visible: false,
click() {
BrowserWindow.getFocusedWindow()!.webContents.toggleDevTools();
}
},
{
label: "Reload Window",
accelerator: "CmdOrCtrl+R",
click() {
BrowserWindow.getFocusedWindow()!.webContents.reload();
}
},
{
label: "Relaunch",
accelerator: "CmdOrCtrl+Shift+R",
@ -132,6 +112,7 @@ function initMenuBar(win: BrowserWindow) {
label: "Quit",
accelerator: wantCtrlQ ? "CmdOrCtrl+Q" : void 0,
visible: !isWindows,
role: "quit",
click() {
app.quit();
}
@ -140,34 +121,28 @@ function initMenuBar(win: BrowserWindow) {
label: "Quit",
accelerator: isWindows ? "Alt+F4" : void 0,
visible: isWindows,
role: "quit",
click() {
app.quit();
}
}
]
},
{ role: "fileMenu" },
{ role: "editMenu" },
{ role: "viewMenu" },
{ role: "windowMenu" },
{
label: "Zoom",
submenu: [
{
label: "Zoom in",
accelerator: "CmdOrCtrl+Plus",
role: "zoomIn"
},
// Fix for zoom in on keyboards with dedicated + like QWERTZ (or numpad)
// See https://github.com/electron/electron/issues/14742 and https://github.com/electron/electron/issues/5256
{
label: "Zoom in",
accelerator: "CmdOrCtrl+=",
role: "zoomIn",
visible: false
},
{
label: "Zoom out",
accelerator: "CmdOrCtrl+-",
role: "zoomOut"
role: "zoomIn"
}
]
],
visible: false
}
]);