30 lines
661 B
JavaScript
30 lines
661 B
JavaScript
const { app, BrowserWindow, ipcMain } = require('electron/main');
|
|
const path = require('node:path');
|
|
|
|
console.log('Hello from Electron 👋');
|
|
|
|
function createWindow() {
|
|
const win = new BrowserWindow({
|
|
width: 800,
|
|
height: 600,
|
|
webPreferences: {
|
|
preload: path.join(__dirname, 'preload.js'),
|
|
},
|
|
});
|
|
win.loadFile('index.html');
|
|
// or use ctrl+shift+i
|
|
win.webContents.openDevTools();
|
|
// win.loadURL('chrome://gpu');
|
|
}
|
|
|
|
app.whenReady().then(() => {
|
|
ipcMain.handle('ping', () => 'pong');
|
|
createWindow();
|
|
});
|
|
|
|
app.on('window-all-closed', () => {
|
|
// when not on mac
|
|
if (process.platform !== 'darwin') {
|
|
app.quit();
|
|
}
|
|
});
|