32a9df2940
* Disable nodeIntegration * Enable contextIsolation * Re-implement the CSP security check to handle running in contextIsolation * Disable bad DCHECKS for the promise helper * Remove the unused "-d" flag for the electron binary * Added a way to hide the default help output for electron devs who don't want to see it every time
194 lines
3.2 KiB
JavaScript
194 lines
3.2 KiB
JavaScript
const { shell, Menu } = require('electron')
|
|
|
|
const setDefaultApplicationMenu = () => {
|
|
if (Menu.getApplicationMenu()) return
|
|
|
|
const template = [
|
|
{
|
|
label: 'Edit',
|
|
submenu: [
|
|
{
|
|
role: 'undo'
|
|
},
|
|
{
|
|
role: 'redo'
|
|
},
|
|
{
|
|
type: 'separator'
|
|
},
|
|
{
|
|
role: 'cut'
|
|
},
|
|
{
|
|
role: 'copy'
|
|
},
|
|
{
|
|
role: 'paste'
|
|
},
|
|
{
|
|
role: 'pasteandmatchstyle'
|
|
},
|
|
{
|
|
role: 'delete'
|
|
},
|
|
{
|
|
role: 'selectall'
|
|
}
|
|
]
|
|
},
|
|
{
|
|
label: 'View',
|
|
submenu: [
|
|
{
|
|
role: 'reload'
|
|
},
|
|
{
|
|
role: 'forcereload'
|
|
},
|
|
{
|
|
role: 'toggledevtools'
|
|
},
|
|
{
|
|
type: 'separator'
|
|
},
|
|
{
|
|
role: 'resetzoom'
|
|
},
|
|
{
|
|
role: 'zoomin'
|
|
},
|
|
{
|
|
role: 'zoomout'
|
|
},
|
|
{
|
|
type: 'separator'
|
|
},
|
|
{
|
|
role: 'togglefullscreen'
|
|
}
|
|
]
|
|
},
|
|
{
|
|
role: 'window',
|
|
submenu: [
|
|
{
|
|
role: 'minimize'
|
|
},
|
|
{
|
|
role: 'close'
|
|
}
|
|
]
|
|
},
|
|
{
|
|
role: 'help',
|
|
submenu: [
|
|
{
|
|
label: 'Learn More',
|
|
click () {
|
|
shell.openExternal('https://electronjs.org')
|
|
}
|
|
},
|
|
{
|
|
label: 'Documentation',
|
|
click () {
|
|
shell.openExternal(
|
|
`https://github.com/electron/electron/tree/v${process.versions.electron}/docs#readme`
|
|
)
|
|
}
|
|
},
|
|
{
|
|
label: 'Community Discussions',
|
|
click () {
|
|
shell.openExternal('https://discuss.atom.io/c/electron')
|
|
}
|
|
},
|
|
{
|
|
label: 'Search Issues',
|
|
click () {
|
|
shell.openExternal('https://github.com/electron/electron/issues')
|
|
}
|
|
}
|
|
]
|
|
}
|
|
]
|
|
|
|
if (process.platform === 'darwin') {
|
|
template.unshift({
|
|
label: 'Electron',
|
|
submenu: [
|
|
{
|
|
role: 'about'
|
|
},
|
|
{
|
|
type: 'separator'
|
|
},
|
|
{
|
|
role: 'services',
|
|
submenu: []
|
|
},
|
|
{
|
|
type: 'separator'
|
|
},
|
|
{
|
|
role: 'hide'
|
|
},
|
|
{
|
|
role: 'hideothers'
|
|
},
|
|
{
|
|
role: 'unhide'
|
|
},
|
|
{
|
|
type: 'separator'
|
|
},
|
|
{
|
|
role: 'quit'
|
|
}
|
|
]
|
|
})
|
|
template[1].submenu.push({
|
|
type: 'separator'
|
|
}, {
|
|
label: 'Speech',
|
|
submenu: [
|
|
{
|
|
role: 'startspeaking'
|
|
},
|
|
{
|
|
role: 'stopspeaking'
|
|
}
|
|
]
|
|
})
|
|
template[3].submenu = [
|
|
{
|
|
role: 'close'
|
|
},
|
|
{
|
|
role: 'minimize'
|
|
},
|
|
{
|
|
role: 'zoom'
|
|
},
|
|
{
|
|
type: 'separator'
|
|
},
|
|
{
|
|
role: 'front'
|
|
}
|
|
]
|
|
} else {
|
|
template.unshift({
|
|
label: 'File',
|
|
submenu: [{
|
|
role: 'quit'
|
|
}]
|
|
})
|
|
}
|
|
|
|
const menu = Menu.buildFromTemplate(template)
|
|
Menu.setApplicationMenu(menu)
|
|
}
|
|
|
|
module.exports = {
|
|
setDefaultApplicationMenu
|
|
}
|