From d1b7148b657ce6e893de2f1dde13714833e30536 Mon Sep 17 00:00:00 2001
From: BLCK <123077751+BLCK-B@users.noreply.github.com>
Date: Sun, 3 Nov 2024 16:16:53 +0100
Subject: [PATCH] electron dimensions (#107)
* overflow fix
* retain electron dimensions
---
src/main/resources/static/index.html | 4 ++--
vue/electron-main.js | 18 +++++++++++++++--
vue/package-lock.json | 30 +++++++++++++++++++++++++---
vue/package.json | 1 +
4 files changed, 46 insertions(+), 7 deletions(-)
diff --git a/src/main/resources/static/index.html b/src/main/resources/static/index.html
index 5f09fbb..a3c488e 100644
--- a/src/main/resources/static/index.html
+++ b/src/main/resources/static/index.html
@@ -5,8 +5,8 @@
MusicReleaseTracker
-
-
+
+
diff --git a/vue/electron-main.js b/vue/electron-main.js
index ba40d50..d5c37e3 100644
--- a/vue/electron-main.js
+++ b/vue/electron-main.js
@@ -4,6 +4,8 @@ import path from "path";
import { fileURLToPath } from "url";
import { spawn } from "child_process";
import axios from "axios";
+import windowStateKeeper from "electron-window-state";
+
axios.defaults.baseURL = "http://localhost:57782";
const __filename = fileURLToPath(import.meta.url);
@@ -15,19 +17,29 @@ let externalEXE;
function createWindow() {
if (process.env.NODE_ENV !== "development") Menu.setApplicationMenu(null);
+
+ const mainWindowState = windowStateKeeper({
+ defaultWidth: 900,
+ defaultHeight: 650,
+ });
+
const win = new BrowserWindow({
icon: path.join(__dirname, "buildResources/MRTicon.ico"),
show: false,
backgroundColor: "#000000",
- width: 900,
- height: 650,
+ width: mainWindowState.width,
+ height: mainWindowState.height,
minHeight: 450,
minWidth: 720,
+ x: mainWindowState.x,
+ y: mainWindowState.y,
webPreferences: {
preload: path.join(__dirname, "electron-preload.js"),
},
});
+ mainWindowState.manage(win);
+
win.webContents.setWindowOpenHandler(({ url }) => {
shell.openExternal(url);
return { action: "deny" };
@@ -64,9 +76,11 @@ app.whenReady().then(async () => {
if (process.env.NODE_ENV !== "development") {
externalEXE = spawn("buildResources/MusicReleaseTracker", { detached: true, stdio: "ignore" });
}
+
await checkBackendReady();
createWindow();
+
app.on("activate", () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
diff --git a/vue/package-lock.json b/vue/package-lock.json
index 094bcfd..9d55614 100644
--- a/vue/package-lock.json
+++ b/vue/package-lock.json
@@ -9,6 +9,7 @@
"version": "9.1.1",
"dependencies": {
"axios": "^1.7.7",
+ "electron-window-state": "^5.0.3",
"vue": "^3.5.12",
"vue-router": "^4.4.5",
"vuex": "^4.1.0"
@@ -2874,6 +2875,31 @@
"node": ">= 10.0.0"
}
},
+ "node_modules/electron-window-state": {
+ "version": "5.0.3",
+ "resolved": "https://registry.npmjs.org/electron-window-state/-/electron-window-state-5.0.3.tgz",
+ "integrity": "sha512-1mNTwCfkolXl3kMf50yW3vE2lZj0y92P/HYWFBrb+v2S/pCka5mdwN3cagKm458A7NjndSwijynXgcLWRodsVg==",
+ "license": "MIT",
+ "dependencies": {
+ "jsonfile": "^4.0.0",
+ "mkdirp": "^0.5.1"
+ },
+ "engines": {
+ "node": ">=8.0.0"
+ }
+ },
+ "node_modules/electron-window-state/node_modules/mkdirp": {
+ "version": "0.5.6",
+ "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz",
+ "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==",
+ "license": "MIT",
+ "dependencies": {
+ "minimist": "^1.2.6"
+ },
+ "bin": {
+ "mkdirp": "bin/cmd.js"
+ }
+ },
"node_modules/emoji-regex": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
@@ -3673,7 +3699,7 @@
"version": "4.2.11",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
"integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==",
- "dev": true,
+ "devOptional": true,
"license": "ISC"
},
"node_modules/has-flag": {
@@ -4130,7 +4156,6 @@
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz",
"integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==",
- "dev": true,
"license": "MIT",
"optionalDependencies": {
"graceful-fs": "^4.1.6"
@@ -4473,7 +4498,6 @@
"version": "1.2.8",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz",
"integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==",
- "dev": true,
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/ljharb"
diff --git a/vue/package.json b/vue/package.json
index 7e47002..60b1883 100644
--- a/vue/package.json
+++ b/vue/package.json
@@ -80,6 +80,7 @@
},
"dependencies": {
"axios": "^1.7.7",
+ "electron-window-state": "^5.0.3",
"vue": "^3.5.12",
"vue-router": "^4.4.5",
"vuex": "^4.1.0"