Upload main.js via GUI
This commit is contained in:
48
main.js
48
main.js
@@ -7,6 +7,8 @@ const crypto = require('crypto');
|
||||
const { execSync } = require('child_process');
|
||||
const https = require('https');
|
||||
const http = require('http');
|
||||
const Updater = require('./updater.js'); // Auto-Updater
|
||||
let updater = null;
|
||||
|
||||
const {
|
||||
createRepoGitHub,
|
||||
@@ -1586,3 +1588,49 @@ ipcMain.handle('get-commit-files', async (event, data) => {
|
||||
return { ok: false, error: String(error) };
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// main.js - Updater IPC Handlers
|
||||
|
||||
// 1. Version abfragen
|
||||
ipcMain.handle('get-app-version', async () => {
|
||||
return { ok: true, version: app.getVersion() };
|
||||
});
|
||||
|
||||
// 2. Suche nach Updates (Manuell oder Automatisch)
|
||||
ipcMain.handle('check-for-updates', async (event) => {
|
||||
console.log("[Main] Update-Check angefordert...");
|
||||
try {
|
||||
if (!updater) {
|
||||
const win = BrowserWindow.fromWebContents(event.sender);
|
||||
if (win) updater = new Updater(win);
|
||||
}
|
||||
if (updater) await updater.checkForUpdates(false);
|
||||
return { ok: true };
|
||||
} catch (error) {
|
||||
console.error('[Main] Fehler beim Update-Check:', error);
|
||||
return { ok: false, error: String(error) };
|
||||
}
|
||||
});
|
||||
|
||||
// 3. Download starten (wird vom "Jetzt installieren" Button gerufen)
|
||||
ipcMain.handle('start-update-download', async (event, asset) => {
|
||||
console.log("[Main] Download-Signal erhalten für:", asset ? asset.name : "Unbekannt");
|
||||
try {
|
||||
if (!updater) {
|
||||
const win = BrowserWindow.fromWebContents(event.sender);
|
||||
updater = new Updater(win);
|
||||
}
|
||||
if (asset && asset.browser_download_url) {
|
||||
await updater.startDownload(asset);
|
||||
return { ok: true };
|
||||
}
|
||||
return { ok: false, error: 'Ungültiges Asset' };
|
||||
} catch (error) {
|
||||
console.error('[Main] Download-Fehler:', error);
|
||||
return { ok: false, error: String(error) };
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user