2023-11-07 20:47:28 +08:00
|
|
|
import 'package:hive/hive.dart';
|
|
|
|
import 'package:local_auth/local_auth.dart';
|
2023-10-09 09:32:07 +08:00
|
|
|
import 'package:starcitizen_doctor/base/ui_model.dart';
|
2023-11-07 22:49:09 +08:00
|
|
|
import 'package:starcitizen_doctor/common/conf.dart';
|
2023-11-07 20:47:28 +08:00
|
|
|
import 'package:starcitizen_doctor/common/win32/credentials.dart';
|
2023-10-09 09:32:07 +08:00
|
|
|
|
|
|
|
class SettingUIModel extends BaseUIModel {
|
2023-11-07 20:47:28 +08:00
|
|
|
var isDeviceSupportWinHello = false;
|
2023-10-09 09:32:07 +08:00
|
|
|
|
2023-11-07 20:47:28 +08:00
|
|
|
String autoLoginEmail = "-";
|
|
|
|
bool isEnableAutoLogin = false;
|
|
|
|
bool isEnableAutoLoginPwd = false;
|
|
|
|
|
|
|
|
@override
|
|
|
|
loadData() async {
|
|
|
|
final LocalAuthentication localAuth = LocalAuthentication();
|
|
|
|
isDeviceSupportWinHello = await localAuth.isDeviceSupported();
|
|
|
|
notifyListeners();
|
2023-11-07 22:49:09 +08:00
|
|
|
if (AppConf.isMSE) {
|
|
|
|
_updateAutoLoginAccount();
|
|
|
|
}
|
2023-11-07 20:47:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> onResetAutoLogin() async {
|
2023-11-10 22:20:23 +08:00
|
|
|
final ok = await showConfirmDialogs(context!, "确认重置自动填充?",
|
|
|
|
const Text("这将会删除本地的账号记录,或在下次启动游戏时将自动填充选择 ‘否’ 以禁用自动填充。"));
|
|
|
|
if (ok) {
|
|
|
|
final userBox = await Hive.openBox("rsi_account_data");
|
|
|
|
await userBox.deleteFromDisk();
|
|
|
|
Win32Credentials.delete("SCToolbox_RSI_Account_secret");
|
|
|
|
showToast(context!, "已清理自动填充数据");
|
|
|
|
reloadData();
|
|
|
|
}
|
2023-11-07 20:47:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Future _updateAutoLoginAccount() async {
|
|
|
|
final userBox = await Hive.openBox("rsi_account_data");
|
|
|
|
autoLoginEmail = userBox.get("account_email", defaultValue: "-");
|
|
|
|
isEnableAutoLogin = userBox.get("enable", defaultValue: true);
|
|
|
|
isEnableAutoLoginPwd =
|
|
|
|
userBox.get("account_pwd_encrypted", defaultValue: "") != "";
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
}
|