mirror of
https://github.com/cuiocean/ZY-Player.git
synced 2026-02-11 06:25:21 +08:00
优化自动更新功能, 增加进度条
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import Vue from 'vue'
|
||||
import { Message, Button, Table, TableColumn, Tag, Input, InputNumber, Dialog, Form, FormItem, Switch, Select, Option, Checkbox, Autocomplete, Col, Tree, Divider } from 'element-ui'
|
||||
import { Message, Button, Table, TableColumn, Tag, Input, InputNumber, Dialog, Form, FormItem, Switch, Select, Option, Checkbox, Autocomplete, Col, Tree, Divider, Progress } from 'element-ui'
|
||||
import Plugin from 'v-fit-columns'
|
||||
Vue.use(Button)
|
||||
Vue.use(Col)
|
||||
@@ -19,4 +19,5 @@ Vue.use(Checkbox)
|
||||
Vue.use(Autocomplete)
|
||||
Vue.use(Tree)
|
||||
Vue.use(Divider)
|
||||
Vue.use(Progress)
|
||||
Vue.prototype.$message = Message
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { BrowserWindow, ipcMain } from 'electron'
|
||||
import { autoUpdater } from 'electron-updater'
|
||||
const { autoUpdater } = require('@imjs/electron-differential-updater')
|
||||
|
||||
export function initUpdater (win = BrowserWindow) {
|
||||
autoUpdater.autoDownload = false
|
||||
@@ -10,9 +10,14 @@ export function initUpdater (win = BrowserWindow) {
|
||||
autoUpdater.checkForUpdates()
|
||||
})
|
||||
|
||||
// 主进程监听开始下载事件
|
||||
ipcMain.on('downloadUpdate', () => {
|
||||
autoUpdater.downloadUpdate()
|
||||
})
|
||||
|
||||
// 主进程监听退出并安装事件
|
||||
ipcMain.on('quitAndInstall', () => {
|
||||
autoUpdater.downloadUpdate()
|
||||
autoUpdater.quitAndInstall()
|
||||
})
|
||||
|
||||
// 开始检测是否有更新
|
||||
@@ -36,13 +41,12 @@ export function initUpdater (win = BrowserWindow) {
|
||||
})
|
||||
|
||||
// 下载更新进度
|
||||
autoUpdater.on('download-progress', (progressObj) => {
|
||||
win.webContents.send('download-progress', progressObj)
|
||||
autoUpdater.on('download-progress', (info, progress) => {
|
||||
win.webContents.send('download-progress', info, progress)
|
||||
})
|
||||
|
||||
// 下载完成并退出安装
|
||||
// 下载完成
|
||||
autoUpdater.on('update-downloaded', () => {
|
||||
win.webContents.send('update-downloaded')
|
||||
autoUpdater.quitAndInstall()
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user