import { Menu } from 'electron' ; export function setMenu ( win , appname ) { const template = [ { label : 'Edit' , submenu : [ { role : 'undo' } , { role : 'redo' } , { type : 'separator' } , { role : 'cut' } , { role : 'copy' } , { role : 'paste' } , { role : 'pasteandmatchstyle' } , { role : 'delete' } , { role : 'selectall' } ] } , { role : 'window' , submenu : [ { role : 'minimize' } , { role : 'close' } ] } , { role : 'help' , submenu : [ { label : 'Toggle Developer Tools' , accelerator : process . platform === 'darwin' ? 'Alt+Command+I' : 'Ctrl+Shift+I' , click ( item , focusedWindow ) { if ( focusedWindow ) focusedWindow . webContents . toggleDevTools ( ) ; } } ] } ] ; if ( process . platform === 'darwin' ) { template . unshift ( { label : appname , submenu : [ { role : 'about' } , { type : 'separator' } , { role : 'services' , submenu : [ ] } , { type : 'separator' } , { role : 'hide' } , { role : 'hideothers' } , { role : 'unhide' } , { type : 'separator' } , { role : 'quit' } ] } ) ; template [ 2 ] . submenu = [ { label : 'Close' , accelerator : 'CmdOrCtrl+W' , role : 'close' } , { label : 'Minimize' , accelerator : 'CmdOrCtrl+M' , role : 'minimize' } , { label : 'Zoom' , role : 'zoom' } , { type : 'separator' } , { label : 'Bring All to Front' , role : 'front' } ] ; } ; const menu = Menu . buildFromTemplate ( template ) ; Menu . setApplicationMenu ( menu ) ; }