From 8212defe906536f3d5fc011c01bc12c61a19935c Mon Sep 17 00:00:00 2001 From: Fadel <59105868+SrWither@users.noreply.github.com> Date: Sun, 21 Apr 2024 16:23:17 -0300 Subject: [PATCH] new option: hidde on close --- package.json | 2 +- src/app.ts | 20 +- src/assets/web/html/settings.html | 500 +++++++++++++++--------------- src/settings.ts | 28 +- 4 files changed, 281 insertions(+), 269 deletions(-) diff --git a/package.json b/package.json index 7cf62ff..7e93487 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "./build/main.js", "scripts": { "build": "mkdir -p build && copyfiles -u 1 \"src/titlebar/**/*\" \"build\" && tsc -p .", - "run": "electron27 build/main.js", + "run": "electron build/main.js", "postbuild": "copyfiles -u 1 \"src/assets/**/*\" \"build\"", "make-app": "npm run build && npm run postbuild && npm run run", "clean": "rm -r build/", diff --git a/src/app.ts b/src/app.ts index 5449fa4..87b2d32 100644 --- a/src/app.ts +++ b/src/app.ts @@ -8,9 +8,10 @@ import * as fs from "fs"; import * as os from "os"; const titlebarIsEnabled = getConfig().titlebar +const hiddeOnClose = getConfig().hiddeOnClose Menu.setApplicationMenu(null); -if(titlebarIsEnabled) { +if (titlebarIsEnabled) { setupTitlebar(); } @@ -29,9 +30,8 @@ export class MainApp { */ constructor(app: Electron.App) { this.app = app; - this.userAgent = `Mozilla/5.0 (X11; ${ - os.type - } ${os.arch()}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36`; + this.userAgent = `Mozilla/5.0 (X11; ${os.type + } ${os.arch()}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36`; this.icons = { main: path.join(__dirname, "assets/icons/main.png"), tray: path.join(__dirname, "assets/icons/tray.png"), @@ -94,7 +94,7 @@ export class MainApp { }); this.win.webContents.setUserAgent(this.userAgent); this.win.loadURL("https://discord.com/app"); - if(titlebarIsEnabled) { + if (titlebarIsEnabled) { attachTitlebarToWindow(this.win); } } @@ -104,10 +104,12 @@ export class MainApp { */ private windowEvents() { // hide window - this.win.on("close", (event: Event) => { - event.preventDefault(); - this.win.hide(); - }); + if (hiddeOnClose) { + this.win.on("close", (event: Event) => { + event.preventDefault(); + this.win.hide(); + }); + } // Open links in the browser. this.win.webContents.setWindowOpenHandler( diff --git a/src/assets/web/html/settings.html b/src/assets/web/html/settings.html index ad04283..d64a8ce 100644 --- a/src/assets/web/html/settings.html +++ b/src/assets/web/html/settings.html @@ -1,264 +1,272 @@ -
- - - - - - - - -