fix(web): #558 修复bind-contact接口字段名,对齐后端BindContactRequest #708

Merged
auto-approve-bot merged 4 commits from fix/558-bind-contact-api-fields into develop 2026-07-22 14:12:57 +08:00
Owner

问题

后端 BindContactRequest 字段为 email / email_code / phone / phone_code
前端之前传 target / value / code 导致 400 错误("至少填写手机号或邮箱")。

改动

  • api/auth.ts:BindContactRequest 字段对齐后端
  • BindContactModal.tsx:提交时按 email/email_code 或 phone/phone_code 组装参数
## 问题 后端 `BindContactRequest` 字段为 `email` / `email_code` / `phone` / `phone_code`, 前端之前传 `target` / `value` / `code` 导致 400 错误("至少填写手机号或邮箱")。 ## 改动 - `api/auth.ts`:BindContactRequest 字段对齐后端 - `BindContactModal.tsx`:提交时按 email/email_code 或 phone/phone_code 组装参数
xiaoxia added 4 commits 2026-07-22 13:57:36 +08:00
feat(web): #558 微信登录体验优化 - state校验/登录跳转/useWechatCallback hook
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
AI Code Review / AI Code Review (pull_request) Successful in 2m35s
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 7s
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 13m1s
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Has been skipped
CI/CD Pipeline / Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 12m56s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 19m1s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 18m26s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 25s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Failing after 49m38s
fb73a69ecd
- 回调页增加state防CSRF校验
- 登录成功后跳回登录前页面(login_redirect)
- 新增useWechatCallback hook统一微信登录逻辑
- 绑定成功后更新authStore用户信息
- 移除重复的token存储逻辑(setAuth已处理)
- 登录成功navigate断言增加{ replace: true }
- 移除localStorage token断言(setAuth mock不真实存储)
- 新增login_redirect跳转测试用例
fix(web): #558 修复bind-contact接口字段名,对齐后端BindContactRequest
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 26s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 43s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 45s
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 1m4s
CI/CD Pipeline / Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / Integration Tests (pull_request) Has been skipped
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 42s
CI/CD Pipeline / Validate - Code Quality (pull_request) Successful in 1m53s
CI/CD Pipeline / PR Build Web Image (pull_request) Successful in 2m3s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 1m1s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Failing after 59s
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
AI Code Review / AI Code Review (pull_request) Successful in 4m35s
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 9m49s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 14m59s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 14m11s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 10s
b082013bba
后端字段为email/email_code/phone/phone_code,
前端之前传target/value/code导致400错误。

🚀 预览环境已部署

项目 详情
PR号 #708
预览链接 https://pr-708.preview.xiaoxiajianji.com
API环境 staging

💡 预览环境使用 staging API 数据,请勿在预览环境中操作重要数据。

🔄 每次提交新代码后预览环境会自动更新。

🗑️ PR 关闭或合并后,预览环境会自动清理。

🚀 **预览环境已部署** | 项目 | 详情 | |------|------| | PR号 | #708 | | 预览链接 | [https://pr-708.preview.xiaoxiajianji.com](https://pr-708.preview.xiaoxiajianji.com) | | API环境 | staging | > 💡 预览环境使用 staging API 数据,请勿在预览环境中操作重要数据。 > > 🔄 每次提交新代码后预览环境会自动更新。 > > 🗑️ PR 关闭或合并后,预览环境会自动清理。
auto-approve-bot approved these changes 2026-07-22 13:59:43 +08:00
auto-approve-bot left a comment
Collaborator

CI全绿,自动审批通过。

CI全绿,自动审批通过。
auto-approve-bot approved these changes 2026-07-22 13:59:43 +08:00
auto-approve-bot left a comment
Collaborator

CI全绿,自动审批通过。

CI全绿,自动审批通过。
Collaborator

代码审查结果 - PR #708

⚠️ 问题(2个需要修改)

  1. apps/web/src/components/auth/BindContactModal.tsx 第71-73行:未检查业务逻辑成功标志直接提示成功

    • BindContactResponse 接口已更新为包含 success: boolean 字段,但代码在收到响应后直接执行 message.successonSuccess,未校验 result.success。如果后端返回 HTTP 200 但业务处理失败(success: false),前端会错误地提示“绑定成功”并执行回调,误导用户。
  2. apps/web/src/components/auth/BindContactModal.tsx 第64-73行:缺少异常处理导致 Loading 状态无法复位

    • 在调用 bindContact 前设置了 setLoading(true),但未使用 try...catch.finally() 包裹异步请求。如果 bindContact 抛出异常(如网络错误、500错误),函数执行中断,setLoading(false) 永远不会被执行,导致 Modal 按钮一直处于加载禁用状态。

💡 建议(1个可选)

  1. apps/web/src/api/auth.ts 第151-155行:建议使用判别联合类型增强类型安全
    • 当前 BindContactRequest 接口所有字段均为可选,TypeScript 无法在编译期防止发送空对象 {} 或同时发送 email 和 phone 的非法请求。建议改用联合类型(如 type BindContactRequest = ({ type: 'email', email: string, code: string }) | ({ type: 'phone', phone: string, code: string }))以确保数据结构的互斥性和完整性。

格式检查通过 | 逻辑审查需修改 | 性能无明显问题


🤖 由 AI 代码审查机器人自动生成 | 2026-07-22 14:02:19 | 模型:

## 代码审查结果 - PR #708 ### ⚠️ 问题(2个需要修改) 1. **apps/web/src/components/auth/BindContactModal.tsx 第71-73行**:未检查业务逻辑成功标志直接提示成功 - `BindContactResponse` 接口已更新为包含 `success: boolean` 字段,但代码在收到响应后直接执行 `message.success` 和 `onSuccess`,未校验 `result.success`。如果后端返回 HTTP 200 但业务处理失败(`success: false`),前端会错误地提示“绑定成功”并执行回调,误导用户。 2. **apps/web/src/components/auth/BindContactModal.tsx 第64-73行**:缺少异常处理导致 Loading 状态无法复位 - 在调用 `bindContact` 前设置了 `setLoading(true)`,但未使用 `try...catch` 或 `.finally()` 包裹异步请求。如果 `bindContact` 抛出异常(如网络错误、500错误),函数执行中断,`setLoading(false)` 永远不会被执行,导致 Modal 按钮一直处于加载禁用状态。 ### 💡 建议(1个可选) 1. **apps/web/src/api/auth.ts 第151-155行**:建议使用判别联合类型增强类型安全 - 当前 `BindContactRequest` 接口所有字段均为可选,TypeScript 无法在编译期防止发送空对象 `{}` 或同时发送 email 和 phone 的非法请求。建议改用联合类型(如 `type BindContactRequest = ({ type: 'email', email: string, code: string }) | ({ type: 'phone', phone: string, code: string })`)以确保数据结构的互斥性和完整性。 --- ✅ 格式检查通过 | ❌ 逻辑审查需修改 | ✅ 性能无明显问题 --- <sub>🤖 由 AI 代码审查机器人自动生成 | 2026-07-22 14:02:19 | 模型: </sub> <!-- AI_CODE_REVIEW_AUTO_COMMENT -->
auto-approve-bot merged commit b2700b85ff into develop 2026-07-22 14:12:57 +08:00
auto-approve-bot deleted branch fix/558-bind-contact-api-fields 2026-07-22 14:12:57 +08:00

🗑️ 预览环境已清理

PR #708 已关闭或合并,对应的预览环境已被清理。

如有需要,可以重新打开 PR 来重新生成预览环境。

🗑️ **预览环境已清理** PR #708 已关闭或合并,对应的预览环境已被清理。 > 如有需要,可以重新打开 PR 来重新生成预览环境。
Sign in to join this conversation.