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.handle("get-default-download-path", () => defaultDownloadPath);
|
||||||
|
|
||||||
|
ipcMain.on("set-progress", (event, percent) => {
|
||||||
|
mainWindow.setProgressBar(percent / 100); // Electron attend 0 → 1
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
function setupMenu() {
|
function setupMenu() {
|
||||||
const menuTemplate = [
|
const menuTemplate = [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,4 +3,5 @@ const { contextBridge, ipcRenderer } = require("electron");
|
|||||||
contextBridge.exposeInMainWorld("electronAPI", {
|
contextBridge.exposeInMainWorld("electronAPI", {
|
||||||
getDefaultDownloadPath: () => ipcRenderer.invoke("get-default-download-path"),
|
getDefaultDownloadPath: () => ipcRenderer.invoke("get-default-download-path"),
|
||||||
selectDownloadFolder: () => ipcRenderer.invoke("select-download-folder"),
|
selectDownloadFolder: () => ipcRenderer.invoke("select-download-folder"),
|
||||||
|
setProgress: (percent) => ipcRenderer.send("set-progress", percent)
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -34,4 +34,4 @@ form.addEventListener("submit", async (e) => {
|
|||||||
statusDiv.textContent = "";
|
statusDiv.textContent = "";
|
||||||
}, 5000);
|
}, 5000);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -26,17 +26,23 @@ const evtSource = new EventSource("/download/progress");
|
|||||||
evtSource.onmessage = e => {
|
evtSource.onmessage = e => {
|
||||||
if (e.data === "reset") {
|
if (e.data === "reset") {
|
||||||
startProgress();
|
startProgress();
|
||||||
|
window.electronAPI.setProgress(0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.data === "done") {
|
if (e.data === "done") {
|
||||||
resetProgress();
|
resetProgress();
|
||||||
|
window.electronAPI.setProgress(-1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const percent = parseFloat(e.data);
|
const percent = parseFloat(e.data);
|
||||||
if (!isNaN(percent)) {
|
if (!isNaN(percent)) {
|
||||||
updateProgress(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