diff --git a/lib/common/conf.dart b/lib/common/conf.dart index 112827f..06c168d 100644 --- a/lib/common/conf.dart +++ b/lib/common/conf.dart @@ -44,7 +44,7 @@ class AppConf { static late final WindowsDeviceInfo windowsDeviceInfo; static const isMSE = - String.fromEnvironment("MSE", defaultValue: "false") == "true"; + String.fromEnvironment("MSE", defaultValue: "true") == "true"; static final launchHelperPath = "${AppConf.applicationSupportDir}\\launch_helper.vbs"; diff --git a/lib/ui/about/about_ui.dart b/lib/ui/about/about_ui.dart index 0f9243d..fa1cf3a 100644 --- a/lib/ui/about/about_ui.dart +++ b/lib/ui/about/about_ui.dart @@ -1,7 +1,6 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:starcitizen_doctor/base/ui.dart'; import 'package:starcitizen_doctor/common/conf.dart'; -import 'package:starcitizen_doctor/global_ui_model.dart'; import 'package:url_launcher/url_launcher_string.dart'; import 'about_ui_model.dart'; @@ -25,16 +24,11 @@ class AboutUI extends BaseUI { ), const SizedBox(height: 12), Button( + onPressed: model.checkUpdate, child: const Padding( padding: EdgeInsets.all(4), child: Text("检查更新"), - ), - onPressed: () async { - final hasUpdate = await globalUIModel.checkUpdate(context); - if (!hasUpdate) { - if (mounted) showToast(context, "已是最新版本"); - } - }), + )), const SizedBox(height: 32), Container( decoration: BoxDecoration( diff --git a/lib/ui/about/about_ui_model.dart b/lib/ui/about/about_ui_model.dart index a00fc3f..7df94e9 100644 --- a/lib/ui/about/about_ui_model.dart +++ b/lib/ui/about/about_ui_model.dart @@ -1,5 +1,17 @@ import 'package:starcitizen_doctor/base/ui_model.dart'; +import 'package:starcitizen_doctor/common/conf.dart'; +import 'package:starcitizen_doctor/global_ui_model.dart'; +import 'package:url_launcher/url_launcher_string.dart'; class AboutUIModel extends BaseUIModel { - -} \ No newline at end of file + Future checkUpdate() async { + if (AppConf.isMSE) { + launchUrlString("ms-windows-store://pdp/?productid=9NF3SWFWNKL1"); + return; + } + final hasUpdate = await globalUIModel.checkUpdate(context!); + if (!hasUpdate) { + if (mounted) showToast(context!, "已是最新版本"); + } + } +} diff --git a/lib/ui/home/home_ui.dart b/lib/ui/home/home_ui.dart index 9e31334..b76d953 100644 --- a/lib/ui/home/home_ui.dart +++ b/lib/ui/home/home_ui.dart @@ -415,21 +415,23 @@ class HomeUI extends BaseUI { const SizedBox(width: 12), AnimatedSize( duration: const Duration(milliseconds: 130), - child: Button( - onPressed: model.appWebLocalizationVersionsData == null - ? null - : () => model.launchRSI(), - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Icon( - model.isCurGameRunning - ? FluentIcons.stop_solid - : FluentIcons.play, - color: model.isCurGameRunning - ? Colors.red.withOpacity(.8) - : null, - ), - )), + child: model.isRsiLauncherStarting + ? const ProgressRing() + : Button( + onPressed: model.appWebLocalizationVersionsData == null + ? null + : () => model.launchRSI(), + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Icon( + model.isCurGameRunning + ? FluentIcons.stop_solid + : FluentIcons.play, + color: model.isCurGameRunning + ? Colors.red.withOpacity(.8) + : null, + ), + )), ), const SizedBox(width: 12), Button( diff --git a/lib/ui/home/home_ui_model.dart b/lib/ui/home/home_ui_model.dart index e895e62..62350ac 100644 --- a/lib/ui/home/home_ui_model.dart +++ b/lib/ui/home/home_ui_model.dart @@ -74,6 +74,8 @@ class HomeUIModel extends BaseUIModel { "Arena Commander": "竞技场指挥官" }; + bool isRsiLauncherStarting = false; + @override Future loadData() async { if (AppConf.networkVersionData == null) return; @@ -488,19 +490,37 @@ class HomeUIModel extends BaseUIModel { showToast(context!, "该功能需要一个有效的安装位置"); return; } - if (isCurGameRunning) { - await Process.run(SystemHelper.powershellPath, ["ps \"StarCitizen\" | kill"]); - return; + + if (AppConf.isMSE) { + if (isCurGameRunning) { + await Process.run( + SystemHelper.powershellPath, ["ps \"StarCitizen\" | kill"]); + return; + } + AnalyticsApi.touch("gameLaunch"); + showDialog( + context: context!, + dismissWithEsc: false, + builder: (context) { + return BaseUIContainer( + uiCreate: () => LoginDialog(), + modelCreate: () => LoginDialogModel(scInstalledPath, this)); + }); + } else { + 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(); } - AnalyticsApi.touch("gameLaunch"); - showDialog( - context: context!, - dismissWithEsc: false, - builder: (context) { - return BaseUIContainer( - uiCreate: () => LoginDialog(), - modelCreate: () => LoginDialogModel(scInstalledPath, this)); - }); } bool isRSIServerStatusOK(Map map) { diff --git a/lib/ui/settings/settings_ui.dart b/lib/ui/settings/settings_ui.dart index 2a84d00..559df34 100644 --- a/lib/ui/settings/settings_ui.dart +++ b/lib/ui/settings/settings_ui.dart @@ -1,4 +1,5 @@ import 'package:starcitizen_doctor/base/ui.dart'; +import 'package:starcitizen_doctor/common/conf.dart'; import 'package:starcitizen_doctor/ui/settings/settings_ui_model.dart'; class SettingUI extends BaseUI { @@ -10,10 +11,13 @@ class SettingUI extends BaseUI { margin: const EdgeInsets.all(16), child: Column( children: [ - makeSettingsItem(const Icon(FluentIcons.reset_device), "重置自动密码填充", - subTitle: - "启用:${model.isEnableAutoLogin ? "已启用" : "已禁用"} 设备支持:${model.isDeviceSupportWinHello ? "支持" : "不支持"} 邮箱:${model.autoLoginEmail} 密码:${model.isEnableAutoLoginPwd ? "已加密保存" : "未保存"}", - onTap: model.onResetAutoLogin), + if (AppConf.isMSE) + makeSettingsItem(const Icon(FluentIcons.reset_device), "重置自动密码填充", + subTitle: + "启用:${model.isEnableAutoLogin ? "已启用" : "已禁用"} 设备支持:${model.isDeviceSupportWinHello ? "支持" : "不支持"} 邮箱:${model.autoLoginEmail} 密码:${model.isEnableAutoLoginPwd ? "已加密保存" : "未保存"}", + onTap: model.onResetAutoLogin) + else + const Text("暂无设置项"), ], ), ); diff --git a/lib/ui/settings/settings_ui_model.dart b/lib/ui/settings/settings_ui_model.dart index 9f7336f..c8c77fd 100644 --- a/lib/ui/settings/settings_ui_model.dart +++ b/lib/ui/settings/settings_ui_model.dart @@ -1,6 +1,7 @@ import 'package:hive/hive.dart'; import 'package:local_auth/local_auth.dart'; import 'package:starcitizen_doctor/base/ui_model.dart'; +import 'package:starcitizen_doctor/common/conf.dart'; import 'package:starcitizen_doctor/common/win32/credentials.dart'; class SettingUIModel extends BaseUIModel { @@ -15,7 +16,9 @@ class SettingUIModel extends BaseUIModel { final LocalAuthentication localAuth = LocalAuthentication(); isDeviceSupportWinHello = await localAuth.isDeviceSupported(); notifyListeners(); - _updateAutoLoginAccount(); + if (AppConf.isMSE) { + _updateAutoLoginAccount(); + } } Future onResetAutoLogin() async {