fix(update): electron update function (#32)

This commit is contained in:
Haze
2026-02-10 15:20:04 +08:00
committed by GitHub
Unverified
parent e8a7377525
commit 9e5fdc5631
4 changed files with 168 additions and 2 deletions

View File

@@ -1,6 +1,9 @@
/**
* Auto-Updater Module
* Handles automatic application updates using electron-updater
*
* Update providers are configured in electron-builder.yml (OSS primary, GitHub fallback).
* electron-updater handles provider resolution automatically.
*/
import { autoUpdater, UpdateInfo, ProgressInfo, UpdateDownloadedEvent } from 'electron-updater';
import { BrowserWindow, app, ipcMain } from 'electron';
@@ -113,6 +116,7 @@ export class AppUpdater extends EventEmitter {
/**
* Check for updates
* electron-updater automatically tries providers defined in electron-builder.yml in order
*/
async checkForUpdates(): Promise<UpdateInfo | null> {
try {
@@ -120,7 +124,8 @@ export class AppUpdater extends EventEmitter {
return result?.updateInfo || null;
} catch (error) {
console.error('[Updater] Check for updates failed:', error);
return null;
this.updateStatus({ status: 'error', error: (error as Error).message || String(error) });
throw error;
}
}