diff --git a/Cargo.lock b/Cargo.lock index 28554fc..1c555c2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1151,7 +1151,6 @@ dependencies = [ "email-encoding", "email_address", "fastrand", - "futures-util", "hostname", "httpdate", "idna", diff --git a/Cargo.toml b/Cargo.toml index 577be35..2ff91a4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,4 +49,4 @@ rand = "0.8" clap = { version = "4", features = ["derive", "env"] } # 注册邮箱验证码发信(rant 2026-08-19T14:36:19:方案 B 完整验证码) -lettre = { version = "0.11", default-features = false, features = ["builder", "smtp-transport", "rustls-tls", "hostname", "pool"] } +lettre = { version = "0.11", default-features = false, features = ["builder", "smtp-transport", "rustls-tls", "hostname"] } diff --git a/src/mail.rs b/src/mail.rs index e7d8cd7..4f0118a 100644 --- a/src/mail.rs +++ b/src/mail.rs @@ -10,6 +10,7 @@ //! `SmtpTransport::builder_dangerous(...).tls(Tls::Opportunistic(...))`。 use anyhow::{Context, Result}; +use std::time::Duration; use crate::config::Mail; use lettre::Transport; @@ -61,6 +62,8 @@ pub fn send_verification_code(cfg: &Mail, to: &str, code: &str) -> Result<()> { .with_context(|| format!("SMTP 服务器不可用: {}", cfg.smtp_host))? .port(cfg.smtp_port) .credentials(creds) + // 显式 15s 超时:避免无 pool 时挂住/长等(rant 2026-08-21T14:08:03) + .timeout(Some(Duration::from_secs(15))) .build(); mailer.send(&email).map_err(|e| { log::error!("SMTP 发送验证码到 {to} 失败: {e:?}"); diff --git a/ui/js/app.js b/ui/js/app.js index 709f9d1..97d7512 100644 --- a/ui/js/app.js +++ b/ui/js/app.js @@ -2673,7 +2673,9 @@ const email = $("#verify-email").value.trim(); if (!email) return; const b = $("#resend-btn"); + const orig = b.textContent; b.disabled = true; + b.textContent = T("verify.sending"); // 发送中反馈(rant 2026-08-21T14:08:03 补充验收) try { const r = await api.post("/api/auth/resend-code", { email }); if (r.dev_code) { toast(T("verify.devCode") + ": " + r.dev_code, "info"); } @@ -2682,7 +2684,7 @@ const m = (err && err.message) ? I18n.mapErr(err.message) : T("verify.err.fail"); toast(m, "error"); } finally { - setTimeout(() => { b.disabled = false; }, 1000); + setTimeout(() => { b.disabled = false; b.textContent = orig; }, 300); } }); diff --git a/ui/js/i18n.js b/ui/js/i18n.js index 42ab5ea..99f4e1d 100644 --- a/ui/js/i18n.js +++ b/ui/js/i18n.js @@ -65,6 +65,7 @@ "verify.code": "验证码", "verify.submit": "验证并激活", "verify.resend": "重新发送", + "verify.sending": "发送中…", "verify.sent": "验证码已发送到邮箱", "verify.ok": "注册成功,请登录", "verify.devCode": "[dev] 验证码", @@ -759,6 +760,7 @@ "verify.code": "Verification code", "verify.submit": "Verify & Activate", "verify.resend": "Resend", + "verify.sending": "Sending…", "verify.sent": "Verification code sent to your email", "verify.ok": "Registered successfully, please sign in", "verify.devCode": "[dev] Code",