Compare commits

..

2 Commits

Author SHA1 Message Date
xiaoxia 4588f1ac7e Merge branch 'develop' into refactor/template-library
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 25s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 1m15s
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 1m2s
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 - Migration (alembic) (pull_request) Successful in 1m18s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 39s
CI/CD Pipeline / PR Build Web Image (pull_request) Successful in 45s
CI/CD Pipeline / Validate - Code Quality (pull_request) Failing after 2m34s
AI Code Review / AI Code Review (pull_request) Successful in 45s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 1m7s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 1m24s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 7m32s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 5m10s
ACR Cleanup / ACR Image Cleanup (pull_request_target) Has been cancelled
CI/CD Pipeline / Frontend Unit Tests (pull_request) Successful in 14s
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) Successful in 3m49s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 9m41s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 15s
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
2026-07-27 12:34:35 +08:00
xiaoxia 8711b5dade refactor(template-library): 三阶段重构 TemplateLibrary(716→107行, -85%)
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 38s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 1m4s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 1m8s
CI/CD Pipeline / Validate - Code Quality (pull_request) Failing after 1m53s
CI/CD Pipeline / Frontend Lint (pull_request) Failing after 52s
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 26s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 1m4s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 1m0s
CI/CD Pipeline / PR Build Web Image (pull_request) Successful in 1m45s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 55s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 4m49s
AI Code Review / AI Code Review (pull_request) Successful in 4m43s
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 / Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (pull_request) Successful in 37s
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
Phase 1 - 抽类型/常量/工具函数:
- types/templateLibrary.ts: EditTemplateType, DurationRange, ConfigDisplayFields
- constants/templateLibrary.ts: TEMPLATE_TYPES, DURATION_OPTIONS, MATERIAL_TYPE_LABELS, 渐变色映射
- utils/templateLibrary.ts: getTypeColor, gradientForCategory, formatDuration, formatConfig, getMaterialTypeLabel, calcTotalSegmentDuration

Phase 2 - 抽 5 个 UI 组件:
- TemplateCard: 模板卡片(缩略图+信息+操作按钮)
- TemplateDetailModal: 模板详情弹窗(预览+素材规则+样式配置)
- TemplateHeader: 页面头部(标题+创建按钮)
- TemplateToolbar: 工具栏(搜索+分类+时长筛选)
- TemplateGrid: 模板网格 + 空状态 + 分页 + Loading/Error

Phase 3 - 抽 2 个业务 Hook:
- useTemplateLibrary: 数据获取、筛选、分页、收藏/复制 mutations
- useTemplateDetail: 详情弹窗逻辑(预览加载、收藏乐观更新)

主文件 716→107 行,共新增 10 个文件
2026-07-26 18:24:29 +08:00
3 changed files with 38 additions and 61 deletions
@@ -1,6 +1,8 @@
/**
*
* API
*
*/
import apiClient from "./client"
/** 查重记录状态 */
export type DuplicationStatus = "pending" | "processing" | "completed" | "failed"
@@ -60,3 +62,38 @@ export interface DuplicationUploadResponse {
/** 消息 */
message: string
}
// ============ API 函数 ============
/** 上传视频进行查重 */
export const uploadForDuplication = async (file: File): Promise<DuplicationUploadResponse> => {
const formData = new FormData()
formData.append("file", file)
const response = await apiClient.post("/duplication/upload", formData, {
headers: { "Content-Type": "multipart/form-data" },
})
return response.data
}
/** 获取查重记录列表 */
export const getDuplicationRecords = async (): Promise<DuplicationRecord[]> => {
const response = await apiClient.get("/duplication/records")
return response.data
}
/** 获取查重详情 */
export const getDuplicationDetail = async (recordId: string): Promise<DuplicationDetail> => {
const response = await apiClient.get(`/duplication/records/${recordId}`)
return response.data
}
/** 删除查重记录 */
export const deleteDuplicationRecord = async (recordId: string): Promise<void> => {
await apiClient.delete(`/duplication/records/${recordId}`)
}
/** 重新查重 */
export const retryDuplication = async (recordId: string): Promise<DuplicationUploadResponse> => {
const response = await apiClient.post(`/duplication/records/${recordId}/retry`)
return response.data
}
@@ -1,38 +0,0 @@
/**
* 查重 API 函数
*/
import apiClient from "../client"
import type { DuplicationDetail, DuplicationRecord, DuplicationUploadResponse } from "./types"
/** 上传视频进行查重 */
export const uploadForDuplication = async (file: File): Promise<DuplicationUploadResponse> => {
const formData = new FormData()
formData.append("file", file)
const response = await apiClient.post("/duplication/upload", formData, {
headers: { "Content-Type": "multipart/form-data" },
})
return response.data
}
/** 获取查重记录列表 */
export const getDuplicationRecords = async (): Promise<DuplicationRecord[]> => {
const response = await apiClient.get("/duplication/records")
return response.data
}
/** 获取查重详情 */
export const getDuplicationDetail = async (recordId: string): Promise<DuplicationDetail> => {
const response = await apiClient.get(`/duplication/records/${recordId}`)
return response.data
}
/** 删除查重记录 */
export const deleteDuplicationRecord = async (recordId: string): Promise<void> => {
await apiClient.delete(`/duplication/records/${recordId}`)
}
/** 重新查重 */
export const retryDuplication = async (recordId: string): Promise<DuplicationUploadResponse> => {
const response = await apiClient.post(`/duplication/records/${recordId}/retry`)
return response.data
}
-22
View File
@@ -1,22 +0,0 @@
/**
* 查重 API — 目录化入口
* 保持与原 duplication.ts 相同导出,向后兼容
*/
// 类型
export type {
DuplicationStatus,
DuplicationRecord,
DuplicateSegment,
DuplicationDetail,
DuplicationUploadResponse,
} from "./types"
// API 函数
export {
uploadForDuplication,
getDuplicationRecords,
getDuplicationDetail,
deleteDuplicationRecord,
retryDuplication,
} from "./duplication"