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 { try {
networkVersionData = await Api.getAppVersion(); networkVersionData = await Api.getAppVersion();
globalUIModel.checkActivityThemeColor(); globalUIModel.checkActivityThemeColor();
dPrint( if (isMSE) {
"lastVersion=${networkVersionData?.lastVersion} ${networkVersionData?.lastVersionCode}"); dPrint(
"lastVersion=${networkVersionData?.mSELastVersion} ${networkVersionData?.mSELastVersionCode}");
} else {
dPrint(
"lastVersion=${networkVersionData?.lastVersion} ${networkVersionData?.lastVersionCode}");
}
} catch (e) { } catch (e) {
dPrint("_checkUpdate Error:$e"); dPrint("_checkUpdate Error:$e");
} }

View File

@ -20,7 +20,6 @@ class AppGlobalUIModel extends BaseUIModel {
Timer? activityThemeColorTimer; Timer? activityThemeColorTimer;
Future<bool> doCheckUpdate(BuildContext context, {bool init = true}) async { Future<bool> doCheckUpdate(BuildContext context, {bool init = true}) async {
if (AppConf.isMSE) return true;
if (!init) { if (!init) {
try { try {
await AppConf.checkUpdate(); await AppConf.checkUpdate();
@ -32,8 +31,10 @@ class AppGlobalUIModel extends BaseUIModel {
"检查更新失败!请检查网络连接... \n进入离线模式.. \n\n请谨慎在离线模式中使用。 \n当前版本构建日期:${AppConf.appVersionDate}\n QQ群940696487"); "检查更新失败!请检查网络连接... \n进入离线模式.. \n\n请谨慎在离线模式中使用。 \n当前版本构建日期:${AppConf.appVersionDate}\n QQ群940696487");
return false; return false;
} }
if (((AppConf.networkVersionData?.lastVersionCode) ?? 0) > final lastVersion = AppConf.isMSE
AppConf.appVersionCode) { ? AppConf.networkVersionData?.mSELastVersionCode
: AppConf.networkVersionData?.lastVersionCode;
if ((lastVersion ?? 0) > AppConf.appVersionCode) {
// need update // need update
final r = await showDialog( final r = await showDialog(
dismissWithEsc: false, 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/base/ui_model.dart';
import 'package:starcitizen_doctor/common/conf.dart'; import 'package:starcitizen_doctor/common/conf.dart';
import 'package:starcitizen_doctor/common/helper/system_helper.dart'; import 'package:starcitizen_doctor/common/helper/system_helper.dart';
import 'package:url_launcher/url_launcher_string.dart';
class UpgradeDialogUIModel extends BaseUIModel { class UpgradeDialogUIModel extends BaseUIModel {
String? description; String? description;
@ -19,9 +20,10 @@ class UpgradeDialogUIModel extends BaseUIModel {
Future loadData() async { Future loadData() async {
// get download url for gitlab release // get download url for gitlab release
try { try {
targetVersion = AppConf.networkVersionData!.lastVersion!; targetVersion = AppConf.isMSE
final r = await Api.getAppReleaseDataByVersionName( ? AppConf.networkVersionData!.mSELastVersion!
AppConf.networkVersionData!.lastVersion!); : AppConf.networkVersionData!.lastVersion!;
final r = await Api.getAppReleaseDataByVersionName(targetVersion);
description = r["description"]; description = r["description"];
final assetsLinks = List.of(r["assets"]?["links"] ?? []); final assetsLinks = List.of(r["assets"]?["links"] ?? []);
for (var link in assetsLinks) { for (var link in assetsLinks) {
@ -37,6 +39,10 @@ class UpgradeDialogUIModel extends BaseUIModel {
} }
doUpgrade() async { doUpgrade() async {
if (AppConf.isMSE) {
launchUrlString("ms-windows-store://pdp/?productid=9NF3SWFWNKL1");
return;
}
isUpgrading = true; isUpgrading = true;
notifyListeners(); notifyListeners();
final fileName = "${AppConf.getUpgradePath()}/next_SETUP.exe"; final fileName = "${AppConf.getUpgradePath()}/next_SETUP.exe";