44 lines
859 B
JavaScript
44 lines
859 B
JavaScript
console.log('Hello world')
|
|
|
|
const { app, BrowserWindow, ipcMain } = require('electron')
|
|
const path = require('node:path')
|
|
|
|
app.on('window-all-closed', windowsClosed)
|
|
app.whenReady().then(appReady)
|
|
|
|
function createWindow() {
|
|
const win = new BrowserWindow({
|
|
width: 400,
|
|
height: 600,
|
|
webPreferences: {
|
|
preload: path.join(__dirname, 'preload.js')
|
|
}
|
|
})
|
|
|
|
win.loadFile('index.html')
|
|
}
|
|
|
|
function appReady() {
|
|
createWindow()
|
|
|
|
// MacOS window activation stuffs (??) (idk I don't use Apple products)
|
|
app.on('activate', () => {
|
|
if (BrowserWindow.getAllWindows().length === 0) {
|
|
createWindow()
|
|
}
|
|
})
|
|
|
|
ipcMain.on('log', ipcLog)
|
|
}
|
|
|
|
function windowsClosed() {
|
|
// Windows and Linux need to call app.quit manually
|
|
// otherwise process will not exit
|
|
if (process.platform !== 'darwin') app.quit()
|
|
}
|
|
|
|
function ipcLog(event, msg) {
|
|
console.log(msg)
|
|
}
|
|
|