mirror of
https://github.com/MasterAcnolo/Freedom-Loader.git
synced 2026-07-29 18:25:47 +02:00
Loading Bar taskbar
This commit is contained in:
5
main.js
5
main.js
@@ -76,6 +76,11 @@ ipcMain.handle("select-download-folder", async () => {
|
||||
|
||||
ipcMain.handle("get-default-download-path", () => defaultDownloadPath);
|
||||
|
||||
ipcMain.on("set-progress", (event, percent) => {
|
||||
mainWindow.setProgressBar(percent / 100); // Electron attend 0 → 1
|
||||
});
|
||||
|
||||
|
||||
function setupMenu() {
|
||||
const menuTemplate = [
|
||||
{
|
||||
|
||||
@@ -3,4 +3,5 @@ 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)
|
||||
});
|
||||
|
||||
@@ -26,17 +26,23 @@ const evtSource = new EventSource("/download/progress");
|
||||
evtSource.onmessage = e => {
|
||||
if (e.data === "reset") {
|
||||
startProgress();
|
||||
window.electronAPI.setProgress(0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.data === "done") {
|
||||
resetProgress();
|
||||
window.electronAPI.setProgress(-1);
|
||||
return;
|
||||
}
|
||||
|
||||
const percent = parseFloat(e.data);
|
||||
if (!isNaN(percent)) {
|
||||
updateProgress(percent);
|
||||
if (percent >= 100) setTimeout(resetProgress, 500);
|
||||
window.electronAPI.setProgress(percent); // update barre des tâches
|
||||
if (percent >= 100) setTimeout(() => {
|
||||
resetProgress();
|
||||
window.electronAPI.setProgress(-1); // retire la barre
|
||||
}, 500);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user