From a2de1984e32a25062bb9cd0af934baa5e8b763e0 Mon Sep 17 00:00:00 2001 From: buvta <12312540+buvta@users.noreply.github.com> Date: Thu, 31 Dec 2020 22:12:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E4=B8=BA=E5=8E=9F=E6=9D=A5=E7=9A=84?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=BB=84=E4=BB=B6=EF=BC=8C=E9=81=BF=E5=85=8D?= =?UTF-8?q?=E5=9B=A0=E4=B8=BA=E8=B6=85=E6=97=B6=E8=80=8C=E4=B8=AD=E6=96=AD?= =?UTF-8?q?=E5=8D=A1=E4=BD=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Setting.vue | 21 +++++++-------------- src/lib/update/update.js | 9 +++++---- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/src/components/Setting.vue b/src/components/Setting.vue index bcff144..cb2113b 100644 --- a/src/components/Setting.vue +++ b/src/components/Setting.vue @@ -205,14 +205,11 @@
-
- -
更新包大小: {{update.size}} KB
-
@@ -258,9 +255,8 @@ export default { version: '', show: false, html: '', - percent: 0, - size: 0, - downloaded: false + downloaded: false, + showDownload: true } } }, @@ -498,15 +494,12 @@ export default { openUpdate () { this.update.show = true }, - cancelUpdate () { + closeUpdate () { this.update.show = false }, startUpdate () { + this.update.showDownload = false ipcRenderer.send('downloadUpdate') - ipcRenderer.on('download-progress', (info, progress) => { - this.update.size = progress.total - this.update.percent = parseFloat(progress.percent).toFixed(1) - }) ipcRenderer.on('update-downloaded', () => { this.update.downloaded = true }) diff --git a/src/lib/update/update.js b/src/lib/update/update.js index 776c2a5..d945f8d 100644 --- a/src/lib/update/update.js +++ b/src/lib/update/update.js @@ -1,9 +1,10 @@ import { BrowserWindow, ipcMain } from 'electron' -const { autoUpdater } = require('@imjs/electron-differential-updater') +const { autoUpdater } = require('electron-updater') +// electron-updater 增量更新时似乎无法显示进度 export function initUpdater (win = BrowserWindow) { autoUpdater.autoDownload = false - autoUpdater.autoInstallOnAppQuit = false + autoUpdater.autoInstallOnAppQuit = true // 主进程监听检查更新事件 ipcMain.on('checkForUpdate', () => { @@ -41,8 +42,8 @@ export function initUpdater (win = BrowserWindow) { }) // 下载更新进度 - autoUpdater.on('download-progress', (info, progress) => { - win.webContents.send('download-progress', info, progress) + autoUpdater.on('download-progress', (progressObj) => { + win.webContents.send('download-progress', progressObj) }) // 下载完成