Skip to content

Commit

Permalink
Add default menu items back. (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
robinjhuang authored Oct 16, 2024
1 parent 5cc5625 commit 98f6b99
Showing 1 changed file with 29 additions and 48 deletions.
77 changes: 29 additions & 48 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,53 +236,35 @@ function restartApp() {
app.quit();
}

function buildMenu(): Menu {
const isMac = process.platform === 'darwin';

const menu = new Menu();

if (isMac) {
menu.append(
new MenuItem({
label: app.name,
submenu: [
{ role: 'about' },
{ type: 'separator' },
{ role: 'services' },
{ type: 'separator' },
{ role: 'hide' },
{ role: 'hideOthers' },
{ role: 'unhide' },
{ type: 'separator' },
{ role: 'quit' },
],
})
);
}

if (!isMac) {
menu.append(
new MenuItem({
label: 'File',
submenu: [{ role: 'quit' }],
})
);
menu.append(
new MenuItem({
label: 'About',
click: () => {
dialog.showMessageBox({
title: 'About',
message: `ComfyUI v${app.getVersion()}`,
detail: 'Created by Comfy Org\nCopyright © 2024',
buttons: ['OK'],
});
},
})
);
function buildMenu(): void {
const menu = Menu.getApplicationMenu();
if (menu) {
const aboutMenuItem = {
label: 'About ComfyUI',
click: () => {
dialog.showMessageBox({
title: 'About',
message: `ComfyUI v${app.getVersion()}`,
detail: 'Created by Comfy Org\nCopyright © 2024',
buttons: ['OK'],
});
},
};
const helpMenuItem = menu.items.find((item) => item.role === 'help');
if (helpMenuItem && helpMenuItem.submenu) {
helpMenuItem.submenu.append(new MenuItem(aboutMenuItem));
Menu.setApplicationMenu(menu);
} else {
// If there's no Help menu, add one
menu.append(
new MenuItem({
label: 'Help',
submenu: [aboutMenuItem],
})
);
Menu.setApplicationMenu(menu);
}
}

return menu;
}

/**
Expand Down Expand Up @@ -342,8 +324,7 @@ export const createWindow = async (userResourcesPath?: string): Promise<BrowserW
mainWindow = null;
});

const menu = buildMenu();
Menu.setApplicationMenu(menu);
buildMenu();

return mainWindow;
};
Expand Down

0 comments on commit 98f6b99

Please sign in to comment.