This commit is contained in:
parent
8847f3fcf6
commit
832de038ca
8 changed files with 526 additions and 9 deletions
39
main.js
39
main.js
|
|
@ -1,4 +1,5 @@
|
|||
const { app, BrowserWindow, session, desktopCapturer, ipcMain, clipboard } = require('electron');
|
||||
const { autoUpdater } = require('electron-updater');
|
||||
const path = require('path');
|
||||
const url = require('url');
|
||||
|
||||
|
|
@ -121,6 +122,44 @@ app.commandLine.appendSwitch('log-level', '3'); // Silences standard Chromium wa
|
|||
app.whenReady().then(() => {
|
||||
createWindow();
|
||||
|
||||
// Configure Auto-Updater
|
||||
autoUpdater.autoDownload = false;
|
||||
autoUpdater.logger = console;
|
||||
|
||||
autoUpdater.on('update-available', (info) => {
|
||||
const wins = BrowserWindow.getAllWindows();
|
||||
if (wins.length > 0) wins[0].webContents.send('update-available', info);
|
||||
});
|
||||
|
||||
autoUpdater.on('update-downloaded', (info) => {
|
||||
const wins = BrowserWindow.getAllWindows();
|
||||
if (wins.length > 0) wins[0].webContents.send('update-downloaded', info);
|
||||
});
|
||||
|
||||
autoUpdater.on('error', (err) => {
|
||||
const wins = BrowserWindow.getAllWindows();
|
||||
if (wins.length > 0) wins[0].webContents.send('update-error', err.message);
|
||||
});
|
||||
|
||||
ipcMain.on('check-for-updates', () => {
|
||||
autoUpdater.checkForUpdatesAndNotify().catch(err => {
|
||||
console.error("Manual update check failed", err);
|
||||
});
|
||||
});
|
||||
|
||||
ipcMain.on('download-update', () => {
|
||||
autoUpdater.downloadUpdate();
|
||||
});
|
||||
|
||||
ipcMain.on('quit-and-install', () => {
|
||||
autoUpdater.quitAndInstall();
|
||||
});
|
||||
|
||||
// Check once on startup
|
||||
setTimeout(() => {
|
||||
autoUpdater.checkForUpdatesAndNotify().catch(() => { });
|
||||
}, 5000);
|
||||
|
||||
app.on('activate', () => {
|
||||
if (BrowserWindow.getAllWindows().length === 0) {
|
||||
createWindow();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue