diff --git a/.gitignore b/.gitignore deleted file mode 100644 index f68d109..0000000 --- a/.gitignore +++ /dev/null @@ -1,29 +0,0 @@ -### IntelliJ IDEA ### -out/ -!**/src/main/**/out/ -!**/src/test/**/out/ - -### Eclipse ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans -.sts4-cache -bin/ -!**/src/main/**/bin/ -!**/src/test/**/bin/ - -### NetBeans ### -/nbproject/private/ -/nbbuild/ -/dist/ -/nbdist/ -/.nb-gradle/ - -### VS Code ### -.vscode/ - -### Mac OS ### -.DS_Store \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 10b731c..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -# 默认忽略的文件 -/shelf/ -/workspace.xml -# 基于编辑器的 HTTP 客户端请求 -/httpRequests/ diff --git a/.idea/.name b/.idea/.name deleted file mode 100644 index 2b3e571..0000000 --- a/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -untitled111.iml \ No newline at end of file diff --git a/.idea/artifacts/untitled111_jar.xml b/.idea/artifacts/untitled111_jar.xml deleted file mode 100644 index 5ef401c..0000000 --- a/.idea/artifacts/untitled111_jar.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - $PROJECT_DIR$/out/artifacts/untitled111_jar - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 2bfdeda..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 5116208..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index 3d42da1..0000000 --- a/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# pairing_program - diff --git a/src/Main.java b/src/Main.java index 6aa0089..484e558 100644 --- a/src/Main.java +++ b/src/Main.java @@ -141,13 +141,13 @@ public class Main extends Application { infoLabel.setText("用户名已存在"); return; } -/* + // 使用新的邮箱验证方法 if (!isValidEmail(email)) { infoLabel.setText("邮箱格式不正确,请使用有效的邮箱地址"); return; } -*/ + if (userDatabase.containsKey(email)) { infoLabel.setText("该邮箱已注册"); return; @@ -224,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) { diff --git a/untitled111.iml b/untitled111.iml deleted file mode 100644 index a3ee431..0000000 --- a/untitled111.iml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file