Show Developer menu when running in dev only.

This commit is contained in:
Tom Butcher 2025-08-23 22:30:33 +01:00
parent 31905d6bb5
commit c5cd9b42b1

View File

@ -1,4 +1,4 @@
import { app, BrowserWindow, ipcMain, shell } from 'electron' import { app, BrowserWindow, ipcMain, shell, Menu } from 'electron'
import path, { dirname } from 'path' import path, { dirname } from 'path'
import { fileURLToPath } from 'url' import { fileURLToPath } from 'url'
@ -22,6 +22,30 @@ function createWindow() {
} }
}) })
// Set up custom menu bar
const env = (process.env.NODE_ENV || 'development').trim()
if (env === 'development') {
const devMenu = [
{
label: 'Developer',
submenu: [
{
label: 'Toggle Developer Tools',
accelerator:
process.platform === 'darwin' ? 'Alt+Command+I' : 'Ctrl+Shift+I',
click: () => {
win.webContents.toggleDevTools()
}
}
]
}
]
const menu = Menu.buildFromTemplate(devMenu)
Menu.setApplicationMenu(menu)
} else {
Menu.setApplicationMenu(null)
}
// For development, load from localhost; for production, load the built index.html // For development, load from localhost; for production, load the built index.html
if (process.env.ELECTRON_START_URL) { if (process.env.ELECTRON_START_URL) {
win.loadURL(process.env.ELECTRON_START_URL) win.loadURL(process.env.ELECTRON_START_URL)