在生产过程中,似乎没有将默认菜单添加到应用程序中。
解决方案是检查您是否正在开发:
https://www.npmjs.com/package/electron-is-dev
// Check if we are in development
var isDev = require('electron-is-dev');
如果在生产中,您必须从头开始构建菜单。
if(isDev){
// In development
// modify existing menu
}else{
// In production
// construct menu from scratch
var template = [
{
label: "File",
submenu: [
{
label: "Exit",
click: function () { quit(); }
}
]
},
{
label: "Project",
submenu: [
{
label: "Delete",
click: function () { deleteProject(); }
},
{
label: "Build",
click: function () { buildProject(); }
}
]
}
];
// build menu from template
var menu = Menu.buildFromTemplate(template);
// set menu for main window
mainWindow.setMenu(menu);
};