增加官方服务器状态展示

取消盒子内置的 CCUGames 汉化
增加外部浏览器拓展下载图标
性能优化选项下线HDR调整(官方已经在 3.20 正式服试装设置 UI)
This commit is contained in:
2023-10-16 23:24:10 +08:00
parent 54d15444d9
commit 9a68167062
4 changed files with 228 additions and 83 deletions

View File

@ -1,3 +1,4 @@
import 'dart:async';
import 'dart:convert';
import 'dart:io';
@ -46,6 +47,18 @@ class HomeUIModel extends BaseUIModel {
AppPlacardData? appPlacardData;
List? scServerStatus;
Timer? serverUpdateTimer;
final statusCnName = const {
"Platform": "平台",
"Persistent Universe": "持续宇宙",
"Electronic Access": "电子访问",
};
bool isRsiLauncherStarting = false;
@override
Future loadData() async {
if (AppConf.networkVersionData == null) return;
@ -53,21 +66,38 @@ class HomeUIModel extends BaseUIModel {
final r = await Api.getAppPlacard();
final box = await Hive.openBox("app_conf");
final version = box.get("close_placard", defaultValue: "");
if (r.enable != true) return;
if (r.alwaysShow != true && version == r.version) return;
appPlacardData = r;
notifyListeners();
if (r.enable == true) {
if (r.alwaysShow != true && version == r.version) {
} else {
appPlacardData = r;
}
}
} catch (e) {
dPrint(e);
}
notifyListeners();
updateSCServerStatus();
}
@override
void initModel() {
reScanPath();
serverUpdateTimer = Timer.periodic(
const Duration(minutes: 1),
(timer) {
updateSCServerStatus();
},
);
super.initModel();
}
@override
void dispose() {
serverUpdateTimer?.cancel();
serverUpdateTimer = null;
super.dispose();
}
Future<void> reScanPath() async {
scInstallPaths.clear();
scInstalledPath = "not_install";
@ -91,6 +121,17 @@ class HomeUIModel extends BaseUIModel {
}
}
updateSCServerStatus() async {
try {
final s = await Api.getScServerStatus();
dPrint("updateSCServerStatus===$s");
scServerStatus = s;
notifyListeners();
} catch (e) {
dPrint(e);
}
}
VoidCallback? doCheck() {
if (isChecking) return null;
return () async {
@ -407,4 +448,20 @@ class HomeUIModel extends BaseUIModel {
await webViewModel.launch(url);
notifyListeners();
}
launchRSI() async {
isRsiLauncherStarting = true;
notifyListeners();
final rsiLauncherInstalledPath = await SystemHelper.getRSILauncherPath();
if (rsiLauncherInstalledPath.isEmpty) {
isRsiLauncherStarting = false;
notifyListeners();
showToast(context!, "未找到 RSI 启动器目录");
return;
}
SystemHelper.checkAndLaunchRSILauncher(rsiLauncherInstalledPath);
await Future.delayed(const Duration(seconds: 3));
isRsiLauncherStarting = false;
notifyListeners();
}
}