Skip to content

Commit a2de198

Browse files
committed
改为原来的更新组件,避免因为超时而中断卡住
1 parent 81b5391 commit a2de198

File tree

2 files changed

+12
-18
lines changed

2 files changed

+12
-18
lines changed

src/components/Setting.vue

+7-14
Original file line numberDiff line numberDiff line change
@@ -205,14 +205,11 @@
205205
<div class="wrapper">
206206
<div class="body">
207207
<div class="content" v-html="update.html"></div>
208-
<div class="progress" v-show="update.percent > 0">
209-
<el-progress :percentage="update.percent"></el-progress>
210-
<div class="size" style="font-size: 14px">更新包大小: {{update.size}} KB</div>
211-
</div>
212208
</div>
213209
<div class="footer">
214-
<el-button size="small" @click="cancelUpdate">取消</el-button>
215-
<el-button size="small" v-show="!update.downloaded" @click="startUpdate">更新</el-button>
210+
<el-button size="small" @click="closeUpdate">关闭</el-button>
211+
<el-button size="small" v-show="update.showDownload" @click="startUpdate">更新</el-button>
212+
<el-button size="small" v-show="!update.showDownload && !update.downloaded">正在更新...</el-button>
216213
<el-button size="small" v-show="update.downloaded" @click="installUpdate">安装</el-button>
217214
</div>
218215
</div>
@@ -258,9 +255,8 @@ export default {
258255
version: '',
259256
show: false,
260257
html: '',
261-
percent: 0,
262-
size: 0,
263-
downloaded: false
258+
downloaded: false,
259+
showDownload: true
264260
}
265261
}
266262
},
@@ -498,15 +494,12 @@ export default {
498494
openUpdate () {
499495
this.update.show = true
500496
},
501-
cancelUpdate () {
497+
closeUpdate () {
502498
this.update.show = false
503499
},
504500
startUpdate () {
501+
this.update.showDownload = false
505502
ipcRenderer.send('downloadUpdate')
506-
ipcRenderer.on('download-progress', (info, progress) => {
507-
this.update.size = progress.total
508-
this.update.percent = parseFloat(progress.percent).toFixed(1)
509-
})
510503
ipcRenderer.on('update-downloaded', () => {
511504
this.update.downloaded = true
512505
})

src/lib/update/update.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { BrowserWindow, ipcMain } from 'electron'
2-
const { autoUpdater } = require('@imjs/electron-differential-updater')
2+
const { autoUpdater } = require('electron-updater')
33

4+
// electron-updater 增量更新时似乎无法显示进度
45
export function initUpdater (win = BrowserWindow) {
56
autoUpdater.autoDownload = false
6-
autoUpdater.autoInstallOnAppQuit = false
7+
autoUpdater.autoInstallOnAppQuit = true
78

89
// 主进程监听检查更新事件
910
ipcMain.on('checkForUpdate', () => {
@@ -41,8 +42,8 @@ export function initUpdater (win = BrowserWindow) {
4142
})
4243

4344
// 下载更新进度
44-
autoUpdater.on('download-progress', (info, progress) => {
45-
win.webContents.send('download-progress', info, progress)
45+
autoUpdater.on('download-progress', (progressObj) => {
46+
win.webContents.send('download-progress', progressObj)
4647
})
4748

4849
// 下载完成

0 commit comments

Comments
 (0)