feat: networkGameChannels Support

This commit is contained in:
xkeyC 2024-12-20 19:17:30 +08:00
parent 33f8866bb9
commit 43d0d8454c
17 changed files with 50 additions and 27 deletions

View File

@ -10,7 +10,7 @@ import 'package:hexcolor/hexcolor.dart';
import 'package:hive/hive.dart';
import 'package:path_provider/path_provider.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:starcitizen_doctor/common/conf/const_conf.dart';
import 'package:starcitizen_doctor/common/conf/conf.dart';
import 'package:starcitizen_doctor/common/utils/log.dart';
import 'package:starcitizen_doctor/ui/guide/guide_ui.dart';
import 'package:starcitizen_doctor/ui/home/performance/performance_ui.dart';
@ -214,6 +214,8 @@ class AppGlobalModel extends _$AppGlobalModel {
try {
final networkVersionData = await Api.getAppVersion();
dPrint("networkVersionData == ${networkVersionData.toJson()}");
AppConf.setNetworkChannels(networkVersionData.gameChannels);
checkActivityThemeColor(networkVersionData);
if (ConstConf.isMSE) {
dPrint(

28
lib/common/conf/conf.dart Normal file
View File

@ -0,0 +1,28 @@
class ConstConf {
static const String appVersion = "2.13.3";
static const int appVersionCode = 61;
static const String appVersionDate = "2024-11-23";
static const _gameChannels = [
"LIVE",
"4.0_PREVIEW",
"PTU",
"EPTU",
"TECH-PREVIEW",
"HOTFIX"
];
static const isMSE =
String.fromEnvironment("MSE", defaultValue: "false") == "true";
static const dohAddress = "https://223.6.6.6/resolve";
static const inputMethodServerPort = 59399;
}
class AppConf {
static List<String>? _networkGameChannels;
static setNetworkChannels(List<String>? channels) {
_networkGameChannels = channels;
}
static List<String> get gameChannels =>
_networkGameChannels ?? ConstConf._gameChannels;
}

View File

@ -1,10 +0,0 @@
class ConstConf {
static const String appVersion = "2.13.3";
static const int appVersionCode = 61;
static const String appVersionDate = "2024-11-23";
static const gameChannels = ["LIVE", "4.0_PREVIEW","PTU", "EPTU", "TECH-PREVIEW", "HOTFIX"];
static const isMSE =
String.fromEnvironment("MSE", defaultValue: "false") == "true";
static const dohAddress = "https://223.6.6.6/resolve";
static const inputMethodServerPort = 59399;
}

View File

@ -2,7 +2,7 @@ import 'dart:convert';
import 'dart:io';
import 'package:hive/hive.dart';
import 'package:starcitizen_doctor/common/conf/const_conf.dart';
import 'package:starcitizen_doctor/common/conf/conf.dart';
import 'package:starcitizen_doctor/common/utils/log.dart';
class SCLoggerHelper {
@ -108,7 +108,7 @@ class SCLoggerHelper {
}
static String getGameChannelID(String installPath) {
for (var value in ConstConf.gameChannels) {
for (var value in AppConf.gameChannels) {
if (installPath.endsWith("\\$value")) {
return value;
}

View File

@ -1,6 +1,6 @@
import 'dart:convert';
import 'package:starcitizen_doctor/common/conf/const_conf.dart';
import 'package:starcitizen_doctor/common/conf/conf.dart';
import 'package:starcitizen_doctor/common/io/rs_http.dart';
import 'package:starcitizen_doctor/common/utils/log.dart';
import 'package:starcitizen_doctor/data/doh_client_response_data.dart';

View File

@ -1,7 +1,7 @@
import 'dart:convert';
import 'dart:typed_data';
import 'package:starcitizen_doctor/common/conf/const_conf.dart';
import 'package:starcitizen_doctor/common/conf/conf.dart';
import 'package:starcitizen_doctor/common/rust/api/http_api.dart' as rust_http;
import 'package:starcitizen_doctor/common/rust/api/http_api.dart';
import 'package:starcitizen_doctor/common/rust/http_package.dart';

View File

@ -30,6 +30,7 @@ class AppVersionData {
activityColors = json['activityColors'] != null
? ActivityColors.fromJson(json['activityColors'])
: null;
gameChannels = List.from(json["game_channels"]).cast<String>();
webMirrors = json["web_mirrors"];
}
@ -41,6 +42,7 @@ class AppVersionData {
num? mSEMinVersionCode;
String? p4kDownloadUrl;
ActivityColors? activityColors;
List<String>? gameChannels;
Map? webMirrors;
Map<String, dynamic> toJson() {
@ -56,6 +58,7 @@ class AppVersionData {
map['activityColors'] = activityColors?.toJson();
}
map["web_mirrors"] = webMirrors;
map["game_channels"] = gameChannels;
return map;
}
}

View File

@ -4,7 +4,7 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:starcitizen_doctor/api/analytics.dart';
import 'package:starcitizen_doctor/app.dart';
import 'package:starcitizen_doctor/common/conf/const_conf.dart';
import 'package:starcitizen_doctor/common/conf/conf.dart';
import 'package:starcitizen_doctor/common/conf/url_conf.dart';
import 'package:starcitizen_doctor/widgets/src/flow_number_text.dart';
import 'package:starcitizen_doctor/widgets/widgets.dart';

View File

@ -3,7 +3,7 @@ import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:go_router/go_router.dart';
import 'package:hive/hive.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:starcitizen_doctor/common/conf/const_conf.dart';
import 'package:starcitizen_doctor/common/conf/conf.dart';
import 'package:starcitizen_doctor/common/conf/url_conf.dart';
import 'package:starcitizen_doctor/ui/settings/settings_ui_model.dart';
import 'package:starcitizen_doctor/ui/tools/tools_ui_model.dart';

View File

@ -11,7 +11,7 @@ import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:starcitizen_doctor/api/analytics.dart';
import 'package:starcitizen_doctor/api/api.dart';
import 'package:starcitizen_doctor/api/rss.dart';
import 'package:starcitizen_doctor/common/conf/const_conf.dart';
import 'package:starcitizen_doctor/common/conf/conf.dart';
import 'package:starcitizen_doctor/common/conf/url_conf.dart';
import 'package:starcitizen_doctor/common/helper/log_helper.dart';
import 'package:starcitizen_doctor/common/helper/system_helper.dart';

View File

@ -8,7 +8,7 @@ import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:shelf/shelf.dart';
import 'package:shelf/shelf_io.dart' as shelf_io;
import 'package:starcitizen_doctor/common/conf/const_conf.dart';
import 'package:starcitizen_doctor/common/conf/conf.dart';
import 'package:starcitizen_doctor/common/utils/log.dart';
import 'package:starcitizen_doctor/ui/home/input_method/server_qr_dialog_ui.dart';
import 'package:starcitizen_doctor/ui/home/localization/localization_ui_model.dart';

View File

@ -11,7 +11,7 @@ import 'package:hive/hive.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:starcitizen_doctor/api/analytics.dart';
import 'package:starcitizen_doctor/api/api.dart';
import 'package:starcitizen_doctor/common/conf/const_conf.dart';
import 'package:starcitizen_doctor/common/conf/conf.dart';
import 'package:starcitizen_doctor/common/conf/url_conf.dart';
import 'package:starcitizen_doctor/common/io/rs_http.dart';
import 'package:starcitizen_doctor/common/utils/log.dart';
@ -578,7 +578,7 @@ class LocalizationUIModel extends _$LocalizationUIModel {
dPrint("check Localization update $scInstallPath");
if (!(curData?.keys.contains(installedVersion) ?? false)) {
// has update
for (var channel in ConstConf.gameChannels) {
for (var channel in AppConf.gameChannels) {
if (scInstallPath.contains(channel)) {
dPrint("check Localization update: has update -> $channel");
updates.add(channel);

View File

@ -3,7 +3,7 @@ import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:go_router/go_router.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:starcitizen_doctor/app.dart';
import 'package:starcitizen_doctor/common/conf/const_conf.dart';
import 'package:starcitizen_doctor/common/conf/conf.dart';
import 'package:starcitizen_doctor/provider/aria2c.dart';
import 'package:starcitizen_doctor/ui/home/home_ui_model.dart';
import 'package:starcitizen_doctor/ui/settings/settings_ui_model.dart';

View File

@ -7,7 +7,7 @@ import 'package:flutter/services.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:hive/hive.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:starcitizen_doctor/common/conf/const_conf.dart';
import 'package:starcitizen_doctor/common/conf/conf.dart';
import 'package:starcitizen_doctor/common/helper/system_helper.dart';
import 'package:starcitizen_doctor/common/utils/log.dart';
import 'package:starcitizen_doctor/common/utils/provider.dart';

View File

@ -8,7 +8,7 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:markdown/markdown.dart' as markdown;
import 'package:starcitizen_doctor/api/api.dart';
import 'package:starcitizen_doctor/app.dart';
import 'package:starcitizen_doctor/common/conf/const_conf.dart';
import 'package:starcitizen_doctor/common/conf/conf.dart';
import 'package:starcitizen_doctor/common/conf/url_conf.dart';
import 'package:starcitizen_doctor/common/helper/system_helper.dart';
import 'package:starcitizen_doctor/common/utils/log.dart';

View File

@ -8,7 +8,7 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:markdown_widget/widget/markdown.dart';
import 'package:starcitizen_doctor/api/analytics.dart';
import 'package:starcitizen_doctor/app.dart';
import 'package:starcitizen_doctor/common/conf/const_conf.dart';
import 'package:starcitizen_doctor/common/conf/conf.dart';
import 'package:starcitizen_doctor/common/conf/url_conf.dart';
import 'package:starcitizen_doctor/common/utils/log.dart';
import 'package:starcitizen_doctor/provider/aria2c.dart';

View File

@ -11,7 +11,7 @@ import 'package:go_router/go_router.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:starcitizen_doctor/api/analytics.dart';
import 'package:starcitizen_doctor/api/api.dart';
import 'package:starcitizen_doctor/common/conf/const_conf.dart';
import 'package:starcitizen_doctor/common/conf/conf.dart';
import 'package:starcitizen_doctor/common/conf/url_conf.dart';
import 'package:starcitizen_doctor/common/helper/log_helper.dart';
import 'package:starcitizen_doctor/common/helper/system_helper.dart';
@ -268,7 +268,7 @@ class ToolsUIModel extends _$ToolsUIModel {
return;
}
scInstallPaths = await SCLoggerHelper.getGameInstallPath(listData,
checkExists: checkActive, withVersion: ConstConf.gameChannels);
checkExists: checkActive, withVersion: AppConf.gameChannels);
if (scInstallPaths.isNotEmpty) {
scInstalledPath = scInstallPaths.first;
}