From 361fe53a7e8a48e42ac8d7f4c07f33bf4ed178e2 Mon Sep 17 00:00:00 2001 From: Starscouts Date: Sun, 14 Jul 2024 14:28:01 +0200 Subject: Fixes for Windows --- main.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) mode change 100755 => 100644 main.js (limited to 'main.js') diff --git a/main.js b/main.js old mode 100755 new mode 100644 index 329ebd8..9220a09 --- a/main.js +++ b/main.js @@ -25,7 +25,7 @@ function open() { }, titleBarStyle: "hidden", titleBarOverlay: { - color: "transparent", + color: "#00000000", symbolColor: "#ffffff", height: 43 }, @@ -39,9 +39,10 @@ function open() { remote.enable(win.webContents); win.on('close', async (e) => { - if (await win.webContents.executeJavaScript("instance?.dataStore.unloaded;")) e.preventDefault(); - await win.webContents.executeJavaScript("instance?.safeClose();"); - }) + e.preventDefault(); + if (await win.webContents.executeJavaScript("instance?.dataStore.unloaded;")) win.destroy(); + await win.webContents.executeJavaScript("instance?.safeUnload().then(() => { require('electron').ipcRenderer.send('destroy'); });"); + }); win.loadFile("./dom/index.html"); win.on('ready-to-show', () => { @@ -68,6 +69,10 @@ function open() { properties: ["openFile", "treatPackageAsDirectory", "dontAddToRecent"] }); }); + + ipcMain.on('destroy', () => { + win.destroy(); + }); } if (app.getName() !== "Electron") { @@ -80,9 +85,11 @@ if (app.getName() !== "Electron") { app.whenReady().then(() => { protocol.handle('pbip', async (req) => { - const { pathname, searchParams } = new URL(req.url); + let { pathname, searchParams } = new URL(req.url); let mime = searchParams.get("mime") ?? "application/octet-stream"; + if (process.platform === "win32") pathname = pathname.substring(1); + const inflateRawSync = util.promisify(zlib.inflateRaw); try { @@ -101,7 +108,6 @@ app.whenReady().then(() => { headers: { 'content-type': 'text/plain' } }); } - }); open(); -- cgit