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 // eslint-disable-next-line no-unused-vars
const isMac = process.platform === 'darwin' const isMac = process.platform === 'darwin'
// 检测更新在你想要检查更新的时候执行renderer事件触发后的操作自行编写 // 检测更新在你想要检查更新的时候执行renderer事件触发后的操作自行编写
function updateHandle (app, win, beforeQuit, updateUrl,log) { function updateHandle (app, win, beforeQuit, updateUrl, log) {
// // 更新前,删除本地安装包 ↓ // // 更新前,删除本地安装包 ↓
// const updaterCacheDirName = 'dev-sidecar-updater' // const updaterCacheDirName = 'dev-sidecar-updater'
// const updatePendingPath = path.join(autoUpdater.app.baseCachePath, updaterCacheDirName, 'pending') // 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) log.info('download complete', info.version)
win.webContents.send('update', { win.webContents.send('update', {
key: 'downloaded', key: 'downloaded',
value: { value: info
version: info.version,
releaseData: info.releaseDate
}
}) })
}) })
@ -97,7 +94,7 @@ function updateHandle (app, win, beforeQuit, updateUrl,log) {
export default { export default {
install (context) { install (context) {
const { app, win, beforeQuit,log } = context const { app, win, beforeQuit, log } = context
let updateUrl = 'https://dev-sidecar.docmirror.cn/update/' let updateUrl = 'https://dev-sidecar.docmirror.cn/update/'
if (process.env.NODE_ENV === 'development') { if (process.env.NODE_ENV === 'development') {
Object.defineProperty(app, 'isPackaged', { Object.defineProperty(app, 'isPackaged', {
@ -105,9 +102,9 @@ export default {
return true return true
} }
}) })
updateUrl = 'https://dev-sidecar.docmirror.cn/update/' // updateUrl = 'https://dev-sidecar.docmirror.cn/update/'
// updateUrl = 'http://localhost/dev-sidecar/' 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) { function newUpdateIsReady (value) {
updateParams.downloading = false updateParams.downloading = false
app.$confirm({ app.$confirm({
title: '新版本已准备好', title: `新版本(v${value.version})已准备好,是否立即升级?`,
content: `是否立即升级安装v${value.version}?`,
cancelText: '暂不升级', cancelText: '暂不升级',
okText: '立即升级', 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 () { onOk () {
console.log('OK') console.log('OK')
api.update.doUpdateNow() api.update.doUpdateNow()