fix version check

This commit is contained in:
2025-02-14 10:12:30 +08:00
parent bd24cfad46
commit 2333c6df85

View File

@@ -85,8 +85,8 @@ class _AboutSettingsState extends State<AboutSettings> {
} }
Future<bool> checkUpdate() async { Future<bool> checkUpdate() async {
var res = await AppDio().get( var res = await AppDio()
"https://cdn.jsdelivr.net/gh/venera-app/venera@latest/pubspec.yaml"); .get("https://cdn.jsdelivr.net/gh/venera-app/venera@master/pubspec.yaml");
if (res.statusCode == 200) { if (res.statusCode == 200) {
var data = loadYaml(res.data); var data = loadYaml(res.data);
if (data["version"] != null) { if (data["version"] != null) {
@@ -108,7 +108,7 @@ Future<void> checkUpdateUi([bool showMessageIfNoUpdate = true]) async {
content: Text( content: Text(
"A new version is available. Do you want to update now?" "A new version is available. Do you want to update now?"
.tl) .tl)
.paddingHorizontal(8), .paddingHorizontal(16),
actions: [ actions: [
Button.text( Button.text(
onPressed: () { onPressed: () {
@@ -137,6 +137,9 @@ bool _compareVersion(String version1, String version2) {
if (int.parse(v1[i]) > int.parse(v2[i])) { if (int.parse(v1[i]) > int.parse(v2[i])) {
return true; return true;
} }
if (int.parse(v1[i]) < int.parse(v2[i])) {
return false;
}
} }
return false; return false;
} }