Wire window controls to main window
All checks were successful
Build Windows App / build-windows (push) Successful in 19m56s
All checks were successful
Build Windows App / build-windows (push) Successful in 19m56s
This commit is contained in:
@@ -5,6 +5,8 @@ import { fileURLToPath } from "node:url";
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
let mainWindow: BrowserWindow | null = null;
|
||||
|
||||
async function createWindow() {
|
||||
const win = new BrowserWindow({
|
||||
width: 1220,
|
||||
@@ -22,6 +24,13 @@ async function createWindow() {
|
||||
}
|
||||
});
|
||||
|
||||
mainWindow = win;
|
||||
win.on("closed", () => {
|
||||
if (mainWindow === win) {
|
||||
mainWindow = null;
|
||||
}
|
||||
});
|
||||
|
||||
Menu.setApplicationMenu(null);
|
||||
|
||||
if (!app.isPackaged) {
|
||||
@@ -48,27 +57,25 @@ ipcMain.handle("envhelper:open-file", async () => {
|
||||
};
|
||||
});
|
||||
|
||||
ipcMain.handle("envhelper:window-minimize", (event) => {
|
||||
BrowserWindow.fromWebContents(event.sender)?.minimize();
|
||||
ipcMain.on("envhelper:window-minimize", () => {
|
||||
mainWindow?.minimize();
|
||||
});
|
||||
|
||||
ipcMain.handle("envhelper:window-toggle-maximize", (event) => {
|
||||
const win = BrowserWindow.fromWebContents(event.sender);
|
||||
if (!win) {
|
||||
return false;
|
||||
ipcMain.on("envhelper:window-toggle-maximize", () => {
|
||||
if (!mainWindow) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (win.isMaximized()) {
|
||||
win.unmaximize();
|
||||
return false;
|
||||
if (mainWindow.isMaximized()) {
|
||||
mainWindow.unmaximize();
|
||||
return;
|
||||
}
|
||||
|
||||
win.maximize();
|
||||
return true;
|
||||
mainWindow.maximize();
|
||||
});
|
||||
|
||||
ipcMain.handle("envhelper:window-close", (event) => {
|
||||
BrowserWindow.fromWebContents(event.sender)?.close();
|
||||
ipcMain.on("envhelper:window-close", () => {
|
||||
mainWindow?.close();
|
||||
});
|
||||
|
||||
ipcMain.handle("envhelper:save-file", async (_event, content: string) => {
|
||||
|
||||
Reference in New Issue
Block a user