Feat: Add theme reloading functionality with refresh button in settings panel

This commit is contained in:
MasterAcnolo
2026-04-12 09:32:15 +02:00
parent ebb48f4f8b
commit d05b9e2511
7 changed files with 83 additions and 6 deletions

View File

@@ -3,7 +3,7 @@ const fs = require("fs");
const path = require("path");
const { logger, logDir } = require("../server/logger");
const { configFeatures, featuresPath } = require("../config");
const { getThemes } = require("./themeManager");
const { getThemes, reloadThemes } = require("./themeManager");
const config = require("../config");
const { validateDownloadPath, getDefaultDownloadPath } = require("./pathValidator");
@@ -57,7 +57,7 @@ function registerIpcHandlers(getMainWindow) {
getMainWindow()?.setProgressBar(percent / 100);
});
// Contrôles fenêtre (custom top bar)
// TOPBAR ACTION
ipcMain.on("window-minimize", () => getMainWindow()?.minimize());
ipcMain.on("window-maximize", () => {
const win = getMainWindow();
@@ -66,7 +66,7 @@ function registerIpcHandlers(getMainWindow) {
});
ipcMain.on("window-close", () => getMainWindow()?.close());
// Actions custom
ipcMain.on("open-devtools", () =>
getMainWindow()?.webContents.openDevTools({ mode: "detach" })
);
@@ -79,9 +79,16 @@ function registerIpcHandlers(getMainWindow) {
);
ipcMain.on("open-config", () => shell.openPath(configFolderPath));
// THEME
ipcMain.handle("get-themes", () => getThemes());
ipcMain.on("open-theme", () => shell.openPath(themeFolderPath));
ipcMain.handle("get-themes", () => getThemes());
ipcMain.handle("reload-themes", async () => {
return await reloadThemes();
});
// Modification des features
ipcMain.handle("set-feature", (event, { key, value }) => {

View File

@@ -178,4 +178,11 @@ function getThemes() {
return cachedThemes ?? [];
}
module.exports = { initThemes, getThemes };
async function reloadThemes() {
const themes = await loadThemesFromFolder();
cachedThemes = themes.sort((a, b) => getThemeOrder(a.id) - getThemeOrder(b.id));
logger.info(`Themes reloaded: ${cachedThemes.length} theme(s)`);
return cachedThemes;
}
module.exports = { initThemes, getThemes , reloadThemes };