mirror of
https://ghfast.top/https://github.com/StarCitizenToolBox/app.git
synced 2025-07-30 05:53:19 +08:00
优化自动登录
This commit is contained in:
@ -4,8 +4,56 @@ import 'package:starcitizen_doctor/ui/settings/settings_ui_model.dart';
|
||||
class SettingUI extends BaseUI<SettingUIModel> {
|
||||
@override
|
||||
Widget? buildBody(BuildContext context, SettingUIModel model) {
|
||||
return const Center(
|
||||
child: Text("暂时没啥好设置的。"),
|
||||
return Container(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
height: MediaQuery.of(context).size.height,
|
||||
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),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget makeSettingsItem(Widget icon, String title,
|
||||
{String? subTitle, VoidCallback? onTap}) {
|
||||
return Button(
|
||||
onPressed: onTap,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(top: 12, bottom: 12),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
icon,
|
||||
const SizedBox(width: 12),
|
||||
Text(title),
|
||||
const Spacer(),
|
||||
],
|
||||
),
|
||||
if (subTitle != null) ...[
|
||||
const SizedBox(height: 3),
|
||||
Text(
|
||||
subTitle,
|
||||
style: TextStyle(
|
||||
fontSize: 12, color: Colors.white.withOpacity(.6)),
|
||||
)
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
const Icon(FluentIcons.chevron_right),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,37 @@
|
||||
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/win32/credentials.dart';
|
||||
|
||||
class SettingUIModel extends BaseUIModel {
|
||||
var isDeviceSupportWinHello = false;
|
||||
|
||||
}
|
||||
String autoLoginEmail = "-";
|
||||
bool isEnableAutoLogin = false;
|
||||
bool isEnableAutoLoginPwd = false;
|
||||
|
||||
@override
|
||||
loadData() async {
|
||||
final LocalAuthentication localAuth = LocalAuthentication();
|
||||
isDeviceSupportWinHello = await localAuth.isDeviceSupported();
|
||||
notifyListeners();
|
||||
_updateAutoLoginAccount();
|
||||
}
|
||||
|
||||
Future<void> onResetAutoLogin() async {
|
||||
final userBox = await Hive.openBox("rsi_account_data");
|
||||
await userBox.deleteFromDisk();
|
||||
Win32Credentials.delete("SCToolbox_RSI_Account_secret");
|
||||
showToast(context!, "已清理自动填充数据");
|
||||
reloadData();
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user