From 60ca751fa9256d079c8561b597920c3176938727 Mon Sep 17 00:00:00 2001 From: npmrun <1549469775@qq.com> Date: Mon, 20 Apr 2026 20:23:05 +0800 Subject: [PATCH] feat(config): add admin comment email test send flow Add an admin-only test email endpoint with SMTP config and admin email validation, plus a config-page action button to trigger test sends and minimal service tests for key 400 failure paths. Made-with: Cursor --- app/pages/me/admin/config/index.vue | 27 +++++++- bun.lock | 23 ++++--- package.json | 1 + .../api/config/global/comment-email-test.post.ts | 49 +++++++++++++++ server/service/comment-email/test-mail.test.ts | 26 ++++++++ server/service/comment-email/test-mail.ts | 71 ++++++++++++++++++++++ 6 files changed, 184 insertions(+), 13 deletions(-) create mode 100644 server/api/config/global/comment-email-test.post.ts create mode 100644 server/service/comment-email/test-mail.test.ts create mode 100644 server/service/comment-email/test-mail.ts diff --git a/app/pages/me/admin/config/index.vue b/app/pages/me/admin/config/index.vue index 5d39e90..51391d8 100644 --- a/app/pages/me/admin/config/index.vue +++ b/app/pages/me/admin/config/index.vue @@ -26,6 +26,7 @@ const { refresh: refreshGlobalConfig } = useGlobalConfig() const loading = ref(true) const saving = ref(false) +const testingEmail = ref(false) const siteName = ref('') const allowRegister = ref(true) const mediaOrphanAutoSweepEnabled = ref(false) @@ -101,6 +102,21 @@ async function save() { saving.value = false } } + +async function sendTestEmail() { + testingEmail.value = true + try { + const result = await fetchData<{ message: string }>('/api/config/global/comment-email-test', { + method: 'POST', + }) + toast.add({ title: result.message || '测试邮件发送成功,请检查邮箱', color: 'success' }) + } catch (error) { + const message = error instanceof Error ? error.message : '测试邮件发送失败' + toast.add({ title: message, color: 'error' }) + } finally { + testingEmail.value = false + } +}