Repository navigation
前端:邮件设置卡片新增「发送测试邮件」 - #133
Merged
todosdev[bot] merged 1 commit intoOct 18, 2026
Merged
Conversation
- add adminApi.sendTestEmail calling POST /api/admin/email/test - add a test-email section under the save button, prefilled with the admin's email, with loading and status-based error messages - extract pure error mapping into lib/testEmail.ts and cover it with node --test cases alongside new i18n keys in en and zh-CN Checkpoint: jFaLA3kQxhfrG-jNW0mPh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
adminApi.sendTestEmail(to)调用POST /api/admin/email/test,并按状态码(400/429/502)展示可读的错误提示。node --test单测覆盖请求、错误映射与文案 key。Changes
apps/web/src/api/client.ts—adminApi增加sendTestEmail(to),body{ to },返回{ success: boolean }。apps/web/src/pages/admin/AdminSettingsPage.tsx— 在「保存」按钮下方新增测试区:收件地址输入框(默认填入useAuth().user.email,用useRef只预填一次)、「发送测试邮件」按钮(type="button",发送中loading并禁用)、成功用toast.success绿色提示、失败内联红色文案(复用「检查并升级数据库」的内联报错风格)。apps/web/src/lib/testEmail.ts(新增)— 纯函数resolveTestEmailError/formatTestEmailError:400 → 配置/地址问题、429 → 过于频繁(插值Retry-After秒数)、502 → 发送失败、其余 → 通用失败;会话过期返回null由 AuthProvider 统一提示。apps/web/src/i18n/locales/en.ts/zh-CN.ts— 新增 8 个admin.*key,无硬编码中文。apps/web/src/lib/testEmail.test.ts(新增)+apps/web/package.json— 单测纳入pnpm test,覆盖请求/响应(stub fetch)、429/502 错误映射、两套 locale key 非空。Testing
pnpm check(biome)、pnpm typecheck、pnpm build、pnpm test(54 项全部通过)。