perf: 升级时可以展示更新内容

pull/180/head
xiaojunnuo 2020-11-29 00:24:43 +08:00
parent 5c723e99a5
commit 806ac046a9
2 changed files with 17 additions and 12 deletions

View File

@ -7,7 +7,7 @@ import path from 'path'
// eslint-disable-next-line no-unused-vars
const isMac = process.platform === 'darwin'
// 检测更新在你想要检查更新的时候执行renderer事件触发后的操作自行编写
function updateHandle (app, win, beforeQuit, updateUrl,log) {
function updateHandle (app, win, beforeQuit, updateUrl, log) {
// // 更新前,删除本地安装包 ↓
// const updaterCacheDirName = 'dev-sidecar-updater'
// const updatePendingPath = path.join(autoUpdater.app.baseCachePath, updaterCacheDirName, 'pending')
@ -57,10 +57,7 @@ function updateHandle (app, win, beforeQuit, updateUrl,log) {
log.info('download complete', info.version)
win.webContents.send('update', {
key: 'downloaded',
value: {
version: info.version,
releaseData: info.releaseDate
}
value: info
})
})
@ -97,7 +94,7 @@ function updateHandle (app, win, beforeQuit, updateUrl,log) {
export default {
install (context) {
const { app, win, beforeQuit,log } = context
const { app, win, beforeQuit, log } = context
let updateUrl = 'https://dev-sidecar.docmirror.cn/update/'
if (process.env.NODE_ENV === 'development') {
Object.defineProperty(app, 'isPackaged', {
@ -105,9 +102,9 @@ export default {
return true
}
})
updateUrl = 'https://dev-sidecar.docmirror.cn/update/'
// updateUrl = 'http://localhost/dev-sidecar/'
// updateUrl = 'https://dev-sidecar.docmirror.cn/update/'
updateUrl = 'http://localhost/dev-sidecar/'
}
updateHandle(app, win, beforeQuit, updateUrl,log)
updateHandle(app, win, beforeQuit, updateUrl, log)
}
}

View File

@ -78,11 +78,19 @@ function install (app, api) {
function newUpdateIsReady (value) {
updateParams.downloading = false
app.$confirm({
title: '新版本已准备好',
content: `是否立即升级安装v${value.version}?`,
title: `新版本(v${value.version})已准备好,是否立即升级?`,
cancelText: '暂不升级',
okText: '立即升级',
// content: h => <div><h4>{value.version}更新内容:</h4><div>{value.releaseNotes}</div></div>,
content: h => {
console.log(value)
if (value.releaseNotes) {
const notes = []
for (const note of value.releaseNotes) {
notes.push(<li>{note}</li>)
}
return <div><div>更新内容</div><ol>{notes}</ol></div>
}
},
onOk () {
console.log('OK')
api.update.doUpdateNow()