set Application menu for mac support

This commit is contained in:
Abhinav-grd 2021-07-09 19:49:21 +05:30
parent 3f15dbaea3
commit 3184e8882f

View file

@ -40,7 +40,6 @@ function createWindow() {
icon: appIcon, icon: appIcon,
show: false, // don't show the main window show: false, // don't show the main window
}); });
mainWindow.setMenu(buildMenuBar());
const splash = new BrowserWindow({ const splash = new BrowserWindow({
frame: false, frame: false,
alwaysOnTop: true, alwaysOnTop: true,
@ -90,6 +89,7 @@ app.on('ready', () => {
if (!isDev) { if (!isDev) {
autoUpdater.checkForUpdatesAndNotify(); autoUpdater.checkForUpdatesAndNotify();
} }
Menu.setApplicationMenu(buildMenuBar())
mainWindow = createWindow(); mainWindow = createWindow();
app.on('activate', function () { app.on('activate', function () {
@ -200,6 +200,7 @@ function buildContextMenu(args: any = {}) {
} }
function buildMenuBar() { function buildMenuBar() {
const name = app.getName();
return Menu.buildFromTemplate([ return Menu.buildFromTemplate([
{ {
label: ' ', label: ' ',
@ -208,6 +209,20 @@ function buildMenuBar() {
mainWindow.reload(); mainWindow.reload();
}, },
}, },
...(process.platform === 'darwin' && [{
label: name,
submenu: Menu.buildFromTemplate([
{
label: 'About ' + name,
role: 'about'
},
{
label: 'Quit',
accelerator: 'Command+Q',
click() { app.quit(); }
},
])
}]),
{ {
label: 'help', label: 'help',
submenu: Menu.buildFromTemplate([ submenu: Menu.buildFromTemplate([