This commit is contained in:
xkeyC 2023-10-28 19:15:13 +08:00
parent e465bc913d
commit d63d07a1a9
4 changed files with 42 additions and 45 deletions

View File

@ -35,8 +35,10 @@ class AppConf {
WidgetsFlutterBinding.ensureInitialized();
/// init device info
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
windowsDeviceInfo = await deviceInfo.windowsInfo;
try {
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
windowsDeviceInfo = await deviceInfo.windowsInfo;
}catch (_){}
/// init Data
applicationSupportDir =
@ -85,7 +87,8 @@ class AppConf {
try {
networkVersionData = await Api.getAppVersion();
dPrint(
"lastVersion=${networkVersionData?.lastVersion} ${networkVersionData?.lastVersionCode}");
"lastVersion=${networkVersionData?.lastVersion} ${networkVersionData
?.lastVersionCode}");
} catch (e) {
dPrint("_checkUpdate Error:$e");
}

View File

@ -133,8 +133,8 @@ class HomeUI extends BaseUI<HomeUIModel> {
const SizedBox(width: 12),
],
),
name: "DPSCalculator 汉化",
webTitle: "DPSCalculatorLIVE 汉化",
name: "DPS计算器汉化",
webTitle: "DPS计算器汉化",
webURL: "https://www.erkul.games/live/calculator",
info: "在线改船,查询伤害数值和配件购买地点",
useLocalization: true,

View File

@ -32,7 +32,7 @@ class LoginDialog extends BaseUI<LoginDialogModel> {
Text("请输入RSI账户 [${model.nickname}] 的邮箱,以保存登录状态(输入错误会导致无法进入游戏!)"),
const SizedBox(height: 12),
TextFormBox(
controller: model.emailCtrl,
// controller: model.emailCtrl,
),
const SizedBox(height: 6),
Text(
@ -79,24 +79,24 @@ class LoginDialog extends BaseUI<LoginDialogModel> {
],
),
),
actions: [
if (model.loginStatus == 1) ...[
Button(
child: const Padding(
padding: EdgeInsets.all(4),
child: Text("取消"),
),
onPressed: () {
Navigator.pop(context);
}),
const SizedBox(width: 80),
FilledButton(
child: const Padding(
padding: EdgeInsets.all(4),
child: Text("保存"),
),
onPressed: () => model.onSaveEmail()),
],
actions: const [
// if (model.loginStatus == 1) ...[
// Button(
// child: const Padding(
// padding: EdgeInsets.all(4),
// child: Text("取消"),
// ),
// onPressed: () {
// Navigator.pop(context);
// }),
// const SizedBox(width: 80),
// FilledButton(
// child: const Padding(
// padding: EdgeInsets.all(4),
// child: Text("保存"),
// ),
// onPressed: () => model.onSaveEmail()),
// ],
],
);
}

View File

@ -23,7 +23,7 @@ class LoginDialogModel extends BaseUIModel {
final HomeUIModel homeUIModel;
TextEditingController emailCtrl = TextEditingController();
// TextEditingController emailCtrl = TextEditingController();
LoginDialogModel(this.installPath, this.homeUIModel);
@ -42,7 +42,7 @@ class LoginDialogModel extends BaseUIModel {
Navigator.pop(context!);
return;
}
final emailBox = await Hive.openBox("quick_login_email");
// final emailBox = await Hive.openBox("quick_login_email");
final data = message["data"];
authToken = data["authToken"];
webToken = data["webToken"];
@ -53,13 +53,7 @@ class LoginDialogModel extends BaseUIModel {
.replaceAll("\")", "");
Map<String, dynamic> payload = Jwt.parseJwt(authToken!);
nickname = payload["nickname"] ?? "";
if (emailBox.get(nickname, defaultValue: "") == "") {
loginStatus = 1;
notifyListeners();
} else {
emailCtrl.text = emailBox.get(nickname, defaultValue: "");
_readyForLaunch();
}
_readyForLaunch();
}, useLocalization: true);
}
@ -114,23 +108,23 @@ class LoginDialogModel extends BaseUIModel {
notifyListeners();
}
onSaveEmail() async {
final RegExp emailRegex = RegExp(r'^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$');
if (!emailRegex.hasMatch(emailCtrl.text.trim())) {
showToast(context!, "邮箱输入有误!");
return;
}
final emailBox = await Hive.openBox("quick_login_email");
await emailBox.put(nickname, emailCtrl.text.trim());
_readyForLaunch();
notifyListeners();
}
// onSaveEmail() async {
// final RegExp emailRegex = RegExp(r'^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$');
// if (!emailRegex.hasMatch(emailCtrl.text.trim())) {
// showToast(context!, "邮箱输入有误!");
// return;
// }
// final emailBox = await Hive.openBox("quick_login_email");
// await emailBox.put(nickname, emailCtrl.text.trim());
// _readyForLaunch();
// notifyListeners();
// }
Future<void> _readyForLaunch() async {
loginStatus = 2;
notifyListeners();
final launchData = {
"username": emailCtrl.text.trim(),
"username": "",
"token": webToken,
"auth_token": authToken,
"star_network": {