为账户安全,游戏登入功能将只支持微软商店版

This commit is contained in:
xkeyC 2023-11-07 22:49:09 +08:00
parent 7257e34653
commit 8d79c1bce2
7 changed files with 78 additions and 43 deletions

View File

@ -44,7 +44,7 @@ class AppConf {
static late final WindowsDeviceInfo windowsDeviceInfo; static late final WindowsDeviceInfo windowsDeviceInfo;
static const isMSE = static const isMSE =
String.fromEnvironment("MSE", defaultValue: "false") == "true"; String.fromEnvironment("MSE", defaultValue: "true") == "true";
static final launchHelperPath = static final launchHelperPath =
"${AppConf.applicationSupportDir}\\launch_helper.vbs"; "${AppConf.applicationSupportDir}\\launch_helper.vbs";

View File

@ -1,7 +1,6 @@
import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:starcitizen_doctor/base/ui.dart'; import 'package:starcitizen_doctor/base/ui.dart';
import 'package:starcitizen_doctor/common/conf.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 'package:url_launcher/url_launcher_string.dart';
import 'about_ui_model.dart'; import 'about_ui_model.dart';
@ -25,16 +24,11 @@ class AboutUI extends BaseUI<AboutUIModel> {
), ),
const SizedBox(height: 12), const SizedBox(height: 12),
Button( Button(
onPressed: model.checkUpdate,
child: const Padding( child: const Padding(
padding: EdgeInsets.all(4), padding: EdgeInsets.all(4),
child: Text("检查更新"), child: Text("检查更新"),
), )),
onPressed: () async {
final hasUpdate = await globalUIModel.checkUpdate(context);
if (!hasUpdate) {
if (mounted) showToast(context, "已是最新版本");
}
}),
const SizedBox(height: 32), const SizedBox(height: 32),
Container( Container(
decoration: BoxDecoration( decoration: BoxDecoration(

View File

@ -1,5 +1,17 @@
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/global_ui_model.dart';
import 'package:url_launcher/url_launcher_string.dart';
class AboutUIModel extends BaseUIModel { class AboutUIModel extends BaseUIModel {
Future<void> 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!, "已是最新版本");
}
}
} }

View File

@ -415,7 +415,9 @@ class HomeUI extends BaseUI<HomeUIModel> {
const SizedBox(width: 12), const SizedBox(width: 12),
AnimatedSize( AnimatedSize(
duration: const Duration(milliseconds: 130), duration: const Duration(milliseconds: 130),
child: Button( child: model.isRsiLauncherStarting
? const ProgressRing()
: Button(
onPressed: model.appWebLocalizationVersionsData == null onPressed: model.appWebLocalizationVersionsData == null
? null ? null
: () => model.launchRSI(), : () => model.launchRSI(),

View File

@ -74,6 +74,8 @@ class HomeUIModel extends BaseUIModel {
"Arena Commander": "竞技场指挥官" "Arena Commander": "竞技场指挥官"
}; };
bool isRsiLauncherStarting = false;
@override @override
Future loadData() async { Future loadData() async {
if (AppConf.networkVersionData == null) return; if (AppConf.networkVersionData == null) return;
@ -488,8 +490,11 @@ class HomeUIModel extends BaseUIModel {
showToast(context!, "该功能需要一个有效的安装位置"); showToast(context!, "该功能需要一个有效的安装位置");
return; return;
} }
if (AppConf.isMSE) {
if (isCurGameRunning) { if (isCurGameRunning) {
await Process.run(SystemHelper.powershellPath, ["ps \"StarCitizen\" | kill"]); await Process.run(
SystemHelper.powershellPath, ["ps \"StarCitizen\" | kill"]);
return; return;
} }
AnalyticsApi.touch("gameLaunch"); AnalyticsApi.touch("gameLaunch");
@ -501,6 +506,21 @@ class HomeUIModel extends BaseUIModel {
uiCreate: () => LoginDialog(), uiCreate: () => LoginDialog(),
modelCreate: () => LoginDialogModel(scInstalledPath, this)); 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();
}
} }
bool isRSIServerStatusOK(Map map) { bool isRSIServerStatusOK(Map map) {

View File

@ -1,4 +1,5 @@
import 'package:starcitizen_doctor/base/ui.dart'; import 'package:starcitizen_doctor/base/ui.dart';
import 'package:starcitizen_doctor/common/conf.dart';
import 'package:starcitizen_doctor/ui/settings/settings_ui_model.dart'; import 'package:starcitizen_doctor/ui/settings/settings_ui_model.dart';
class SettingUI extends BaseUI<SettingUIModel> { class SettingUI extends BaseUI<SettingUIModel> {
@ -10,10 +11,13 @@ class SettingUI extends BaseUI<SettingUIModel> {
margin: const EdgeInsets.all(16), margin: const EdgeInsets.all(16),
child: Column( child: Column(
children: [ children: [
if (AppConf.isMSE)
makeSettingsItem(const Icon(FluentIcons.reset_device), "重置自动密码填充", makeSettingsItem(const Icon(FluentIcons.reset_device), "重置自动密码填充",
subTitle: subTitle:
"启用:${model.isEnableAutoLogin ? "已启用" : "已禁用"} 设备支持:${model.isDeviceSupportWinHello ? "支持" : "不支持"} 邮箱:${model.autoLoginEmail} 密码:${model.isEnableAutoLoginPwd ? "已加密保存" : "未保存"}", "启用:${model.isEnableAutoLogin ? "已启用" : "已禁用"} 设备支持:${model.isDeviceSupportWinHello ? "支持" : "不支持"} 邮箱:${model.autoLoginEmail} 密码:${model.isEnableAutoLoginPwd ? "已加密保存" : "未保存"}",
onTap: model.onResetAutoLogin), onTap: model.onResetAutoLogin)
else
const Text("暂无设置项"),
], ],
), ),
); );

View File

@ -1,6 +1,7 @@
import 'package:hive/hive.dart'; import 'package:hive/hive.dart';
import 'package:local_auth/local_auth.dart'; import 'package:local_auth/local_auth.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/win32/credentials.dart'; import 'package:starcitizen_doctor/common/win32/credentials.dart';
class SettingUIModel extends BaseUIModel { class SettingUIModel extends BaseUIModel {
@ -15,8 +16,10 @@ class SettingUIModel extends BaseUIModel {
final LocalAuthentication localAuth = LocalAuthentication(); final LocalAuthentication localAuth = LocalAuthentication();
isDeviceSupportWinHello = await localAuth.isDeviceSupported(); isDeviceSupportWinHello = await localAuth.isDeviceSupported();
notifyListeners(); notifyListeners();
if (AppConf.isMSE) {
_updateAutoLoginAccount(); _updateAutoLoginAccount();
} }
}
Future<void> onResetAutoLogin() async { Future<void> onResetAutoLogin() async {
final userBox = await Hive.openBox("rsi_account_data"); final userBox = await Hive.openBox("rsi_account_data");