diff --git a/common/AppAPI.ts b/common/AppAPI.ts index eef596b..ac3351f 100644 --- a/common/AppAPI.ts +++ b/common/AppAPI.ts @@ -20,6 +20,7 @@ export type AppUpdate = | UpdateNotAvailable | UpdateError | UpdateDownloadProgress + | UpdateCanceled | UpdateDownloaded; export interface CheckingForUpdates { @@ -46,6 +47,11 @@ export interface UpdateDownloadProgress { info: ProgressInfo; } +export interface UpdateCanceled { + name: 'update-cancelled'; + info: UpdateInfo; +} + export interface UpdateDownloaded { name: 'update-downloaded'; info: UpdateDownloadedEvent; diff --git a/src-electron/electron-updater.ts b/src-electron/electron-updater.ts index 1465873..81a384b 100644 --- a/src-electron/electron-updater.ts +++ b/src-electron/electron-updater.ts @@ -20,67 +20,70 @@ function getAutoUpdater(): AppUpdater { const startAutoUpdater = async () => { const autoUpdater = getAutoUpdater(); autoUpdater.logger = log; - registerEventListener(); await autoUpdater.checkForUpdates(); }; -function registerEventListener() { - const autoUpdater = getAutoUpdater(); - autoUpdater.on('checking-for-update', () => { - send({ - name: 'checking-for-update', - }); +const autoUpdater = getAutoUpdater(); +autoUpdater.on('checking-for-update', () => { + send({ + name: 'checking-for-update', }); - autoUpdater.on('update-available', (info) => { - send({ - name: 'update-available', - info, - }); +}); +autoUpdater.on('update-cancelled', (info) => { + send({ + name: 'update-cancelled', + info, }); - autoUpdater.on('update-not-available', (info) => { - send({ - name: 'update-not-available', - info, - }); +}); +autoUpdater.on('update-available', (info) => { + send({ + name: 'update-available', + info, }); - autoUpdater.on('error', (err) => { - send({ - name: 'error', - error: err, - }); +}); +autoUpdater.on('update-not-available', (info) => { + send({ + name: 'update-not-available', + info, }); - autoUpdater.on('download-progress', (progressObj) => { - send({ - name: 'download-progress', - info: progressObj, - }); +}); +autoUpdater.on('error', (err) => { + send({ + name: 'error', + error: err, }); - - autoUpdater.on('update-downloaded', (info) => { - send({ - name: 'update-downloaded', - info, - }); +}); +autoUpdater.on('download-progress', (progressObj) => { + send({ + name: 'download-progress', + info: progressObj, }); +}); - let cancellationToken: CancellationToken | undefined; - ipcMain.on('app:checkForUpdate', async () => { - await autoUpdater.checkForUpdates(); - }); - ipcMain.on('app:downloadUpdate', async () => { - if (cancellationToken) { - return; - } - await autoUpdater.downloadUpdate(cancellationToken); - }); - ipcMain.on('app:cancelUpdate', () => { - cancellationToken?.cancel(); - cancellationToken = undefined; +autoUpdater.on('update-downloaded', (info) => { + send({ + name: 'update-downloaded', + info, }); - ipcMain.on('app:installUpdate', () => { - autoUpdater.quitAndInstall(); - }); -} +}); + +let cancellationToken: CancellationToken | undefined; +ipcMain.on('app:checkForUpdate', async () => { + await autoUpdater.checkForUpdates(); +}); +ipcMain.on('app:downloadUpdate', async () => { + if (cancellationToken) { + return; + } + await autoUpdater.downloadUpdate(cancellationToken); +}); +ipcMain.on('app:cancelUpdate', () => { + cancellationToken?.cancel(); + cancellationToken = undefined; +}); +ipcMain.on('app:installUpdate', () => { + autoUpdater.quitAndInstall(); +}); function send(update: AppUpdate) { BrowserWindow.getAllWindows().forEach((win) => { diff --git a/src/components/layout/AppUpdateBtn.vue b/src/components/layout/AppUpdateBtn.vue index a43ec0b..1bd611f 100644 --- a/src/components/layout/AppUpdateBtn.vue +++ b/src/components/layout/AppUpdateBtn.vue @@ -8,16 +8,17 @@ :icon="icon" >
-
- {{ t('update.available') }} + +
+
+ {{ t('updater.updateAvailable') }} - {{ status.info.version }} +
+ {{ status.info.version }} / {{ updateSize(status.info) }} +
+
+
- {{ t('update.not_available') }} +
+ {{ t('updater.updateNotAvailable') }} + +
+ {{ status.info.version }} +
+
-
- {{ t('update.download-progress') }} + +
+ {{ t('updater.downloadProgress') }} -
- - {{ status.info.transferred }} / {{ status.info.total }} ({{ - status.info.bytesPerSecond - }} - Bps) +
+ {{ humanStorageSize(status.info.transferred) }} / + {{ humanStorageSize(status.info.total) }}
@@ -80,20 +102,68 @@
-
- {{ t('update.downloaded') }} + +
+
+ {{ t('updater.updateCanceled') }} + +
+ {{ status.info.version }} / {{ updateSize(status.info) }} +
+
+ + +
+ + +
+
+ {{ t('updater.updateDownloaded') }} + +
+ {{ status.info.version }} +
+
-
- - {{ status.error.message }} + +
+ +
+ {{ t('updater.error') }} + + {{ status.error.message }} + +
@@ -114,44 +184,45 @@