54 lines
1.2 KiB
JavaScript
54 lines
1.2 KiB
JavaScript
const { app, BrowserWindow, Menu } = require('electron');
|
|
|
|
function createWindow() {
|
|
let win = new BrowserWindow({
|
|
width: 800,
|
|
height: 600,
|
|
webPreferences: {
|
|
nodeIntegration: true
|
|
}
|
|
});
|
|
|
|
createMenu();
|
|
|
|
win.loadFile('index.html');
|
|
|
|
win.webContents.openDevTools();
|
|
|
|
}
|
|
|
|
function createMenu() {
|
|
const menu = [
|
|
{
|
|
label: 'File',
|
|
submenu: [
|
|
{ label: 'Exit', role: 'quit' }
|
|
]
|
|
},
|
|
{
|
|
label: 'Edit',
|
|
submenu: [
|
|
{ label: 'Copy', role: 'copy' },
|
|
{ label: 'Cut', role: 'cut' },
|
|
{ label: 'Paste', role: 'paste' },
|
|
{ type: 'separator' },
|
|
{ label: 'Undo', role: 'undo' },
|
|
{ label: 'Redo', role: 'redo' },
|
|
]
|
|
}
|
|
];
|
|
|
|
Menu.setApplicationMenu(Menu.buildFromTemplate(menu));
|
|
}
|
|
|
|
app.whenReady().then(createWindow);
|
|
app.on('window-all-closed', () => {
|
|
if (process.platform !== 'darwin') {
|
|
app.quit();
|
|
}
|
|
});
|
|
app.on('activate', () => {
|
|
if (BrowserWindow.getAllWindows().length === 0) {
|
|
createWindow();
|
|
}
|
|
}); |