mirror of
https://github.com/MasterAcnolo/Freedom-Loader.git
synced 2026-07-29 18:25:47 +02:00
Autoupdate + FreedomKiller Démarrage
This commit is contained in:
@@ -1,20 +1,23 @@
|
||||
const { autoUpdater } = require("electron-updater");
|
||||
const { dialog, app } = require("electron");
|
||||
const { app, Notification } = require("electron");
|
||||
const { logger } = require("./logger");
|
||||
|
||||
function initAutoUpdater(mainWindow) {
|
||||
function AutoUpdater() {
|
||||
|
||||
autoUpdater.on("update-available", (info) => {
|
||||
logger.info(`Nouvelle version disponible : ${info.version}`);
|
||||
if (mainWindow) {
|
||||
mainWindow.webContents.send("update-available", info.version);
|
||||
}
|
||||
new Notification({
|
||||
title: "Freedom Loader",
|
||||
body: `Nouvelle version disponible : ${info.version}. L'application va redémarrer`
|
||||
}).show();
|
||||
});
|
||||
|
||||
autoUpdater.on("update-downloaded", (info) => {
|
||||
logger.info(`Mise à jour téléchargée : ${info.version}`);
|
||||
if (mainWindow) {
|
||||
mainWindow.webContents.send("update-downloaded", info.version);
|
||||
}
|
||||
new Notification({
|
||||
title: "Freedom Loader",
|
||||
body: `Mise à jour ${info.version} téléchargée.`
|
||||
}).show();
|
||||
|
||||
setTimeout(() => {
|
||||
autoUpdater.quitAndInstall();
|
||||
@@ -23,11 +26,15 @@ function initAutoUpdater(mainWindow) {
|
||||
|
||||
autoUpdater.on("error", (err) => {
|
||||
logger.error("Erreur auto-update :", err.message);
|
||||
new Notification({
|
||||
title: "Freedom Loader - Erreur de mise à jour",
|
||||
body: err.message
|
||||
}).show();
|
||||
});
|
||||
|
||||
app.whenReady().then(() => {
|
||||
app.whenReady().then(async () => {
|
||||
try {
|
||||
autoUpdater.checkForUpdatesAndNotify();
|
||||
await autoUpdater.checkForUpdates();
|
||||
logger.info("Vérification des mises à jour effectuée");
|
||||
} catch (err) {
|
||||
logger.error("Erreur lors du check update :", err.message);
|
||||
@@ -35,4 +42,4 @@ function initAutoUpdater(mainWindow) {
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = { initAutoUpdater };
|
||||
module.exports = { AutoUpdater };
|
||||
|
||||
Reference in New Issue
Block a user