改为原来的更新组件,避免因为超时而中断卡住

This commit is contained in:
buvta
2020-12-31 22:12:30 +08:00
parent 81b5391f64
commit a2de1984e3
2 changed files with 12 additions and 18 deletions

View File

@@ -205,14 +205,11 @@
<div class="wrapper">
<div class="body">
<div class="content" v-html="update.html"></div>
<div class="progress" v-show="update.percent > 0">
<el-progress :percentage="update.percent"></el-progress>
<div class="size" style="font-size: 14px">更新包大小: {{update.size}} KB</div>
</div>
</div>
<div class="footer">
<el-button size="small" @click="cancelUpdate">取消</el-button>
<el-button size="small" v-show="!update.downloaded" @click="startUpdate">更新</el-button>
<el-button size="small" @click="closeUpdate">关闭</el-button>
<el-button size="small" v-show="update.showDownload" @click="startUpdate">更新</el-button>
<el-button size="small" v-show="!update.showDownload && !update.downloaded">正在更新...</el-button>
<el-button size="small" v-show="update.downloaded" @click="installUpdate">安装</el-button>
</div>
</div>
@@ -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
})

View File

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