Skip to content

Commit

Permalink
完善检查更新
Browse files Browse the repository at this point in the history
  • Loading branch information
yueshutong committed Jun 6, 2020
1 parent 31794f3 commit 14ff8dc
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/app-update.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ function autoUpdateApp(isTip) {
});
req.end();
}

exports.autoUpdateApp = autoUpdateApp

//解析html获取内容
Expand All @@ -39,25 +40,31 @@ function parseHtml(result, isTip) {
const version = element.getAttribute('title')
const compareVersion = util.compareVersion(version, app.getVersion())
if (compareVersion > 0) {
//发现更新
//需要更新
dialog.showMessageBox({
buttons: ['取消', '查看', '下载'],
message: `当前版本:${app.getVersion()}\n发现新版本:${version}`
}
).then(function (res) {
if (res.response === 1) {
shell.openExternal(url).then()
}else if (res.response===2){
} else if (res.response === 2) {
// 下载压缩包
shell.openExternal(require('./app-constant').download).then()
}
// 自动检查更新
setInterval(function () {
setTimeout(function () {
autoUpdateApp(false)
}, 1000*60*60)
})
} else if (isTip) {
appToast.toast({title: '已经是最新版本', body: '最新发布版本 '+version})

} else {
// 不需要更新
if (isTip) {
appToast.toast({title: '已经是最新版本', body: '最新发布版本 ' + version})
}
// 自动检查更新
setTimeout(function () {
autoUpdateApp(false)
}, 1000*60*60)
}
}

0 comments on commit 14ff8dc

Please sign in to comment.