mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-28 02:23:53 +02:00
refactor(desktop): extract auto-updater into modules/auto-updater.ts
This commit is contained in:
parent
35da1cf1b4
commit
d868464de7
2 changed files with 35 additions and 35 deletions
|
|
@ -1,9 +1,9 @@
|
|||
import { app, BrowserWindow, shell, ipcMain, dialog, Menu } from 'electron';
|
||||
import { autoUpdater } from 'electron-updater';
|
||||
import { app, BrowserWindow, shell, ipcMain, Menu } from 'electron';
|
||||
import { registerGlobalErrorHandlers, showErrorDialog } from './modules/errors';
|
||||
import { startNextServer } from './modules/server';
|
||||
import { createMainWindow } from './modules/window';
|
||||
import { setupDeepLinks, handlePendingDeepLink } from './modules/deep-links';
|
||||
import { setupAutoUpdater } from './modules/auto-updater';
|
||||
|
||||
registerGlobalErrorHandlers();
|
||||
|
||||
|
|
@ -11,8 +11,6 @@ if (!setupDeepLinks()) {
|
|||
app.quit();
|
||||
}
|
||||
|
||||
const isDev = !app.isPackaged;
|
||||
|
||||
// IPC handlers
|
||||
ipcMain.on('open-external', (_event, url: string) => {
|
||||
try {
|
||||
|
|
@ -29,37 +27,6 @@ ipcMain.handle('get-app-version', () => {
|
|||
return app.getVersion();
|
||||
});
|
||||
|
||||
function setupAutoUpdater() {
|
||||
if (isDev) return;
|
||||
|
||||
autoUpdater.autoDownload = true;
|
||||
|
||||
autoUpdater.on('update-available', (info) => {
|
||||
console.log(`Update available: ${info.version}`);
|
||||
});
|
||||
|
||||
autoUpdater.on('update-downloaded', (info) => {
|
||||
console.log(`Update downloaded: ${info.version}`);
|
||||
dialog.showMessageBox({
|
||||
type: 'info',
|
||||
buttons: ['Restart', 'Later'],
|
||||
defaultId: 0,
|
||||
title: 'Update Ready',
|
||||
message: `Version ${info.version} has been downloaded. Restart to apply the update.`,
|
||||
}).then(({ response }) => {
|
||||
if (response === 0) {
|
||||
autoUpdater.quitAndInstall();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
autoUpdater.on('error', (err) => {
|
||||
console.error('Auto-updater error:', err);
|
||||
});
|
||||
|
||||
autoUpdater.checkForUpdates();
|
||||
}
|
||||
|
||||
function setupMenu() {
|
||||
const isMac = process.platform === 'darwin';
|
||||
const template: Electron.MenuItemConstructorOptions[] = [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue