Merge jinzhibo_branch

develop
fanxuerun 7 months ago
commit 2ddabaca53

@ -63,20 +63,54 @@ public class RegisterFrame extends JFrame {
gbc.weightx = 1.0;
panel.add(buttonPanel, gbc);
// 事件监听器
sendCodeBtn.addActionListener(e -> {
String email = emailField.getText().trim();
if (email.isEmpty()) {
JOptionPane.showMessageDialog(this, "请输入邮箱地址", "提示", JOptionPane.WARNING_MESSAGE);
return;
}
String code = controller.register(email);
if (code != null) {
codeField.setText(code);
JOptionPane.showMessageDialog(this, "验证码已发送: " + code, "验证码", JOptionPane.INFORMATION_MESSAGE);
} else {
JOptionPane.showMessageDialog(this, "邮箱已被注册或无效", "错误", JOptionPane.ERROR_MESSAGE);
}
// 禁用按钮
sendCodeBtn.setEnabled(false);
sendCodeBtn.setText("发送中...");
new Thread(() -> {
try {
String result = controller.register(email);
SwingUtilities.invokeLater(() -> {
sendCodeBtn.setEnabled(true);
sendCodeBtn.setText("发送验证码");
if (result != null && !result.startsWith("already") &&
!result.startsWith("code") && !result.startsWith("invalid") &&
!result.startsWith("send")) {
// 成功发送,只显示通用提示
JOptionPane.showMessageDialog(this,
"验证码已发送到您的邮箱,请查收",
"发送成功",
JOptionPane.INFORMATION_MESSAGE);
} else if (result != null) {
// 处理错误情况(根据你的 AuthController 返回值调整)
JOptionPane.showMessageDialog(this,
"发送失败,请检查邮箱地址",
"错误",
JOptionPane.ERROR_MESSAGE);
} else {
JOptionPane.showMessageDialog(this,
"注册失败,请重试",
"错误",
JOptionPane.ERROR_MESSAGE);
}
});
} catch (Exception ex) {
SwingUtilities.invokeLater(() -> {
sendCodeBtn.setEnabled(true);
sendCodeBtn.setText("发送验证码");
JOptionPane.showMessageDialog(this,
"发送验证码时出现错误",
"错误",
JOptionPane.ERROR_MESSAGE);
});
}
}).start();
});
registerBtn.addActionListener(e -> {

Loading…
Cancel
Save