feat(desktop): add native menu bar with standard Edit/View/Window roles

This commit is contained in:
CREDO23 2026-03-18 20:10:30 +02:00
parent a0e57562e0
commit 9b4d9f0da2

View file

@ -1,4 +1,4 @@
import { app, BrowserWindow, shell, ipcMain, session, dialog, clipboard } from 'electron'; import { app, BrowserWindow, shell, ipcMain, session, dialog, clipboard, Menu } from 'electron';
import path from 'path'; import path from 'path';
import { getPort } from 'get-port-please'; import { getPort } from 'get-port-please';
@ -203,8 +203,21 @@ if (process.defaultApp) {
app.setAsDefaultProtocolClient(PROTOCOL); app.setAsDefaultProtocolClient(PROTOCOL);
} }
function setupMenu() {
const isMac = process.platform === 'darwin';
const template: Electron.MenuItemConstructorOptions[] = [
...(isMac ? [{ role: 'appMenu' as const }] : []),
{ role: 'fileMenu' as const },
{ role: 'editMenu' as const },
{ role: 'viewMenu' as const },
{ role: 'windowMenu' as const },
];
Menu.setApplicationMenu(Menu.buildFromTemplate(template));
}
// App lifecycle // App lifecycle
app.whenReady().then(async () => { app.whenReady().then(async () => {
setupMenu();
try { try {
await startNextServer(); await startNextServer();
} catch (error) { } catch (error) {