option to quit the app or minimize

This commit is contained in:
Hachi-R 2024-05-03 13:13:37 -03:00
parent f6072eeb5c
commit 8aed8f15d7
6 changed files with 33 additions and 7 deletions

View file

@ -4,6 +4,7 @@ import { t } from "i18next";
import path from "node:path";
import icon from "@resources/icon.png?asset";
import trayIcon from "@resources/tray-icon.png?asset";
import { userPreferencesRepository } from "@main/repository";
export class WindowManager {
public static mainWindow: Electron.BrowserWindow | null = null;
@ -25,7 +26,7 @@ export class WindowManager {
}
}
public static createMainWindow() {
public static async createMainWindow() {
// Create the browser window.
this.mainWindow = new BrowserWindow({
width: 1200,
@ -33,8 +34,8 @@ export class WindowManager {
minWidth: 1024,
minHeight: 540,
titleBarStyle: "hidden",
...(process.platform === "linux" ? { icon } : {}),
trafficLightPosition: { x: 16, y: 16 },
...(process.platform === "linux" ? {icon} : {}),
trafficLightPosition: {x: 16, y: 16},
titleBarOverlay: {
symbolColor: "#DADBE1",
color: "#151515",
@ -49,8 +50,12 @@ export class WindowManager {
this.loadURL();
this.mainWindow.removeMenu();
const userPreferences = await userPreferencesRepository.findOne({
where: {id: 1},
});
this.mainWindow.on("close", () => {
WindowManager.mainWindow?.setProgressBar(-1);
userPreferences?.quitInXButtonEnabled ? app.quit() : WindowManager.mainWindow?.setProgressBar(-1);
});
}