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

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,21 +415,23 @@ 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
onPressed: model.appWebLocalizationVersionsData == null ? const ProgressRing()
? null : Button(
: () => model.launchRSI(), onPressed: model.appWebLocalizationVersionsData == null
child: Padding( ? null
padding: const EdgeInsets.all(8.0), : () => model.launchRSI(),
child: Icon( child: Padding(
model.isCurGameRunning padding: const EdgeInsets.all(8.0),
? FluentIcons.stop_solid child: Icon(
: FluentIcons.play, model.isCurGameRunning
color: model.isCurGameRunning ? FluentIcons.stop_solid
? Colors.red.withOpacity(.8) : FluentIcons.play,
: null, color: model.isCurGameRunning
), ? Colors.red.withOpacity(.8)
)), : null,
),
)),
), ),
const SizedBox(width: 12), const SizedBox(width: 12),
Button( Button(

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,19 +490,37 @@ class HomeUIModel extends BaseUIModel {
showToast(context!, "该功能需要一个有效的安装位置"); showToast(context!, "该功能需要一个有效的安装位置");
return; return;
} }
if (isCurGameRunning) {
await Process.run(SystemHelper.powershellPath, ["ps \"StarCitizen\" | kill"]); if (AppConf.isMSE) {
return; 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) { 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: [
makeSettingsItem(const Icon(FluentIcons.reset_device), "重置自动密码填充", if (AppConf.isMSE)
subTitle: makeSettingsItem(const Icon(FluentIcons.reset_device), "重置自动密码填充",
"启用:${model.isEnableAutoLogin ? "已启用" : "已禁用"} 设备支持:${model.isDeviceSupportWinHello ? "支持" : "不支持"} 邮箱:${model.autoLoginEmail} 密码:${model.isEnableAutoLoginPwd ? "已加密保存" : "未保存"}", subTitle:
onTap: model.onResetAutoLogin), "启用:${model.isEnableAutoLogin ? "已启用" : "已禁用"} 设备支持:${model.isDeviceSupportWinHello ? "支持" : "不支持"} 邮箱:${model.autoLoginEmail} 密码:${model.isEnableAutoLoginPwd ? "已加密保存" : "未保存"}",
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,7 +16,9 @@ class SettingUIModel extends BaseUIModel {
final LocalAuthentication localAuth = LocalAuthentication(); final LocalAuthentication localAuth = LocalAuthentication();
isDeviceSupportWinHello = await localAuth.isDeviceSupported(); isDeviceSupportWinHello = await localAuth.isDeviceSupported();
notifyListeners(); notifyListeners();
_updateAutoLoginAccount(); if (AppConf.isMSE) {
_updateAutoLoginAccount();
}
} }
Future<void> onResetAutoLogin() async { Future<void> onResetAutoLogin() async {