MSE检查更新功能

This commit is contained in:
xkeyC 2023-11-11 01:41:06 +08:00
parent 7c833fe3ac
commit 1cb0c85e63
3 changed files with 20 additions and 8 deletions

View File

@ -129,8 +129,13 @@ class AppConf {
try {
networkVersionData = await Api.getAppVersion();
globalUIModel.checkActivityThemeColor();
if (isMSE) {
dPrint(
"lastVersion=${networkVersionData?.mSELastVersion} ${networkVersionData?.mSELastVersionCode}");
} else {
dPrint(
"lastVersion=${networkVersionData?.lastVersion} ${networkVersionData?.lastVersionCode}");
}
} catch (e) {
dPrint("_checkUpdate Error:$e");
}

View File

@ -20,7 +20,6 @@ class AppGlobalUIModel extends BaseUIModel {
Timer? activityThemeColorTimer;
Future<bool> doCheckUpdate(BuildContext context, {bool init = true}) async {
if (AppConf.isMSE) return true;
if (!init) {
try {
await AppConf.checkUpdate();
@ -32,8 +31,10 @@ class AppGlobalUIModel extends BaseUIModel {
"检查更新失败!请检查网络连接... \n进入离线模式.. \n\n请谨慎在离线模式中使用。 \n当前版本构建日期:${AppConf.appVersionDate}\n QQ群940696487");
return false;
}
if (((AppConf.networkVersionData?.lastVersionCode) ?? 0) >
AppConf.appVersionCode) {
final lastVersion = AppConf.isMSE
? AppConf.networkVersionData?.mSELastVersionCode
: AppConf.networkVersionData?.lastVersionCode;
if ((lastVersion ?? 0) > AppConf.appVersionCode) {
// need update
final r = await showDialog(
dismissWithEsc: false,

View File

@ -5,6 +5,7 @@ import 'package:starcitizen_doctor/api/api.dart';
import 'package:starcitizen_doctor/base/ui_model.dart';
import 'package:starcitizen_doctor/common/conf.dart';
import 'package:starcitizen_doctor/common/helper/system_helper.dart';
import 'package:url_launcher/url_launcher_string.dart';
class UpgradeDialogUIModel extends BaseUIModel {
String? description;
@ -19,9 +20,10 @@ class UpgradeDialogUIModel extends BaseUIModel {
Future loadData() async {
// get download url for gitlab release
try {
targetVersion = AppConf.networkVersionData!.lastVersion!;
final r = await Api.getAppReleaseDataByVersionName(
AppConf.networkVersionData!.lastVersion!);
targetVersion = AppConf.isMSE
? AppConf.networkVersionData!.mSELastVersion!
: AppConf.networkVersionData!.lastVersion!;
final r = await Api.getAppReleaseDataByVersionName(targetVersion);
description = r["description"];
final assetsLinks = List.of(r["assets"]?["links"] ?? []);
for (var link in assetsLinks) {
@ -37,6 +39,10 @@ class UpgradeDialogUIModel extends BaseUIModel {
}
doUpgrade() async {
if (AppConf.isMSE) {
launchUrlString("ms-windows-store://pdp/?productid=9NF3SWFWNKL1");
return;
}
isUpgrading = true;
notifyListeners();
final fileName = "${AppConf.getUpgradePath()}/next_SETUP.exe";