refactor(editing-planner): 拆分 useEditPlanClips Hook,按职责拆为列表 + CRUD #1007

Closed
xiaoxia wants to merge 2 commits from refactor/use-edit-plan-clips-split into develop
Owner

变更说明

拆分 useEditPlanClips 巨无霸 Hook(233 行),按职责拆分为目录结构:

  • useEditPlanClipList - 列表查询 + 选中状态
  • useEditPlanClipMutations - 创建/更新/删除/批量删除/重排序/素材导入
  • index - 组合入口 + 本地撤销重做

主文件 233 → 95 行(-59%)

导入路径保持不变(@/pages/editing-planner/hooks/useEditPlanClips),向后兼容。

## 变更说明 拆分 useEditPlanClips 巨无霸 Hook(233 行),按职责拆分为目录结构: - **useEditPlanClipList** - 列表查询 + 选中状态 - **useEditPlanClipMutations** - 创建/更新/删除/批量删除/重排序/素材导入 - **index** - 组合入口 + 本地撤销重做 主文件 233 → 95 行(-59%) 导入路径保持不变(`@/pages/editing-planner/hooks/useEditPlanClips`),向后兼容。
xiaoxia added 1 commit 2026-07-27 07:29:27 +08:00
refactor(editing-planner): 拆分 useEditPlanClips Hook,按职责拆为列表 + CRUD
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 26s
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 55s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 1m8s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 1m19s
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 / PR Build Worker Image (pull_request) Successful in 34s
CI/CD Pipeline / Validate - Code Quality (pull_request) Failing after 2m14s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 1m28s
CI/CD Pipeline / PR Build Web Image (pull_request) Successful in 2m37s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 53s
AI Code Review / AI Code Review (pull_request) Successful in 2m49s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 6m39s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 16m6s
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 / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (pull_request) Failing after 41s
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 / Canary Release to Production (pull_request) Has been cancelled
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
24db76dd04
主文件 233→95 行(-59%),拆分为:
- useEditPlanClipList: 列表查询 + 选中状态
- useEditPlanClipMutations: 创建/更新/删除/批量删除/重排序/素材导入
- index: 组合入口 + 本地撤销重做

导入路径保持向后兼容
auto-approve-bot approved these changes 2026-07-27 07:51:56 +08:00
auto-approve-bot left a comment
Collaborator

CI全绿,自动审批通过。

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

CI全绿,自动审批通过。

CI全绿,自动审批通过。

🚀 预览环境已部署

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

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

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

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

🚀 **预览环境已部署** | 项目 | 详情 | |------|------| | PR号 | #1007 | | 预览链接 | [https://pr-1007.preview.xiaoxiajianji.com](https://pr-1007.preview.xiaoxiajianji.com) | | API环境 | staging | > 💡 预览环境使用 staging API 数据,请勿在预览环境中操作重要数据。 > > 🔄 每次提交新代码后预览环境会自动更新。 > > 🗑️ PR 关闭或合并后,预览环境会自动清理。
Collaborator

代码审查结果 - PR #1007

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

  1. index.ts 第21行useUndoRedo 初始化状态与服务器数据不同步

    • 问题描述localClips 初始化为空数组 [],且没有逻辑在 clips 数据加载或更新时同步 localClips。根据注释,localClips 用于拖拽等即时操作,但目前它始终为空,导致拖拽功能无法正常工作或操作空列表。
    • 后果:拖拽功能失效,用户无法看到或操作本地暂存的片段状态。
  2. useEditPlanClipMutations.ts 第67, 104, 122, 152行:缺少 planId 非空校验

    • 问题描述addClip 函数中有 if (!planId) return 的防护,但 updateClipremoveClipreorderClipsimportFromAssets 等函数均缺少此校验,直接使用 planId! 调用 API。
    • 后果:在 planId 尚未就绪(如 undefined)时触发操作,会导致 API 调用错误或运行时异常。

💡 建议(1个可选)

  1. useEditPlanClipList.ts & useEditPlanClipMutations.tsQUERY_KEY 常量重复定义
    • 建议描述:两个文件中均定义了 const QUERY_KEY = "editPlanClips"。建议将其提取到公共常量文件中统一导出,避免因字符串不一致导致缓存失效失效。

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


🤖 由 AI 代码审查机器人自动生成 | 2026-07-26 23:53:02 | 模型:

## 代码审查结果 - PR #1007 ### ⚠️ 问题(2个需要修改) 1. **index.ts 第21行**:`useUndoRedo` 初始化状态与服务器数据不同步 - **问题描述**:`localClips` 初始化为空数组 `[]`,且没有逻辑在 `clips` 数据加载或更新时同步 `localClips`。根据注释,`localClips` 用于拖拽等即时操作,但目前它始终为空,导致拖拽功能无法正常工作或操作空列表。 - **后果**:拖拽功能失效,用户无法看到或操作本地暂存的片段状态。 2. **useEditPlanClipMutations.ts 第67, 104, 122, 152行**:缺少 `planId` 非空校验 - **问题描述**:`addClip` 函数中有 `if (!planId) return` 的防护,但 `updateClip`、`removeClip`、`reorderClips`、`importFromAssets` 等函数均缺少此校验,直接使用 `planId!` 调用 API。 - **后果**:在 `planId` 尚未就绪(如 undefined)时触发操作,会导致 API 调用错误或运行时异常。 ### 💡 建议(1个可选) 1. **useEditPlanClipList.ts & useEditPlanClipMutations.ts**:`QUERY_KEY` 常量重复定义 - **建议描述**:两个文件中均定义了 `const QUERY_KEY = "editPlanClips"`。建议将其提取到公共常量文件中统一导出,避免因字符串不一致导致缓存失效失效。 --- ✅ 格式检查通过 | ❌ 逻辑审查需修改 | ✅ 性能无明显问题 --- <sub>🤖 由 AI 代码审查机器人自动生成 | 2026-07-26 23:53:02 | 模型: </sub> <!-- AI_CODE_REVIEW_AUTO_COMMENT -->
Collaborator

Auto merge skipped after multiple 405 errors: PR may have conflicts or unresolved checks. Please review manually. This is not a CI failure.

Auto merge skipped after multiple 405 errors: PR may have conflicts or unresolved checks. Please review manually. This is not a CI failure.
xiaoxia added 1 commit 2026-07-27 12:34:22 +08:00
Merge branch 'develop' into refactor/use-edit-plan-clips-split
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 36s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 1m14s
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 52s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 1m16s
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 / Validate - Code Quality (pull_request) Failing after 1m59s
CI/CD Pipeline / PR Build Web Image (pull_request) Successful in 44s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 47s
AI Code Review / AI Code Review (pull_request) Successful in 32s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 53s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 1m9s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 4m17s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m56s
ACR Cleanup / ACR Image Cleanup (pull_request_target) Has been cancelled
CI/CD Pipeline / Frontend Unit Tests (pull_request) Successful in 16s
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 / Unit Tests (pull_request) Successful in 8m2s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 3m8s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 21s
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 / Canary Release to Production (pull_request) Has been cancelled
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
26d026a366
xiaoxia closed this pull request 2026-07-27 15:26:25 +08:00

🗑️ 预览环境已清理

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

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

🗑️ **预览环境已清理** PR #1007 已关闭或合并,对应的预览环境已被清理。 > 如有需要,可以重新打开 PR 来重新生成预览环境。
Some checks are pending
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 36s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 1m14s
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 52s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 1m16s
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 / Validate - Code Quality (pull_request) Failing after 1m59s
CI/CD Pipeline / PR Build Web Image (pull_request) Successful in 44s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 47s
AI Code Review / AI Code Review (pull_request) Successful in 32s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 53s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 1m9s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 4m17s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m56s
ACR Cleanup / ACR Image Cleanup (pull_request_target) Has been cancelled
CI/CD Pipeline / Frontend Unit Tests (pull_request) Successful in 16s
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 / Unit Tests (pull_request) Successful in 8m2s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 3m8s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 21s
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 / Canary Release to Production (pull_request) Has been cancelled
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped

Pull request closed

Sign in to join this conversation.