mirror of
https://github.com/LinoSchmidt/StickExporterTX.git
synced 2026-03-21 10:00:47 +01:00
Added auto update
This commit is contained in:
47
src/index.ts
47
src/index.ts
@@ -1,6 +1,51 @@
|
||||
import {app, BrowserWindow} from 'electron';
|
||||
import {app, BrowserWindow, dialog} from 'electron';
|
||||
import {initialize as remoteInitialize, enable as remoteEnable} from '@electron/remote/main';
|
||||
import path from 'path';
|
||||
import { autoUpdater } from "electron-updater";
|
||||
import logger from 'electron-log';
|
||||
|
||||
logger.transports.console.format = "{h}:{i}:{s} {text}";
|
||||
logger.transports.file.getFile();
|
||||
logger.transports.file.resolvePath = () => path.join(app.getPath('userData'), "logs", "start.log");
|
||||
|
||||
autoUpdater.autoDownload = false;
|
||||
|
||||
autoUpdater.checkForUpdatesAndNotify();
|
||||
|
||||
autoUpdater.on('update-available', async () => {
|
||||
const response = await dialog.showMessageBox({
|
||||
type: 'info',
|
||||
title: 'Update Available',
|
||||
message: 'Found updates, do you want update now?',
|
||||
buttons: ['Yes', 'Later'],
|
||||
});
|
||||
|
||||
if (response.response === 0) {
|
||||
logger.log('Downloading Update');
|
||||
autoUpdater.downloadUpdate();
|
||||
await dialog.showMessageBox({
|
||||
type: 'info',
|
||||
title: 'Update Downloading',
|
||||
message:
|
||||
'Update is being downloaded, you will be notified when it is ready to install',
|
||||
buttons: [],
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
autoUpdater.on('update-downloaded', async () => {
|
||||
const response = await dialog.showMessageBox({
|
||||
type: 'info',
|
||||
buttons: ['Restart', 'Later'],
|
||||
title: 'Application Update',
|
||||
message: 'Update',
|
||||
detail:
|
||||
'A new version has been downloaded. Restart the application to apply the updates.',
|
||||
});
|
||||
if (response.response === 0) {
|
||||
setImmediate(() => autoUpdater.quitAndInstall());
|
||||
}
|
||||
});
|
||||
|
||||
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
|
||||
if (require('electron-squirrel-startup')) {
|
||||
|
||||
Reference in New Issue
Block a user