From 31d8b20a761c4ed693ac5bc4edc96afa70ee195b Mon Sep 17 00:00:00 2001 From: MasterAcnolo <68693319+MasterAcnolo@users.noreply.github.com> Date: Wed, 14 Jan 2026 14:03:32 +0100 Subject: [PATCH] Feat: Implement Config File. Read by Front and Back. It aims to give possibility to disable some features quickly. Currenty: DiscordRPC, AutoCheckInfo, AutoUpdate, Custom TopBar, AddMetadata, Add Thumbail were put and implement. Other need to be implement. That's the begin of Settings Panel --- config.js | 29 ++-- config/config.json | 13 ++ main.js | 15 ++- preload.js | 3 +- public/index.html | 6 +- public/script/fetchinfo.js | 262 +++++++++++++++++++----------------- public/script/topbar.js | 10 +- server/helpers/buildArgs.js | 7 +- 8 files changed, 193 insertions(+), 152 deletions(-) create mode 100644 config/config.json diff --git a/config.js b/config.js index a8362a8..0df8abb 100644 --- a/config.js +++ b/config.js @@ -1,5 +1,20 @@ const packageJson = require("./package.json"); const { app } = require("electron"); +const fs = require("fs"); +const path = require("path"); + +const featuresPath = path.join(__dirname, "./config/config.json"); + +let features = {}; + +function loadFeatures() { + const raw = fs.readFileSync(featuresPath, "utf-8"); + features = JSON.parse(raw); + console.log(features) + return features; +} + +const configFeatures = loadFeatures(); module.exports = { version: packageJson.version, @@ -7,17 +22,5 @@ module.exports = { debugMode: true, localMode: !app.isPackaged, DiscordRPCID: "1410934537051181146", - - // Variables Used to toggle main features - autoUpdate: true, - discordRPC: true, - customTopBar: true, // (Will be active on next launch) - autoDownloadPlaylist: true, - logSystem: true, // Disable = Dangerous - autoCheckInfo: true, // To Improve speed ? (NO) - outputTitleCheck: true, // For Non latin characters (Russian) - addThumbail: true, // The Pictures in the files (audio files) - addMetadata: true, // Looks Explicit - downloadSystem: true, // Why would you disable this ? I don't know but why not - notifySystem: true // Notification when download + configFeatures } \ No newline at end of file diff --git a/config/config.json b/config/config.json new file mode 100644 index 0000000..f969fb6 --- /dev/null +++ b/config/config.json @@ -0,0 +1,13 @@ +{ + "autoUpdate": true, + "discordRPC": true, + "customTopBar": true, + "autoDownloadPlaylist": true, + "logSystem": true, + "autoCheckInfo": true, + "outputTitleCheck": true, + "addThumbnail": true, + "addMetadata": true, + "downloadSystem": true, + "notifySystem": true +} \ No newline at end of file diff --git a/main.js b/main.js index aa43415..b8680de 100644 --- a/main.js +++ b/main.js @@ -3,8 +3,11 @@ const { app, BrowserWindow, ipcMain, dialog, Menu, shell } = require("electron") const path = require("path"); const os = require("os"); const fs = require("fs"); + const { logger, logSessionStart, logSessionEnd, logDir } = require("./server/logger"); const { AutoUpdater } = require("./server/update.js"); +const { configFeatures } = require("./config.js"); +const { startRPC } = require("./server/discordRPC"); let mainWindow; const logsFolderPath = logDir; @@ -77,7 +80,7 @@ async function createMainWindow() { height: 800, minWidth: 750, minHeight: 800, - frame:false, + frame: !configFeatures.customTopBar, webPreferences: { nodeIntegration: false, contextIsolation: true, @@ -163,11 +166,15 @@ app.whenReady().then(async () => { await expressServer.startServer(); logger.info("Express Server Started"); - const { startRPC } = require("./server/discordRPC"); - startRPC(); + ipcMain.handle("features", () => { + return configFeatures; + }); + + configFeatures.discordRPC ? startRPC() : ""; await createMainWindow(); - AutoUpdater(mainWindow); + configFeatures.AutoUpdater ? AutoUpdater(mainWindow) : ""; // Auto Update + } catch (err) { logger.error("Window or Server error :", err); app.quit(); diff --git a/preload.js b/preload.js index 2f0e8e8..5da0c1c 100644 --- a/preload.js +++ b/preload.js @@ -3,7 +3,8 @@ const { contextBridge, ipcRenderer } = require("electron"); contextBridge.exposeInMainWorld("electronAPI", { getDefaultDownloadPath: () => ipcRenderer.invoke("get-default-download-path"), selectDownloadFolder: () => ipcRenderer.invoke("select-download-folder"), - setProgress: (percent) => ipcRenderer.send("set-progress", percent) + setProgress: (percent) => ipcRenderer.send("set-progress", percent), + getFeatures: () => ipcRenderer.invoke("features") }); // Contrôles de fenêtre et outils custom pour la topbar diff --git a/public/index.html b/public/index.html index 76d9296..3f8e077 100644 --- a/public/index.html +++ b/public/index.html @@ -17,7 +17,7 @@
-