feat(#1718): 微信扫码登录前端——昵称引导页 + 设置页微信绑定/解绑 #1720

Merged
auto-approve-bot merged 1 commits from feat/1718-wechat-login-frontend into develop 2026-09-05 17:30:43 +08:00
Owner

需求(Issue #1718)

  1. 登录页「微信登录」按钮 → 后端授权 → 扫码 → 回调落登录态(#558 已建底座,本次验证保留)
  2. 新微信用户首次登录强制进「填写昵称」引导页,填完才进主界面(手机号绑定后续到用户设置里做,不再拦截登录)
  3. 账号设置页加微信绑定状态 + 绑定/解绑按钮(绑定走扫码)

改动

  • 昵称引导页 pages/auth/WechatOnboarding.tsx(新):路由 /welcome/wechat,昵称必填 1-20 字,提交调 PATCH /auth/me 后落登录态进首页
  • 路由守卫 ProtectedRouteprofile_completed === false 的已登录用户一律重定向到 /welcome/wechat,未填昵称无法进入任何 /app 页面
  • 微信回调页 WechatCallback.tsx 改造:is_new_userprofile_completed===false → 跳昵称引导页;老用户回来源页。移除强制绑手机弹窗(手机号绑定挪设置页)
  • 绑定回调页 WechatBindCallback.tsx(新):路由 /auth/wechat/bind/callback,已登录用户设置页扫码后用 code 调绑定接口,成功回设置页并提示
  • 设置页 profile/Settings.tsx:①昵称保存接通 PATCH /auth/me(原来提示「暂未开放」);②新增「微信账号」卡片:未绑定显示「绑定微信」→ 扫码授权;已绑定显示状态+微信昵称+「解绑」(二次确认);微信占位邮箱(@wechat.local)友好展示
  • API 层updateProfile / getWechatBindUrl / bindWechat / unbindWechat;User/UserResponse 类型扩展 wechat_bound/wechat_nickname/avatar_url/phone/profile_completed

依赖的后端接口(后端 #1718 配套)

前端按以下契约开发,需后端补齐:

  • PATCH /auth/me(body: {display_name},返回 {user: {...}})——更新昵称,同时将用户标记为 profile_completed=true
  • GET /auth/me 响应增加 wechat_bound: boolwechat_nickname: stringprofile_completed: bool(微信新用户自动建号时为 false)
  • GET /auth/wechat/bind/url{auth_url, state}(已登录,绑定场景)
  • POST /auth/wechat/bind(body: {code, state})→ {success, user};openid 已被其他账号占用需返回明确错误
  • DELETE /auth/wechat/bind{success}(解绑;若账号无邮箱/手机/密码等其他登录方式应拒绝并提示)

测试

  • WechatCallback.test.tsx 重写 6 例:老用户跳首页、新用户跳引导页、profile_completed=false 跳引导页、state 不匹配报错、接口失败报错、loading
  • WechatOnboarding.test.tsx 新增 5 例:未登录回登录页、已完善跳 dashboard、填写昵称提交成功跳转、空昵称校验拦截、提交失败不跳转
  • Settings.test.tsx 重写 4 例:用户信息展示、未绑定点绑定走授权、已绑定解绑确认调接口、改昵称保存调更新接口
  • 全量 622 通过,tsc/eslint(max-warnings 0)/prettier/build 全绿
## 需求(Issue #1718) 1. 登录页「微信登录」按钮 → 后端授权 → 扫码 → 回调落登录态(#558 已建底座,本次验证保留) 2. **新微信用户首次登录强制进「填写昵称」引导页**,填完才进主界面(手机号绑定后续到用户设置里做,不再拦截登录) 3. **账号设置页加微信绑定状态 + 绑定/解绑按钮**(绑定走扫码) ## 改动 - **昵称引导页** `pages/auth/WechatOnboarding.tsx`(新):路由 `/welcome/wechat`,昵称必填 1-20 字,提交调 `PATCH /auth/me` 后落登录态进首页 - **路由守卫** `ProtectedRoute`:`profile_completed === false` 的已登录用户一律重定向到 `/welcome/wechat`,未填昵称无法进入任何 /app 页面 - **微信回调页** `WechatCallback.tsx` 改造:`is_new_user` 或 `profile_completed===false` → 跳昵称引导页;老用户回来源页。移除强制绑手机弹窗(手机号绑定挪设置页) - **绑定回调页** `WechatBindCallback.tsx`(新):路由 `/auth/wechat/bind/callback`,已登录用户设置页扫码后用 code 调绑定接口,成功回设置页并提示 - **设置页** `profile/Settings.tsx`:①昵称保存接通 `PATCH /auth/me`(原来提示「暂未开放」);②新增「微信账号」卡片:未绑定显示「绑定微信」→ 扫码授权;已绑定显示状态+微信昵称+「解绑」(二次确认);微信占位邮箱(@wechat.local)友好展示 - **API 层**:`updateProfile` / `getWechatBindUrl` / `bindWechat` / `unbindWechat`;User/UserResponse 类型扩展 `wechat_bound/wechat_nickname/avatar_url/phone/profile_completed` ## 依赖的后端接口(后端 #1718 配套) 前端按以下契约开发,需后端补齐: - `PATCH /auth/me`(body: `{display_name}`,返回 `{user: {...}}`)——更新昵称,同时将用户标记为 profile_completed=true - `GET /auth/me` 响应增加 `wechat_bound: bool`、`wechat_nickname: string`、`profile_completed: bool`(微信新用户自动建号时为 false) - `GET /auth/wechat/bind/url` → `{auth_url, state}`(已登录,绑定场景) - `POST /auth/wechat/bind`(body: `{code, state}`)→ `{success, user}`;openid 已被其他账号占用需返回明确错误 - `DELETE /auth/wechat/bind` → `{success}`(解绑;若账号无邮箱/手机/密码等其他登录方式应拒绝并提示) ## 测试 - `WechatCallback.test.tsx` 重写 6 例:老用户跳首页、新用户跳引导页、profile_completed=false 跳引导页、state 不匹配报错、接口失败报错、loading - `WechatOnboarding.test.tsx` 新增 5 例:未登录回登录页、已完善跳 dashboard、填写昵称提交成功跳转、空昵称校验拦截、提交失败不跳转 - `Settings.test.tsx` 重写 4 例:用户信息展示、未绑定点绑定走授权、已绑定解绑确认调接口、改昵称保存调更新接口 - 全量 **622 通过**,tsc/eslint(max-warnings 0)/prettier/build 全绿
xiaoxia added 1 commit 2026-09-05 17:24:14 +08:00
feat(#1718): 微信扫码登录前端——昵称引导页+设置页微信绑定/解绑
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Successful in 2s
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 2s
CI/CD Pipeline / Check push changed paths (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 / PR Build API Image (pull_request) Has been skipped
CI/CD Pipeline / PR Build Worker Image (pull_request) Has been skipped
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 / Retag skipped Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (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
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 2m6s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Successful in 2m10s
CI/CD Pipeline / PR Build Web Image (pull_request) Successful in 2m4s
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Successful in 2m5s
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 2m16s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 2m29s
CI/CD Pipeline / Validate - Style (pull_request) Successful in 2m43s
CI/CD Pipeline / Validate - Security (pull_request) Successful in 5m44s
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 / CI Gate (pull_request) Successful in 2s
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Canary Release to Production (pull_request) Has been skipped
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
AI Code Review / AI Code Review (pull_request) Successful in 6m20s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 3m56s
ACR Cleanup / ACR Image Cleanup (pull_request_target) Successful in 9s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 16s
0851d5bdcf
- 新微信用户首次登录强制进昵称引导页(/welcome/wechat),填完昵称才进主界面
- ProtectedRoute 拦截 profile_completed=false 用户,未填昵称无法进主界面
- WechatCallback 改造:is_new_user 或 profile_completed=false 跳引导页,不再强制绑手机
- 新增 WechatBindCallback 绑定回调页(设置页扫码绑定专用)
- 设置页:昵称保存接通 updateProfile;微信绑定状态展示+扫码绑定+解绑确认
- API 层:updateProfile/getWechatBindUrl/bindWechat/unbindWechat + 类型扩展
- 测试:WechatCallback 重写6例、WechatOnboarding 5例、Settings 重写4例,全量622通过

🚀 预览环境已部署

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

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

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

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

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

CI全绿,自动审批通过。

CI全绿,自动审批通过。
auto-approve-bot approved these changes 2026-09-05 17:26:45 +08:00
auto-approve-bot left a comment
Collaborator

CI全绿,自动审批通过。

CI全绿,自动审批通过。
auto-approve-bot merged commit c8cfed0add into develop 2026-09-05 17:30:43 +08:00
auto-approve-bot deleted branch feat/1718-wechat-login-frontend 2026-09-05 17:30:44 +08:00

🗑️ 预览环境已清理

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

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

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