Compare commits

..

No commits in common. 'main' and 'sqf_branch' have entirely different histories.

@ -1,20 +0,0 @@
1. 12 * 50 + 88 + 87
2. 63 - 2 + 91 - 42
3. (19 + 66) * 78 * 38 * 12
4. 82 - 9 + 72 - 56 / 6
5. 77 / 11 * 10 + 60 - 64
6. (56 * 67) / 12 / 72 - 95
7. 76 * 70 * 48 * 71
8. 8 * 50 - 30
9. (60 * 44) + 27 * 95
10. 11 + 13 * 55 * 53

@ -2,6 +2,7 @@
王五2 123 HIGH wangwu2@example.com
123 Aa123456 PRIMARY 2571400460@qq.com
王五1 123 HIGH wangwu1@example.com
scb Aa123456 PRIMARY 3110858122@qq.com
张三3 123 PRIMARY zhangsan3@example.com
张三1 123 PRIMARY zhangsan1@example.com
张三2 123 PRIMARY zhangsan2@example.com
@ -9,4 +10,3 @@
sqf Qq123456 PRIMARY sqf090815@hnu.edu.cn
李四1 123 MIDDLE lishi1@example.com
李四2 123 MIDDLE lishi2@example.com
cxb Cxb123456 PRIMARY 2263510185@qq.com

Binary file not shown.

Binary file not shown.

@ -64,19 +64,6 @@ public class Login {
return null;
}
public static boolean isEmailExists(String email){
if(email == null || email.trim().isEmpty()){
return false;
}
for(Account acc:accounts.values()){
if(acc.email != null && acc.email.equalsIgnoreCase(email.trim())){
return true;
}
}
return false;
}
// 注册GUI 调用),若用户名已存在返回 false
// 注册GUI 调用),若用户名或邮箱已存在返回 false
public static synchronized boolean register(String username, String password, Level level,
@ -86,10 +73,6 @@ public class Login {
return false;
}
if(isEmailExists(email)){
return false;
}
// 检查邮箱是否重复
for (Account existing : accounts.values()) {
if (existing.email != null && existing.email.equalsIgnoreCase(email)) {

@ -1,6 +1,6 @@
package view;
import java.awt.*;
import java.awt.GridLayout;
import java.util.Properties;
import java.util.Random;
@ -25,6 +25,7 @@ import jakarta.mail.internet.MimeMessage;
import model.Login;
import model.LanguageSwitch;
/**
* 使 QQ
*/
@ -32,21 +33,19 @@ public class RegisterFrame extends JDialog {
private JTextField usernameField;
private JTextField emailField;
private JComboBox<String> levelBox;
private JPasswordField pwdField;
private JPasswordField pwdField2;
private JTextField codeField;
private String lastCode;
private boolean isValidEmail(String email){
String emailRegex = "^[a-zA-Z0-9_+&*-]+(?:\\.[a-zA-Z0-9_+&*-]+)*@(?:[a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,7}$";
return email.matches(emailRegex);
}
// QQ 邮箱配置
private static final String FROM_EMAIL = "songqifeng.sqf@qq.com";
private static final String AUTH_CODE = "gcyschltjgxedgjd"; // ⚠️ 在 QQ 邮箱里申请的授权码
public RegisterFrame(JFrame owner) {
super(owner, "注册新用户", true);
setSize(420, 300);
setSize(420, 320);
setLocationRelativeTo(owner);
JPanel p = new JPanel(new GridLayout(7, 2, 6, 6));
@ -59,7 +58,11 @@ public class RegisterFrame extends JDialog {
emailField = new JTextField();
p.add(emailField);
p.add(new JLabel("密码 (6-10位需含大小写与数字):"));
p.add(new JLabel("年级:"));
levelBox = new JComboBox<>(new String[]{"小学", "初中", "高中"});
p.add(levelBox);
p.add(new JLabel("密码 (6-10位含大小写与数字):"));
pwdField = new JPasswordField();
p.add(pwdField);
@ -67,14 +70,10 @@ public class RegisterFrame extends JDialog {
pwdField2 = new JPasswordField();
p.add(pwdField2);
p.add(new JLabel("请输入注册码:"));
codeField = new JTextField();
p.add(codeField);
JButton sendCodeBtn = new JButton("发送注册码");
p.add(sendCodeBtn);
p.add(new JLabel());
codeField = new JTextField();
p.add(codeField);
JButton regBtn = new JButton("注册");
p.add(regBtn);
@ -85,16 +84,10 @@ public class RegisterFrame extends JDialog {
sendCodeBtn.addActionListener(e -> {
String email = emailField.getText().trim();
if (email.isEmpty() || !isValidEmail(email)) {
if (email.isEmpty() || !email.contains("@")) {
JOptionPane.showMessageDialog(this, "请输入有效邮箱");
return;
}
if(Login.isEmailExists(email)){
JOptionPane.showMessageDialog(this,"该邮箱已经被注册,请使用其他邮箱");
return;
}
lastCode = String.format("%04d", new Random().nextInt(10000));
boolean sent = sendEmail(email, lastCode);
if (sent) {
@ -115,10 +108,6 @@ public class RegisterFrame extends JDialog {
JOptionPane.showMessageDialog(this, "请填写完整信息并输入注册码");
return;
}
if(Login.isEmailExists(email)){
JOptionPane.showMessageDialog(this,"该邮箱已被注册,请使用其他邮箱");
return;
}
if (!code.equals(lastCode)) {
JOptionPane.showMessageDialog(this, "注册码错误,请重新输入");
return;
@ -131,9 +120,8 @@ public class RegisterFrame extends JDialog {
JOptionPane.showMessageDialog(this, "密码不满足要求6-10位且包含大写、小写和数字");
return;
}
Login.Level lv = Login.Level.PRIMARY;
String levelStr = (String) levelBox.getSelectedItem();
Login.Level lv = LanguageSwitch.chineseToLevel(levelStr);
boolean ok = Login.register(u, pwd, lv, email);
if (!ok) {
JOptionPane.showMessageDialog(this, "用户名或邮箱已存在,请换一个用户名");

Loading…
Cancel
Save