be3ed6487e
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 / 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
Preview Deploy / Deploy Preview Environment (pull_request) Failing after 46s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 50s
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
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 46m25s
CI/CD Pipeline / Canary Release to Production (pull_request) Failing after 1246h23m49s
CI/CD Pipeline / Production Browser E2E (pull_request) Failing after 1246h23m49s
CI/CD Pipeline / ACR Image Cleanup (pull_request) Failing after 1246h32m16s
CI/CD Pipeline / Staging E2E Tests (pull_request) Failing after 1246h32m20s
CI/CD Pipeline / Deploy Production (pull_request) Failing after 1246h32m22s
CI/CD Pipeline / Integration Tests (pull_request) Failing after 1246h32m24s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Failing after 1246h38m15s
CI/CD Pipeline / Build Production Web Image (pull_request) Failing after 1246h38m17s
CI/CD Pipeline / Build Production API Image (pull_request) Failing after 1246h38m19s
CI/CD Pipeline / Build Staging Web Image (pull_request) Failing after 1246h40m0s
CI/CD Pipeline / Unit Tests (pull_request) Failing after 1246h38m24s
CI/CD Pipeline / Build Staging API Image (pull_request) Failing after 1246h40m2s
CI/CD Pipeline / Staging API Integration Tests (pull_request) Failing after 1247h4m57s
CI/CD Pipeline / Build Production Worker Image (pull_request) Failing after 1247h10m56s
CI/CD Pipeline / Build Staging Worker Image (pull_request) Failing after 1247h12m37s
将 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 保持向后兼容。
92 lines
2.9 KiB
TypeScript
92 lines
2.9 KiB
TypeScript
/**
|
|
* 模板草稿 CRUD + 生成相关 API
|
|
*/
|
|
import apiClient from "../client"
|
|
import type {
|
|
EditPlan,
|
|
EditPlanListParams,
|
|
EditPlanListResponse,
|
|
CreateEditPlanRequest,
|
|
UpdateEditPlanRequest,
|
|
GenerateResponse,
|
|
GenerationStatusResponse,
|
|
EditPlanGeneration,
|
|
GeneratedVideo,
|
|
CopyEditPlanRequest,
|
|
} from "./types"
|
|
|
|
/** 获取模板草稿列表(支持分页和筛选) */
|
|
export async function getEditPlans(params?: EditPlanListParams): Promise<EditPlanListResponse> {
|
|
const response = await apiClient.get<EditPlanListResponse>("/templates/drafts", {
|
|
params,
|
|
})
|
|
return response.data
|
|
}
|
|
|
|
/** 获取单个模板草稿 */
|
|
export async function getEditPlan(templateId: string): Promise<EditPlan> {
|
|
const response = await apiClient.get(`/templates/${templateId}/editor`)
|
|
return response.data
|
|
}
|
|
|
|
/** 创建模板草稿 */
|
|
export async function createEditPlan(data: CreateEditPlanRequest): Promise<EditPlan> {
|
|
const response = await apiClient.post("/templates/drafts", data)
|
|
return response.data
|
|
}
|
|
|
|
/** 更新模板草稿 */
|
|
export async function updateEditPlan(
|
|
templateId: string,
|
|
data: UpdateEditPlanRequest,
|
|
): Promise<EditPlan> {
|
|
const response = await apiClient.put(`/templates/${templateId}/editor`, data)
|
|
return response.data
|
|
}
|
|
|
|
/** 删除模板草稿 */
|
|
export async function deleteEditPlan(templateId: string): Promise<void> {
|
|
await apiClient.delete(`/templates/${templateId}/editor`)
|
|
}
|
|
|
|
/** 触发生成 */
|
|
export async function generateEditPlan(templateId: string): Promise<GenerateResponse> {
|
|
const response = await apiClient.post(`/templates/${templateId}/editor/generate`)
|
|
return response.data
|
|
}
|
|
|
|
/** 获取生成状态(轮询用) */
|
|
export async function getGenerationStatus(templateId: string): Promise<GenerationStatusResponse> {
|
|
const response = await apiClient.get(`/templates/${templateId}/editor/generation-status`)
|
|
return response.data
|
|
}
|
|
|
|
/** 获取模板草稿关联的生成记录 */
|
|
export async function getEditPlanGenerations(templateId: string): Promise<EditPlanGeneration[]> {
|
|
const response = await apiClient.get(`/templates/${templateId}/editor/generations`)
|
|
return response.data.items || []
|
|
}
|
|
|
|
/** 获取生成任务的视频结果列表 */
|
|
export async function getGenerationTaskResults(taskId: string): Promise<GeneratedVideo[]> {
|
|
const response = await apiClient.get(`/generation/tasks/${taskId}/results`)
|
|
return response.data.items || response.data || []
|
|
}
|
|
|
|
/** 取消生成任务 */
|
|
export async function cancelGeneration(templateId: string): Promise<void> {
|
|
await apiClient.post(`/templates/${templateId}/editor/cancel`)
|
|
}
|
|
|
|
/** 复制模板草稿(含所有片段配置) */
|
|
export async function copyEditPlan(
|
|
templateId: string,
|
|
data?: CopyEditPlanRequest,
|
|
): Promise<EditPlan> {
|
|
const response = await apiClient.post<EditPlan>(
|
|
`/templates/${templateId}/editor/copy`,
|
|
data || {},
|
|
)
|
|
return response.data
|
|
}
|