|
|
|
|
@ -142,10 +142,12 @@ public class Main extends Application {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!email.contains("@")) {
|
|
|
|
|
infoLabel.setText("邮箱格式不正确");
|
|
|
|
|
// 使用新的邮箱验证方法
|
|
|
|
|
if (!isValidEmail(email)) {
|
|
|
|
|
infoLabel.setText("邮箱格式不正确,请使用有效的邮箱地址");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (userDatabase.containsKey(email)) {
|
|
|
|
|
infoLabel.setText("该邮箱已注册");
|
|
|
|
|
return;
|
|
|
|
|
@ -160,7 +162,7 @@ public class Main extends Application {
|
|
|
|
|
if (success) {
|
|
|
|
|
infoLabel.setText("验证码已发送,请查看邮箱");
|
|
|
|
|
} else {
|
|
|
|
|
infoLabel.setText("发送失败,请检查邮箱");
|
|
|
|
|
infoLabel.setText("发送失败,请检查邮箱是否正确");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}).start();
|
|
|
|
|
@ -222,6 +224,47 @@ public class Main extends Application {
|
|
|
|
|
return username.matches("^[a-zA-Z0-9_]+$");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 邮箱完整验证方法
|
|
|
|
|
private boolean isValidEmail(String email) {
|
|
|
|
|
if (email == null || email.trim().isEmpty()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String regex = "^[A-Za-z0-9+_.-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}$";
|
|
|
|
|
|
|
|
|
|
// 基本格式检查
|
|
|
|
|
if (!email.matches(regex)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 检查@符号位置
|
|
|
|
|
int atIndex = email.indexOf('@');
|
|
|
|
|
if (atIndex <= 0 || atIndex == email.length() - 1) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 检查域名部分
|
|
|
|
|
String domain = email.substring(atIndex + 1);
|
|
|
|
|
if (domain.indexOf('.') <= 0 || domain.endsWith(".")) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 检查常见邮箱服务商
|
|
|
|
|
String[] commonDomains = {"qq.com", "gmail.com", "163.com", "126.com", "sina.com",
|
|
|
|
|
"hotmail.com", "outlook.com", "yahoo.com", "foxmail.com"};
|
|
|
|
|
boolean hasCommonDomain = false;
|
|
|
|
|
for (String commonDomain : commonDomains) {
|
|
|
|
|
if (domain.equalsIgnoreCase(commonDomain)) {
|
|
|
|
|
hasCommonDomain = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 密码验证方法
|
|
|
|
|
private boolean isValidPassword(String password) {
|
|
|
|
|
if (password.length() < 6 || password.length() > 10) {
|
|
|
|
|
@ -240,6 +283,8 @@ public class Main extends Application {
|
|
|
|
|
return hasUpper && hasLower && hasDigit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 难度选择界面
|
|
|
|
|
private Scene buildLevelSelectionScene() {
|
|
|
|
|
VBox root = new VBox(15);
|
|
|
|
|
|