feat: Implement topbar with custom window controls and actions

This commit is contained in:
MasterAcnolo
2025-12-20 09:53:17 +01:00
parent cbfde8b761
commit c11fd40681
9 changed files with 181 additions and 1 deletions

32
main.js
View File

@@ -77,6 +77,7 @@ async function createMainWindow() {
height: 800,
minWidth: 750,
minHeight: 800,
frame:false,
webPreferences: {
nodeIntegration: false,
contextIsolation: true,
@@ -118,6 +119,37 @@ ipcMain.on("set-progress", (event, percent) => {
if (mainWindow) mainWindow.setProgressBar(percent / 100); // Electron attend 0 → 1
});
// Topbar window controls
ipcMain.on("window-minimize", () => {
if (mainWindow) mainWindow.minimize();
});
ipcMain.on("window-maximize", () => {
if (mainWindow) {
if (mainWindow.isMaximized()) {
mainWindow.unmaximize();
} else {
mainWindow.maximize();
}
}
});
ipcMain.on("window-close", () => {
if (mainWindow) mainWindow.close();
});
// Topbar custom actions
ipcMain.on("open-devtools", () => {
if (mainWindow) mainWindow.webContents.openDevTools({ mode: 'detach' });
});
ipcMain.on("open-logs", () => {
if (logsFolderPath) shell.openPath(logsFolderPath);
});
ipcMain.on("open-website", () => {
shell.openExternal("https://masteracnolo.github.io/FreedomLoader/index.html");
});
ipcMain.on("open-wiki", () => {
shell.openExternal("https://masteracnolo.github.io/FreedomLoader/pages/wiki.html");
});
// Menu
function setupMenu() {
const menuTemplate = [