mirror of
https://mirror.ghproxy.com/https://github.com/StarCitizenToolBox/app.git
synced 2024-12-23 00:33:42 +08:00
优化自动登录
This commit is contained in:
parent
c92078b931
commit
183864054e
@ -246,6 +246,8 @@ async function getRSILauncherToken(channelId) {
|
||||
return;
|
||||
}
|
||||
|
||||
SCTShowToast("登录游戏中...");
|
||||
|
||||
// get claims
|
||||
let claimsR = await fetch("api/launcher/v3/games/claims", {
|
||||
method: 'POST', headers: {
|
||||
@ -311,9 +313,9 @@ function RSIAutoLogin(email, pwd) {
|
||||
if (pwd !== "") {
|
||||
$('#password').val(pwd)
|
||||
}
|
||||
sessionStorage.setItem('inputEmail', '');
|
||||
sessionStorage.setItem('inputPassword', '');
|
||||
if (email !== "" && pwd !== "") {
|
||||
$("#remember").prop("checked", true);
|
||||
$('.c-form__submit-button-label').click();
|
||||
}
|
||||
});
|
||||
|
@ -234,8 +234,9 @@ class HomeUI extends BaseUI<HomeUIModel> {
|
||||
autoplay: true,
|
||||
autoplayDelay: 5000,
|
||||
itemBuilder: (context, index) {
|
||||
final item = model
|
||||
.countdownFestivalListData![index];
|
||||
final item =
|
||||
model.countdownFestivalListData![
|
||||
index];
|
||||
return Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceEvenly,
|
||||
@ -244,11 +245,13 @@ class HomeUI extends BaseUI<HomeUIModel> {
|
||||
item.icon != "") ...[
|
||||
ClipRRect(
|
||||
borderRadius:
|
||||
BorderRadius.circular(1000),
|
||||
BorderRadius.circular(
|
||||
1000),
|
||||
child: Image.asset(
|
||||
"assets/countdown/${item.icon}",
|
||||
width: 48,
|
||||
height: 48,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
@ -25,6 +25,7 @@ class LoginDialog extends BaseUI<LoginDialogModel> {
|
||||
const Text("登录中..."),
|
||||
const SizedBox(height: 12),
|
||||
const ProgressRing(),
|
||||
if (model.isDeviceSupportWinHello)
|
||||
const SizedBox(height: 24),
|
||||
Text(
|
||||
"* 若开启了自动填充,请留意弹出的 Windows Hello 窗口",
|
||||
|
@ -32,17 +32,21 @@ class LoginDialogModel extends BaseUIModel {
|
||||
|
||||
final LocalAuthentication localAuth = LocalAuthentication();
|
||||
|
||||
var isDeviceSupportWinHello = false;
|
||||
|
||||
@override
|
||||
void initModel() {
|
||||
_launchWebLogin();
|
||||
super.initModel();
|
||||
}
|
||||
|
||||
void _launchWebLogin() {
|
||||
Future<void> _launchWebLogin() async {
|
||||
isDeviceSupportWinHello = await localAuth.isDeviceSupported();
|
||||
notifyListeners();
|
||||
goWebView("登录 RSI 账户", "https://robertsspaceindustries.com/connect",
|
||||
loginMode: true, rsiLoginCallback: (message, ok) async {
|
||||
dPrint(
|
||||
"======rsiLoginCallback=== $ok ===== data==\n${json.encode(message)}");
|
||||
// dPrint(
|
||||
// "======rsiLoginCallback=== $ok ===== data==\n${json.encode(message)}");
|
||||
if (message == null || !ok) {
|
||||
Navigator.pop(context!);
|
||||
return;
|
||||
@ -62,12 +66,12 @@ class LoginDialogModel extends BaseUIModel {
|
||||
final inputEmail = data["inputEmail"];
|
||||
final inputPassword = data["inputPassword"];
|
||||
|
||||
if (inputEmail != null && inputEmail != "") {
|
||||
final userBox = await Hive.openBox("rsi_account_data");
|
||||
if (inputEmail != null && inputEmail != "") {
|
||||
await userBox.put("account_email", inputEmail);
|
||||
}
|
||||
|
||||
if (await localAuth.isDeviceSupported()) {
|
||||
if (isDeviceSupportWinHello) {
|
||||
if (await userBox.get("enable", defaultValue: true)) {
|
||||
if (inputEmail != null &&
|
||||
inputEmail != "" &&
|
||||
inputPassword != null &&
|
||||
@ -82,6 +86,9 @@ class LoginDialogModel extends BaseUIModel {
|
||||
true) {
|
||||
await _savePwd(inputEmail, inputPassword);
|
||||
}
|
||||
} else {
|
||||
await userBox.put("enable", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user