Show Developer menu when running in dev only.
This commit is contained in:
parent
31905d6bb5
commit
c5cd9b42b1
@ -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 { 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
|
||||
if (process.env.ELECTRON_START_URL) {
|
||||
win.loadURL(process.env.ELECTRON_START_URL)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user