Restore custom styled window controls
All checks were successful
Build Windows App / build-windows (push) Successful in 19m20s

This commit is contained in:
MrSphay
2026-05-01 18:57:33 +02:00
parent c76489a1e4
commit 1361ef657d
5 changed files with 84 additions and 43 deletions

View File

@@ -5,17 +5,6 @@ import { fileURLToPath } from "node:url";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const titleBarThemes = {
light: {
color: "#eef1ed",
symbolColor: "#17241d"
},
dark: {
color: "#132019",
symbolColor: "#e9f3ec"
}
};
async function createWindow() {
const win = new BrowserWindow({
width: 1220,
@@ -23,11 +12,7 @@ async function createWindow() {
minWidth: 980,
minHeight: 680,
title: "EnvHelper",
titleBarStyle: "hidden",
titleBarOverlay: {
...titleBarThemes.light,
height: 34
},
frame: false,
autoHideMenuBar: true,
backgroundColor: "#f6f7f4",
webPreferences: {
@@ -63,11 +48,27 @@ ipcMain.handle("envhelper:open-file", async () => {
};
});
ipcMain.handle("envhelper:set-titlebar-theme", (event, theme: "light" | "dark") => {
BrowserWindow.fromWebContents(event.sender)?.setTitleBarOverlay({
...titleBarThemes[theme],
height: 34
});
ipcMain.handle("envhelper:window-minimize", (event) => {
BrowserWindow.fromWebContents(event.sender)?.minimize();
});
ipcMain.handle("envhelper:window-toggle-maximize", (event) => {
const win = BrowserWindow.fromWebContents(event.sender);
if (!win) {
return false;
}
if (win.isMaximized()) {
win.unmaximize();
return false;
}
win.maximize();
return true;
});
ipcMain.handle("envhelper:window-close", (event) => {
BrowserWindow.fromWebContents(event.sender)?.close();
});
ipcMain.handle("envhelper:save-file", async (_event, content: string) => {