← Volver
Crear menus en Electron
Publicado el 13 de diciembre de 2025
Electron
Definiri el menĂº en formato JSON:
let template = [
{
label: "File",
submenu: [
{
label: "Close",
click: onClose,
accelerator: "CmdOrCtrl+P",
},
],
},
{
label: "Help",
submenu: [
{
label: "About",
click: onAbout,
},
],
},
];
Setear el menĂº:
app.whenReady().then(() => {
const menu = Menu.buildFromTemplate(template);
Menu.setApplicationMenu(menu);
createWindow();
app.on("activate", function () {
// On macOS it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (BrowserWindow.getAllWindows().length === 0) createWindow();
});
});