const { app, BrowserWindow } = require('electron') const path = require('path') // add var for window let appWindow = null // add events app.on('ready', handleReady) app.on('activate', handleActivate) app.on('window-all-closed', handleAllClosed) /** * create window for app * * */ function handleReady() { // create window appWindow = new BrowserWindow({ frame: false, webPreferences: { nodeIntegration: true, nodeIntegrationInWorker: true, contextIsolation: false } }) // max size of window appWindow.maximize() appWindow.setMenu(null) // loading appWindow.loadURL('file://' + __dirname + '/dist/index.html') // add event if window closed appWindow.on('closed', handleClose) // @TODO only for appWindow.webContents.openDevTools() } /** * handle close window * */ function handleClose() { appWindow = null } /** * * */ function handleAllClosed() { if (process.platform !== 'darwin') { app.quit() } } /** * * */ function handleActivate() { if (appWindow === null) { createAppWindow() } }