Commit a2de198 1 parent 81b5391 commit a2de198 Copy full SHA for a2de198
File tree 2 files changed +12
-18
lines changed
2 files changed +12
-18
lines changed Original file line number Diff line number Diff line change 205
205
<div class =" wrapper" >
206
206
<div class =" body" >
207
207
<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 >
212
208
</div >
213
209
<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 >
216
213
<el-button size =" small" v-show =" update.downloaded" @click =" installUpdate" >安装</el-button >
217
214
</div >
218
215
</div >
@@ -258,9 +255,8 @@ export default {
258
255
version: ' ' ,
259
256
show: false ,
260
257
html: ' ' ,
261
- percent: 0 ,
262
- size: 0 ,
263
- downloaded: false
258
+ downloaded: false ,
259
+ showDownload: true
264
260
}
265
261
}
266
262
},
@@ -498,15 +494,12 @@ export default {
498
494
openUpdate () {
499
495
this .update .show = true
500
496
},
501
- cancelUpdate () {
497
+ closeUpdate () {
502
498
this .update .show = false
503
499
},
504
500
startUpdate () {
501
+ this .update .showDownload = false
505
502
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
- })
510
503
ipcRenderer .on (' update-downloaded' , () => {
511
504
this .update .downloaded = true
512
505
})
Original file line number Diff line number Diff line change 1
1
import { BrowserWindow , ipcMain } from 'electron'
2
- const { autoUpdater } = require ( '@imjs/ electron-differential -updater' )
2
+ const { autoUpdater } = require ( 'electron-updater' )
3
3
4
+ // electron-updater 增量更新时似乎无法显示进度
4
5
export function initUpdater ( win = BrowserWindow ) {
5
6
autoUpdater . autoDownload = false
6
- autoUpdater . autoInstallOnAppQuit = false
7
+ autoUpdater . autoInstallOnAppQuit = true
7
8
8
9
// 主进程监听检查更新事件
9
10
ipcMain . on ( 'checkForUpdate' , ( ) => {
@@ -41,8 +42,8 @@ export function initUpdater (win = BrowserWindow) {
41
42
} )
42
43
43
44
// 下载更新进度
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 )
46
47
} )
47
48
48
49
// 下载完成
You can’t perform that action at this time.
0 commit comments