From 255b38c41cb1e741745001425573c80b4febb69a Mon Sep 17 00:00:00 2001 From: redtrillix Date: Tue, 6 Dec 2022 10:59:23 +0800 Subject: [PATCH] Update index.js Signed-off-by: redtrillix --- index.js | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index 49cd500..f049b10 100644 --- a/index.js +++ b/index.js @@ -1,12 +1,33 @@ -const { app, BrowserWindow } = require("electron"); +const { app, BrowserWindow } = require('electron'); -app.whenReady().then(createWindow); +let mainWindow; function createWindow() { - const win = new BrowserWindow({ - width: 190, - height: 80, - resizable: false, + mainWindow = new BrowserWindow({ + width: 800, + height: 600, + webPreferences: { + nodeIntegration: true + } }); - win.loadFile("index.html"); -} \ No newline at end of file + + mainWindow.loadFile('index.html'); + + mainWindow.on('closed', function() { + mainWindow = null; + }); +} + +app.on('ready', createWindow); + +app.on('window-all-closed', function() { + if (process.platform !== 'darwin') { + app.quit(); + } +}); + +app.on('activate', function() { + if (mainWindow === null) { + createWindow(); + } +});