Replace native menu with custom titlebar
Some checks failed
Build Windows App / build-windows (push) Failing after 5m27s
Some checks failed
Build Windows App / build-windows (push) Failing after 5m27s
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { app, BrowserWindow, dialog, ipcMain } from "electron";
|
||||
import { app, BrowserWindow, Menu, dialog, ipcMain } from "electron";
|
||||
import isDev from "electron-is-dev";
|
||||
import { readFile, writeFile } from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
@@ -13,6 +13,8 @@ async function createWindow() {
|
||||
minWidth: 980,
|
||||
minHeight: 680,
|
||||
title: "EnvHelper",
|
||||
frame: false,
|
||||
autoHideMenuBar: true,
|
||||
backgroundColor: "#f6f7f4",
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, "preload.js"),
|
||||
@@ -21,6 +23,8 @@ async function createWindow() {
|
||||
}
|
||||
});
|
||||
|
||||
Menu.setApplicationMenu(null);
|
||||
|
||||
if (isDev) {
|
||||
await win.loadURL("http://127.0.0.1:5173");
|
||||
} else {
|
||||
@@ -45,6 +49,27 @@ ipcMain.handle("envhelper:open-file", async () => {
|
||||
};
|
||||
});
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
if (win.isMaximized()) {
|
||||
win.unmaximize();
|
||||
} else {
|
||||
win.maximize();
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle("envhelper:window-close", (event) => {
|
||||
BrowserWindow.fromWebContents(event.sender)?.close();
|
||||
});
|
||||
|
||||
ipcMain.handle("envhelper:save-file", async (_event, content: string) => {
|
||||
const result = await dialog.showSaveDialog({
|
||||
defaultPath: ".env",
|
||||
|
||||
Reference in New Issue
Block a user