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) }) // 下载完成