2023-02-26 01:30
This commit is contained in:
56
gepetto/main.js
Normal file
56
gepetto/main.js
Normal file
@@ -0,0 +1,56 @@
|
||||
const { app, BrowserWindow, Menu, MenuItem } = 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();
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user