Skip to content

Commit

Permalink
new option: hidde on close
Browse files Browse the repository at this point in the history
  • Loading branch information
SrWither committed Apr 21, 2024
1 parent b26a781 commit 8212def
Show file tree
Hide file tree
Showing 4 changed files with 281 additions and 269 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/",
Expand Down
20 changes: 11 additions & 9 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand All @@ -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"),
Expand Down Expand Up @@ -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);
}
}
Expand All @@ -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(
Expand Down
Loading

0 comments on commit 8212def

Please sign in to comment.