refactor(voice-materials): 拆分 useVoiceMaterialActions Hook(216→80行, -63%) #1059

Merged
auto-approve-bot merged 3 commits from refactor/use-voice-material-actions into develop 2026-07-28 12:49:52 +08:00
Owner
No description provided.
xiaoxia added 1 commit 2026-07-28 10:14:59 +08:00
refactor(voice-materials): 拆分 useVoiceMaterialActions Hook
CI/CD Pipeline / Check if frontend-only change (pull_request) Has been cancelled
CI/CD Pipeline / Validate - Code Quality (pull_request) Has been cancelled
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Has been cancelled
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Has been cancelled
CI/CD Pipeline / Unit Tests (pull_request) Has been cancelled
CI/CD Pipeline / Integration Tests (pull_request) Has been cancelled
CI/CD Pipeline / Frontend Lint (pull_request) Has been cancelled
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been cancelled
CI/CD Pipeline / PR Build API Image (pull_request) Has been cancelled
CI/CD Pipeline / PR Build Web Image (pull_request) Has been cancelled
CI/CD Pipeline / PR Build Worker Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Staging API Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been cancelled
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been cancelled
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been cancelled
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been cancelled
CI/CD Pipeline / Build Production API Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Web Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been cancelled
CI/CD Pipeline / Deploy Production (pull_request) Has been cancelled
CI/CD Pipeline / Production Browser E2E (pull_request) Has been cancelled
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been cancelled
CI/CD Pipeline / Canary Release to Production (pull_request) Has been cancelled
CI/CD Pipeline / CI Gate (pull_request) Has been cancelled
AI Code Review / AI Code Review (pull_request) Has been cancelled
Preview Deploy / Deploy Preview Environment (pull_request) Has been cancelled
PR Automation / Auto Approve on CI Green (pull_request) Successful in 1m11s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 1m27s
18f99ba32b
三阶段重构:
- Phase 1: 拆分为 3 个领域子 Hook
  - useVoiceUpload: 上传流程(库→上传→时长→创建→标签)
  - useVoiceEdit: 编辑流程(更新信息+标签差异同步)
  - useVoiceDelete: 删除操作
- Phase 2: 主 Hook 组合子 Hook + UI 弹窗状态
- Phase 3: 主文件 216→80 行(-63%)

保持导出签名向后兼容
xiaoxia added 1 commit 2026-07-28 10:19:45 +08:00
fix(useVoiceMaterialActions): fix prettier formatting
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 27s
CI/CD Pipeline / Validate - Code Quality (pull_request) Failing after 1m40s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 59s
CI/CD Pipeline / Frontend Lint (pull_request) Failing after 42s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 1m7s
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
PR Automation / Auto Approve on CI Green (pull_request) Successful in 47s
CI/CD Pipeline / PR Build Web Image (pull_request) Failing after 2m19s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 2m16s
Preview Deploy / Deploy Preview Environment (pull_request) Failing after 41s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 5m22s
AI Code Review / AI Code Review (pull_request) Failing after 5m49s
CI/CD Pipeline / Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (pull_request) Failing after 26s
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 / Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 46m16s
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / CI Gate (pull_request) Successful in 5s
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 / Canary Release to Production (pull_request) Has been cancelled
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
3eef40bbf8
xiaoxia added 1 commit 2026-07-28 12:18:26 +08:00
fix(useVoiceMaterialActions): 修复子 Hook 相对路径层级错误
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 8s
CI/CD Pipeline / Frontend Lint (pull_request) Failing after 43s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 1m11s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 1m12s
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
PR Automation / Auto Approve on CI Green (pull_request) Successful in 1m7s
CI/CD Pipeline / Validate - Code Quality (pull_request) Failing after 2m47s
Preview Deploy / Deploy Preview Environment (pull_request) Failing after 36s
CI/CD Pipeline / PR Build Web Image (pull_request) Failing after 2m37s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 2m34s
AI Code Review / AI Code Review (pull_request) Successful in 3m57s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 5m57s
CI/CD Pipeline / Unit Tests (pull_request) Has been skipped
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 / Frontend Unit Tests (pull_request) Successful in 41s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Integration Tests (pull_request) Has been skipped
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 / CI Gate (pull_request) Successful in 16s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 24m49s
CI/CD Pipeline / Canary Release to Production (pull_request) Has been cancelled
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
ACR Cleanup / ACR Image Cleanup (pull_request_target) Successful in 32s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 51s
ab9b7409b2
子 Hook 位于 actions/ 子目录,引用 types/utils 需要上三级(../../../)
而非上两级(../../),导致 TS 编译失败。
Collaborator

代码审查结果 - PR #1059

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

  1. useVoiceMaterialActions.ts 第45行:编辑弹窗在请求提交后立即关闭,导致用户无法感知加载状态,且若请求失败弹窗已关闭,体验不佳。
    • 原因:代码在 editMutation.mutate 后立即执行了 setEditingMaterial(null),这与 handleUpload 中将关闭逻辑放在 onSuccess 回调中的做法不一致。
    • 后果:编辑失败时用户界面已重置,可能造成困惑;且无法在弹窗内展示加载中的 Spinner。
    • 建议:将 setEditingMaterial(null) 移至 mutate 方法的 onSuccess 回调选项中,确保仅在成功后关闭。

💡 建议(4个可选)

  1. useVoiceEdit.ts 第45行untagAssetfor...of 循环中使用 await 串行执行,若删除标签数量较多会导致接口响应时间累加。建议改为 Promise.all 并行执行以提高性能。
  2. useVoiceEdit.ts 第62行:该 Hook 导出的 handleEdit 方法在父组件 useVoiceMaterialActions 中被重新定义覆盖,属于死代码,建议删除以减小包体积。
  3. useVoiceDelete.ts 第32行:该 Hook 导出 handleDelete 方法,但在父组件 useVoiceMaterialActions 中并未使用(父组件重新定义了同名函数),属于死代码,建议删除。
  4. useVoiceEdit.ts 第17行mutationFn 依赖闭包中的 materials 变量。若父组件传入的 materials 引用频繁变动,会导致 useMutation 配置频繁重建。建议确保 materials 引用稳定或使用 useCallback 稳定化 mutationFn

格式检查通过 | 逻辑审查需修改 | ⚠️ 建议关注性能


🤖 由 AI 代码审查机器人自动生成 | 2026-07-28 04:27:44 | 模型:

## 代码审查结果 - PR #1059 ### ⚠️ 问题(1个需要修改) 1. **useVoiceMaterialActions.ts 第45行**:编辑弹窗在请求提交后立即关闭,导致用户无法感知加载状态,且若请求失败弹窗已关闭,体验不佳。 - **原因**:代码在 `editMutation.mutate` 后立即执行了 `setEditingMaterial(null)`,这与 `handleUpload` 中将关闭逻辑放在 `onSuccess` 回调中的做法不一致。 - **后果**:编辑失败时用户界面已重置,可能造成困惑;且无法在弹窗内展示加载中的 Spinner。 - **建议**:将 `setEditingMaterial(null)` 移至 `mutate` 方法的 `onSuccess` 回调选项中,确保仅在成功后关闭。 ### 💡 建议(4个可选) 1. **useVoiceEdit.ts 第45行**:`untagAsset` 在 `for...of` 循环中使用 `await` 串行执行,若删除标签数量较多会导致接口响应时间累加。建议改为 `Promise.all` 并行执行以提高性能。 2. **useVoiceEdit.ts 第62行**:该 Hook 导出的 `handleEdit` 方法在父组件 `useVoiceMaterialActions` 中被重新定义覆盖,属于死代码,建议删除以减小包体积。 3. **useVoiceDelete.ts 第32行**:该 Hook 导出 `handleDelete` 方法,但在父组件 `useVoiceMaterialActions` 中并未使用(父组件重新定义了同名函数),属于死代码,建议删除。 4. **useVoiceEdit.ts 第17行**:`mutationFn` 依赖闭包中的 `materials` 变量。若父组件传入的 `materials` 引用频繁变动,会导致 `useMutation` 配置频繁重建。建议确保 `materials` 引用稳定或使用 `useCallback` 稳定化 `mutationFn`。 --- ✅ 格式检查通过 | ❌ 逻辑审查需修改 | ⚠️ 建议关注性能 --- <sub>🤖 由 AI 代码审查机器人自动生成 | 2026-07-28 04:27:44 | 模型: </sub> <!-- AI_CODE_REVIEW_AUTO_COMMENT -->
auto-approve-bot merged commit 29448aaf9b into develop 2026-07-28 12:49:52 +08:00
auto-approve-bot deleted branch refactor/use-voice-material-actions 2026-07-28 12:49:53 +08:00

🗑️ 预览环境已清理

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

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

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