check update

This commit is contained in:
朱子楚\zhuzi
2023-08-27 09:11:44 +08:00
parent db74f71e82
commit e2879f564c
5 changed files with 137 additions and 23 deletions

View File

@ -28,6 +28,7 @@ CustomWindow {
Component.onCompleted: {
FluTools.setQuitOnLastWindowClosed(false)
tour.open()
checkUpdate()
}
SystemTrayIcon {
@ -277,4 +278,46 @@ CustomWindow {
]
}
FluHttp{
id:http
}
FluContentDialog{
property string newVerson
property string body
id:dialog_update
title:"升级提示"
message:"FluentUI目前最新版本 "+ newVerson +" -- 当前应用版本 "+appInfo.version+" \n现在是否去下载新版本\n\n更新内容\n"+body
buttonFlags: FluContentDialogType.NegativeButton | FluContentDialogType.PositiveButton
negativeText: "取消"
positiveText:"确定"
onPositiveClicked:{
Qt.openUrlExternally("https://github.com/zhuzichu520/FluentUI/releases/latest")
}
}
function checkUpdate(){
var callable = {}
callable.onStart = function(){
console.debug("satrt check update...")
}
callable.onFinish = function(){
console.debug("check update finish")
}
callable.onSuccess = function(result){
var data = JSON.parse(result)
console.debug("current version "+appInfo.version)
console.debug("new version "+data.tag_name)
if(data.tag_name !== appInfo.version){
dialog_update.newVerson = data.tag_name
dialog_update.body = data.body
dialog_update.open()
}
}
callable.onError = function(status,errorString){
console.debug(status+";"+errorString)
}
http.get("https://api.github.com/repos/zhuzichu520/FluentUI/releases/latest",callable)
}
}

View File

@ -29,6 +29,7 @@ CustomWindow {
Component.onCompleted: {
FluTools.setQuitOnLastWindowClosed(false)
tour.open()
checkUpdate()
}
SystemTrayIcon {
@ -278,4 +279,46 @@ CustomWindow {
]
}
FluHttp{
id:http
}
FluContentDialog{
property string newVerson
property string body
id:dialog_update
title:"升级提示"
message:"FluentUI目前最新版本 "+ newVerson +" -- 当前应用版本 "+appInfo.version+" \n现在是否去下载新版本\n\n更新内容\n"+body
buttonFlags: FluContentDialogType.NegativeButton | FluContentDialogType.PositiveButton
negativeText: "取消"
positiveText:"确定"
onPositiveClicked:{
Qt.openUrlExternally("https://github.com/zhuzichu520/FluentUI/releases/latest")
}
}
function checkUpdate(){
var callable = {}
callable.onStart = function(){
console.debug("satrt check update...")
}
callable.onFinish = function(){
console.debug("check update finish")
}
callable.onSuccess = function(result){
var data = JSON.parse(result)
console.debug("current version "+appInfo.version)
console.debug("new version "+data.tag_name)
if(data.tag_name !== appInfo.version){
dialog_update.newVerson = data.tag_name
dialog_update.body = data.body
dialog_update.open()
}
}
callable.onError = function(status,errorString){
console.debug(status+";"+errorString)
}
http.get("https://api.github.com/repos/zhuzichu520/FluentUI/releases/latest",callable)
}
}