refactor(template-editor): API层按模块拆分(744行→88行入口, -88%) #939

Closed
xiaoxia wants to merge 2 commits from refactor/template-editor-api into develop
Owner

变更说明

template-editor.ts 单文件拆分为目录结构,按业务模块组织。入口文件从 744 行精简到 88 行(仅 re-export)。

拆分模块

  • types.ts — 所有类型定义(EditPlan / EditPlanClip / MediaAsset / 配置类型等)
  • constants.ts — 常量(TRANSITION_OPTIONS / QUALITY_OPTIONS / 标签映射等)
  • editPlans.ts — 模板草稿 CRUD + 生成 + 复制 + 取消
  • clips.ts — 片段 CRUD + 批量操作(重排序/批量删除/从素材创建)
  • aiFeatures.ts — AI 推荐 + AI 封面生成
  • mediaAssets.ts — 素材库 API + AssetItem→MediaAsset 映射
  • index.ts — 统一入口,re-export 所有类型/常量/函数

向后兼容

  • 导入路径 @/api/template-editor 保持不变(指向 index.ts)
  • 所有导出名称与原文件完全一致

验收标准

  • Prettier 格式化通过
  • ESLint 通过(CI 验证)
  • TSC 编译通过(CI 验证)
  • 功能回归:所有调用方正常工作
## 变更说明 将 `template-editor.ts` 单文件拆分为目录结构,按业务模块组织。入口文件从 744 行精简到 88 行(仅 re-export)。 ### 拆分模块 - `types.ts` — 所有类型定义(EditPlan / EditPlanClip / MediaAsset / 配置类型等) - `constants.ts` — 常量(TRANSITION_OPTIONS / QUALITY_OPTIONS / 标签映射等) - `editPlans.ts` — 模板草稿 CRUD + 生成 + 复制 + 取消 - `clips.ts` — 片段 CRUD + 批量操作(重排序/批量删除/从素材创建) - `aiFeatures.ts` — AI 推荐 + AI 封面生成 - `mediaAssets.ts` — 素材库 API + AssetItem→MediaAsset 映射 - `index.ts` — 统一入口,re-export 所有类型/常量/函数 ### 向后兼容 - 导入路径 `@/api/template-editor` 保持不变(指向 index.ts) - 所有导出名称与原文件完全一致 ## 验收标准 - [x] Prettier 格式化通过 - [ ] ESLint 通过(CI 验证) - [ ] TSC 编译通过(CI 验证) - [ ] 功能回归:所有调用方正常工作
xiaoxia added 1 commit 2026-07-26 16:47:30 +08:00
refactor(template-editor): API层按模块拆分(744行→88行入口, -88%)
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 22s
CI/CD Pipeline / Frontend Lint (pull_request) Failing after 54s
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 - Type Check (mypy) (pull_request) Successful in 1m49s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 58s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 1m50s
CI/CD Pipeline / Validate - Code Quality (pull_request) Failing after 2m33s
CI/CD Pipeline / Unit Tests (pull_request) Has been skipped
Preview Deploy / Deploy Preview Environment (pull_request) Failing after 46s
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
PR Automation / Auto Approve on CI Green (pull_request) Successful in 50s
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 / PR Build API Image (pull_request) Successful in 2m48s
AI Code Review / AI Code Review (pull_request) Successful in 1m48s
CI/CD Pipeline / PR Build Web Image (pull_request) Failing after 2m26s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Failing after 16s
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 / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / Canary Release to Production (pull_request) Has been skipped
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 46m25s
be3ed6487e
将 template-editor.ts 单文件拆分为目录结构,按业务模块组织:

- types.ts — 所有类型定义(EditPlan/Clip/MediaAsset 等)
- constants.ts — 常量(TRANSITION_OPTIONS/QUALITY_OPTIONS 等)
- editPlans.ts — 模板草稿 CRUD + 生成 + 复制 + 取消
- clips.ts — 片段 CRUD + 批量操作(重排序/批量删除/从素材创建)
- aiFeatures.ts — AI 推荐 + AI 封面生成
- mediaAssets.ts — 素材库 API + AssetItem→MediaAsset 映射
- index.ts — 统一入口,re-export 所有类型/常量/函数

入口文件从 744 行精简到 88 行(仅 re-export),
各模块职责单一,便于维护和 tree-shaking。
导入路径 @/api/template-editor 保持向后兼容。
xiaoxia added 1 commit 2026-07-27 12:35:05 +08:00
Merge branch 'develop' into refactor/template-editor-api
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 18s
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 36s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 1m17s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 1m18s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 26s
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 2m36s
CI/CD Pipeline / PR Build Web Image (pull_request) Successful in 1m46s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 5m7s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 47s
AI Code Review / AI Code Review (pull_request) Successful in 1m20s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 46s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 15m18s
CI/CD Pipeline / CI Gate (pull_request) 失败: CI/CD Pipeline / Validate - Code Quality (pull_request) [frontend-only]
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 22s
ACR Cleanup / ACR Image Cleanup (pull_request_target) Has been cancelled
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
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 21s
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
f2bd1c25f4
auto-approve-bot approved these changes 2026-07-27 14:47:34 +08:00
auto-approve-bot left a comment
Collaborator

CI全绿,自动审批通过。

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

CI全绿,自动审批通过。

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

代码审查结果 - PR #939

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

💡 建议(0个可选)


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

审查详情

本次 PR 将 template-editor.ts 单文件拆分为模块化结构(aiFeatures, clips, constants, editPlans 等)。经过审查,代码变更属于纯重构操作,逻辑完全保留,未发现引入错误

审查结论:

  1. 逻辑一致性:所有 API 调用路径、参数处理(如 data || {}response.data.items || [])与原文件保持一致。
  2. 模块拆分editPlans.ts 负责草稿主草稿,clips.ts 负责片段操作,aiFeatures.ts 负责 AI 功能,constants.ts 负责常量,职责划分清晰合理。
  3. 依赖引用:新模块正确引用了 ../client./types,路径解析正确。
  4. 类型安全:所有函数均保留了原有的类型注解,未引入 any

代码质量良好,可以合并。


🤖 由 AI 代码审查机器人自动生成 | 2026-07-27 06:47:40 | 模型:

## 代码审查结果 - PR #939 ### ⚠️ 问题(0个需要修改) 无 ### 💡 建议(0个可选) 无 --- ✅ 格式检查通过 | ✅ 逻辑审查需修改 | ✅ 建议关注性能 ### 审查详情 本次 PR 将 `template-editor.ts` 单文件拆分为模块化结构(`aiFeatures`, `clips`, `constants`, `editPlans` 等)。经过审查,代码变更属于纯重构操作,**逻辑完全保留,未发现引入错误**。 **审查结论:** 1. **逻辑一致性**:所有 API 调用路径、参数处理(如 `data || {}`、`response.data.items || []`)与原文件保持一致。 2. **模块拆分**:`editPlans.ts` 负责草稿主草稿,`clips.ts` 负责片段操作,`aiFeatures.ts` 负责 AI 功能,`constants.ts` 负责常量,职责划分清晰合理。 3. **依赖引用**:新模块正确引用了 `../client` 和 `./types`,路径解析正确。 4. **类型安全**:所有函数均保留了原有的类型注解,未引入 `any`。 代码质量良好,可以合并。 --- <sub>🤖 由 AI 代码审查机器人自动生成 | 2026-07-27 06:47:40 | 模型: </sub> <!-- AI_CODE_REVIEW_AUTO_COMMENT -->

🚀 预览环境已部署

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

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

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

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

🚀 **预览环境已部署** | 项目 | 详情 | |------|------| | PR号 | #939 | | 预览链接 | [https://pr-939.preview.xiaoxiajianji.com](https://pr-939.preview.xiaoxiajianji.com) | | API环境 | staging | > 💡 预览环境使用 staging API 数据,请勿在预览环境中操作重要数据。 > > 🔄 每次提交新代码后预览环境会自动更新。 > > 🗑️ PR 关闭或合并后,预览环境会自动清理。
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 closed this pull request 2026-07-27 16:35:15 +08:00

🗑️ 预览环境已清理

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

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

🗑️ **预览环境已清理** PR #939 已关闭或合并,对应的预览环境已被清理。 > 如有需要,可以重新打开 PR 来重新生成预览环境。
Some checks are pending
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 18s
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 36s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 1m17s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 1m18s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 26s
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 2m36s
CI/CD Pipeline / PR Build Web Image (pull_request) Successful in 1m46s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 5m7s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 47s
AI Code Review / AI Code Review (pull_request) Successful in 1m20s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 46s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 15m18s
CI/CD Pipeline / CI Gate (pull_request) 失败: CI/CD Pipeline / Validate - Code Quality (pull_request) [frontend-only]
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 22s
ACR Cleanup / ACR Image Cleanup (pull_request_target) Has been cancelled
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
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 21s
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped

Pull request closed

Sign in to join this conversation.