fix: 全面补充前端交互状态反馈(P0 第一批) #97

Merged
xiaoxia merged 2 commits from fix/frontend-feedback-improvement into develop 2026-06-29 10:11:51 +08:00
Owner

修复内容

1. 全局错误拦截器 (client.ts)

  • 自动提取后端 detail / message / msg 字段展示 message.error
  • 处理网络异常、请求超时、5xx 服务器错误
  • 通过 __msgShown 标记避免与组件 onError 重复弹提示

2. 删除操作补充 onError(6 处)

  • AssetLibrary、TitleLibrary、VoiceLibrary、ProductLibrary 的 deleteMutation
  • DuplicationResults 的 deleteMutation + retryMutation

3. GeneratePage 加载/错误状态

  • 5 个 query(templates、asset-libraries、titles、voices、all-assets)增加 loading spinner 和 error Alert

4. TemplateLibrary 收藏反馈

  • favMutation 增加「已收藏/已取消收藏」成功提示及失败回退

5. Dashboard / DuplicationDetail 错误状态

  • Dashboard 增加 isError 展示,避免查询失败时静默显示全零数据
  • DuplicationDetail 增加 isError 状态,区分「加载失败」与「记录不存在」

影响范围

10 个文件,+94 / -10 行,纯前端改动,无后端依赖

## 修复内容 ### 1. 全局错误拦截器 (`client.ts`) - 自动提取后端 `detail` / `message` / `msg` 字段展示 `message.error` - 处理网络异常、请求超时、5xx 服务器错误 - 通过 `__msgShown` 标记避免与组件 `onError` 重复弹提示 ### 2. 删除操作补充 onError(6 处) - AssetLibrary、TitleLibrary、VoiceLibrary、ProductLibrary 的 deleteMutation - DuplicationResults 的 deleteMutation + retryMutation ### 3. GeneratePage 加载/错误状态 - 5 个 query(templates、asset-libraries、titles、voices、all-assets)增加 loading spinner 和 error Alert ### 4. TemplateLibrary 收藏反馈 - favMutation 增加「已收藏/已取消收藏」成功提示及失败回退 ### 5. Dashboard / DuplicationDetail 错误状态 - Dashboard 增加 `isError` 展示,避免查询失败时静默显示全零数据 - DuplicationDetail 增加 `isError` 状态,区分「加载失败」与「记录不存在」 ## 影响范围 10 个文件,+94 / -10 行,纯前端改动,无后端依赖
xiaoxia added 1 commit 2026-06-29 09:35:33 +08:00
fix: 全面补充前端交互状态反馈
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Has been cancelled
CI/CD Pipeline / Frontend Lint (pull_request) Has been cancelled
4143018faa
- client.ts: 添加全局错误拦截器,自动提取后端 detail/message/msg 字段展示 toast
  - 处理网络异常、超时、5xx 等场景
  - 通过 __msgShown 标记避免与组件 onError 重复弹提示
- 6 个 delete mutation 补充 onError 回退提示(AssetLibrary、TitleLibrary、
  VoiceLibrary、ProductLibrary、DuplicationResults×2)
- GeneratePage: 5 个 query 增加 loading + error 状态展示
- TemplateLibrary: favMutation 增加收藏/取消收藏成功提示及失败回退
- Dashboard: 增加 isError 错误状态展示,避免静默显示全零数据
- DuplicationDetail: 增加 isError 状态,区分加载失败与记录不存在
xiaoxia added 1 commit 2026-06-29 09:42:52 +08:00
fix: P1 防止全局拦截器与组件 onError 双重 toast
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Has been cancelled
CI/CD Pipeline / Frontend Lint (pull_request) Has been cancelled
fb935981a5
- 所有 React Query onError 中的 message.error 添加 __msgShown 检查
- 所有 try/catch 中的 message.error 添加 __msgShown 检查
- 涉及 14 个页面文件:AssetLibrary, TitleLibrary, VoiceLibrary,
  DuplicationUpload, TaskHistory, GeneratePage, ProductLibrary,
  Billing, UpgradeSubscription, Login, Register, ForgotPassword,
  ResetPassword, TemplateLibrary
- 修复 TemplateLibrary 缺少 message import 的问题

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Author
Owner

代码审计结果: 通过

Head SHA: fb935981a534c53710bffcca9a01ffcb7960bf77

变更概览

18 文件,+126/-45,覆盖全局拦截器 + 14 个页面 + 订阅/查重/生成模块。

审查详情

1. 全局错误拦截器 (client.ts)

  • 正确覆盖 401(清登录态)、超时、网络异常、服务端 detail/message/msg 提取、5xx 兜底
  • __msgShown 标记机制设计合理:拦截器已弹 toast 时标记,组件 onError 据此跳过,避免双重提示
  • 4xx 无服务端信息时不弹通用提示,交由组件自行处理,策略正确

2. Mutation onError 覆盖

  • 6 个 deleteMutation + createMutation + uploadMutation 等均已添加 __msgShown 检查
  • AssetLibrary、TitleLibrary、VoiceLibrary、ProductLibrary、DuplicationResults、GeneratePage、TemplateLibrary 等 14 个页面模式统一
  • Auth 页面(Login/Register/ForgotPassword/ResetPassword)的 catch/onError 也正确添加了 __msgShown 检查,fallback 文案友好

3. 查询错误状态

  • Dashboard:增加 isError + Alert 错误展示,避免静默显示全零数据
  • DuplicationDetail:区分「加载失败」与「记录不存在」,UX 合理
  • GeneratePage:5 个 query 均有 isError 解构 + 加载 Spinner

4. 成功/加载反馈

  • TemplateLibrary favMutation:成功提示「已收藏/已取消收藏」+ 失败回退
  • 各页面 loading Spin、Empty 状态均已覆盖

P2 建议(不阻塞合并)

  • useQuery 的查询错误不会触发 React Query 的 onError(已废弃),当前依赖全局拦截器 toast + isError 条件渲染的组合方式可以工作,但如果未来需要查询级别定制错误展示,建议考虑 error boundaries 或 useQueryonError 替代方案

结论:修复全面且一致,代码质量良好,可以合并。

## 代码审计结果:✅ 通过 **Head SHA**: `fb935981a534c53710bffcca9a01ffcb7960bf77` ### 变更概览 18 文件,+126/-45,覆盖全局拦截器 + 14 个页面 + 订阅/查重/生成模块。 ### 审查详情 #### 1. 全局错误拦截器 (`client.ts`) ✅ - 正确覆盖 401(清登录态)、超时、网络异常、服务端 detail/message/msg 提取、5xx 兜底 - `__msgShown` 标记机制设计合理:拦截器已弹 toast 时标记,组件 onError 据此跳过,避免双重提示 - 4xx 无服务端信息时不弹通用提示,交由组件自行处理,策略正确 #### 2. Mutation onError 覆盖 ✅ - 6 个 deleteMutation + createMutation + uploadMutation 等均已添加 `__msgShown` 检查 - AssetLibrary、TitleLibrary、VoiceLibrary、ProductLibrary、DuplicationResults、GeneratePage、TemplateLibrary 等 14 个页面模式统一 - Auth 页面(Login/Register/ForgotPassword/ResetPassword)的 catch/onError 也正确添加了 `__msgShown` 检查,fallback 文案友好 #### 3. 查询错误状态 ✅ - Dashboard:增加 `isError` + Alert 错误展示,避免静默显示全零数据 - DuplicationDetail:区分「加载失败」与「记录不存在」,UX 合理 - GeneratePage:5 个 query 均有 `isError` 解构 + 加载 Spinner #### 4. 成功/加载反馈 ✅ - TemplateLibrary favMutation:成功提示「已收藏/已取消收藏」+ 失败回退 - 各页面 loading Spin、Empty 状态均已覆盖 ### P2 建议(不阻塞合并) - useQuery 的查询错误不会触发 React Query 的 onError(已废弃),当前依赖全局拦截器 toast + isError 条件渲染的组合方式可以工作,但如果未来需要查询级别定制错误展示,建议考虑 error boundaries 或 `useQuery` 的 `onError` 替代方案 **结论:修复全面且一致,代码质量良好,可以合并。**
Author
Owner

代码审计已通过审查(10:04),1个P2建议不阻塞合并。请合并到develop分支。

代码审计已通过审查(10:04),1个P2建议不阻塞合并。请合并到develop分支。
xiaoxia merged commit f10a526497 into develop 2026-06-29 10:11:51 +08:00
Sign in to join this conversation.