From ff28d089ba6ee36fb2e19b98c664420563110661 Mon Sep 17 00:00:00 2001 From: Maciej Gomola Date: Fri, 18 Oct 2024 19:57:13 +0200 Subject: [PATCH] Migrate to ESM and fix window sizing on Windows --- index.js | 28 +++++++++++++++------------- package.json | 1 + 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/index.js b/index.js index 83c31e6..512e0bc 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,17 @@ -const { app, BrowserWindow } = require('electron'); +import { app, BrowserWindow } from 'electron'; + +// A helper function for creating the window +const createWindow = () => { + const win = new BrowserWindow({ + width: 290, + height: 465, + resizable: false, + autoHideMenuBar: true, + useContentSize: true, + }); + + win.loadFile('static/index.html'); +}; app.whenReady().then(() => { createWindow(); @@ -13,15 +26,4 @@ app.whenReady().then(() => { // If all windows are closed and we're not running macOS, quit the app. app.on('window-all-closed', () => { if (process.platform !== 'darwin') app.quit(); -}); - -function createWindow() { - const win = new BrowserWindow({ - width: 280, - height: 485, - resizable: false, - autoHideMenuBar: true, - }); - - win.loadFile('static/index.html'); -} \ No newline at end of file +}); \ No newline at end of file diff --git a/package.json b/package.json index 802a6eb..b018ef0 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "1.0.0", "description": "Prosty kalkulator w Electronie", "main": "index.js", + "type": "module", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "start": "electron ."