01026156ae
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (push) Successful in 2s
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Successful in 1s
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 2s
CI/CD Pipeline / Check push changed paths (push) Successful in 22s
CI/CD Pipeline / PR Build Web Image (pull_request) Successful in 30s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 32s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 33s
CI/CD Pipeline / Build Staging Web Image (push) Successful in 38s
CI/CD Pipeline / Build Staging API Image (push) Successful in 40s
CI/CD Pipeline / Build Staging Worker Image (push) Successful in 34s
CI/CD Pipeline / CI Gate (pull_request) Successful in 5s
CI/CD Pipeline / Validate - Python (mypy + alembic) (push) Successful in 2m13s
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / Integration Tests (push) Successful in 2m27s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 2m30s
CI/CD Pipeline / Validate - Style (push) Has been cancelled
CI/CD Pipeline / Validate - Security (push) Has been cancelled
CI/CD Pipeline / Unit Tests (push) Has been cancelled
CI/CD Pipeline / Frontend Unit Tests (push) Has been cancelled
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Has been cancelled
CI/CD Pipeline / Staging E2E Tests (push) Has been cancelled
CI/CD Pipeline / Staging API Integration Tests (push) Has been cancelled
CI/CD Pipeline / Build Production API Image (push) Has been cancelled
CI/CD Pipeline / Build Production Web Image (push) Has been cancelled
CI/CD Pipeline / Build Production Worker Image (push) Has been cancelled
CI/CD Pipeline / Deploy Production (push) Has been cancelled
CI/CD Pipeline / Production Browser E2E (push) Has been cancelled
CI/CD Pipeline / ACR Image Cleanup (push) Has been cancelled
CI/CD Pipeline / Canary Release to Production (push) Has been cancelled
CI/CD Pipeline / CI Gate (push) Has been cancelled
AI Code Review / AI Code Review (pull_request) Has been cancelled
PR Automation / Auto Approve on CI Green (pull_request) Has been cancelled
PR Automation / Auto Merge on CI Green + Approved (pull_request) Has been cancelled
CI/CD Pipeline / Canary Release to Production (pull_request) Failing after 207h14m31s
CI/CD Pipeline / ACR Image Cleanup (pull_request) Failing after 207h14m41s
CI/CD Pipeline / Deploy Production (pull_request) Failing after 207h14m46s
CI/CD Pipeline / Staging API Integration Tests (pull_request) Failing after 207h14m41s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Failing after 207h14m51s
CI/CD Pipeline / Retag skipped Staging Worker Image (push) Failing after 207h14m54s
CI/CD Pipeline / Retag skipped Staging API Image (push) Failing after 207h15m1s
CI/CD Pipeline / Build Production Worker Image (pull_request) Failing after 207h15m4s
CI/CD Pipeline / Build Production Web Image (pull_request) Failing after 207h15m6s
CI/CD Pipeline / Retag skipped Staging Web Image (pull_request) Failing after 207h15m14s
CI/CD Pipeline / Build Production API Image (pull_request) Failing after 207h15m7s
CI/CD Pipeline / Retag skipped Staging API Image (pull_request) Failing after 207h15m16s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Failing after 207h16m28s
CI/CD Pipeline / Frontend Lint (pull_request) Failing after 207h16m28s
CI/CD Pipeline / Build Staging API Image (pull_request) Failing after 207h16m30s
CI/CD Pipeline / Integration Tests (pull_request) Failing after 207h16m28s
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Failing after 207h16m33s
CI/CD Pipeline / Unit Tests (pull_request) Failing after 207h16m28s
CI/CD Pipeline / Validate - Style (pull_request) Failing after 207h16m43s
CI/CD Pipeline / Build Staging Worker Image (pull_request) Failing after 207h16m29s
CI/CD Pipeline / PR Build Worker Image (push) Failing after 207h16m48s
CI/CD Pipeline / PR Build API Image (push) Failing after 207h16m49s
CI/CD Pipeline / Frontend Lint (push) Failing after 207h16m51s
CI/CD Pipeline / Check push changed paths (pull_request) Failing after 207h16m52s
CI/CD Pipeline / Check if frontend-only change (push) Failing after 207h16m54s
CI/CD Pipeline / Staging E2E Tests (pull_request) Failing after 207h49m24s
CI/CD Pipeline / Retag skipped Staging Web Image (push) Failing after 207h49m40s
CI/CD Pipeline / Retag skipped Staging Worker Image (pull_request) Failing after 207h49m52s
CI/CD Pipeline / Build Staging Web Image (pull_request) Failing after 207h51m10s
CI/CD Pipeline / Validate - Security (pull_request) Failing after 207h51m18s
CI/CD Pipeline / PR Build Web Image (push) Failing after 207h51m28s
Co-authored-by: xiaoxia <dev@xiaoxiajianji.com> Co-committed-by: xiaoxia <dev@xiaoxiajianji.com>
116 lines
3.3 KiB
TypeScript
116 lines
3.3 KiB
TypeScript
/**
|
||
* 片段 CRUD + 批量操作 API
|
||
*/
|
||
import apiClient from "../client"
|
||
import type {
|
||
EditPlanClip,
|
||
EditPlanClipListParams,
|
||
EditPlanClipListResponse,
|
||
CreateEditPlanClipRequest,
|
||
UpdateEditPlanClipRequest,
|
||
ClipReorderItem,
|
||
ClipReorderResponse,
|
||
ClipBatchDeleteResponse,
|
||
ClipsFromAssetsResponse,
|
||
} from "./types"
|
||
|
||
/** 获取片段列表 */
|
||
export async function getEditPlanClips(
|
||
templateId: string,
|
||
params?: EditPlanClipListParams,
|
||
): Promise<EditPlanClipListResponse> {
|
||
const response = await apiClient.get<EditPlanClipListResponse>(
|
||
`/templates/${templateId}/editor/clips`,
|
||
{ params },
|
||
)
|
||
return response.data
|
||
}
|
||
|
||
/** 获取单个片段详情 */
|
||
export async function getEditPlanClip(templateId: string, clipId: string): Promise<EditPlanClip> {
|
||
const response = await apiClient.get<EditPlanClip>(
|
||
`/templates/${templateId}/editor/clips/${clipId}`,
|
||
)
|
||
return response.data
|
||
}
|
||
|
||
/** 创建片段 */
|
||
export async function createEditPlanClip(
|
||
templateId: string,
|
||
data: CreateEditPlanClipRequest,
|
||
): Promise<EditPlanClip> {
|
||
const response = await apiClient.post<EditPlanClip>(`/templates/${templateId}/editor/clips`, data)
|
||
return response.data
|
||
}
|
||
|
||
/** 更新片段 */
|
||
export async function updateEditPlanClip(
|
||
templateId: string,
|
||
clipId: string,
|
||
data: UpdateEditPlanClipRequest,
|
||
): Promise<EditPlanClip> {
|
||
const response = await apiClient.put<EditPlanClip>(
|
||
`/templates/${templateId}/editor/clips/${clipId}`,
|
||
data,
|
||
)
|
||
return response.data
|
||
}
|
||
|
||
/** 删除片段 */
|
||
export async function deleteEditPlanClip(templateId: string, clipId: string): Promise<void> {
|
||
await apiClient.delete(`/templates/${templateId}/editor/clips/${clipId}`)
|
||
}
|
||
|
||
/** 片段重排序(拖拽排序后一次性提交) */
|
||
export async function reorderEditPlanClips(
|
||
templateId: string,
|
||
items: ClipReorderItem[],
|
||
): Promise<ClipReorderResponse> {
|
||
const response = await apiClient.post<ClipReorderResponse>(
|
||
`/templates/${templateId}/editor/clips/reorder`,
|
||
{ items },
|
||
)
|
||
return response.data
|
||
}
|
||
|
||
/** 批量删除片段 */
|
||
export async function batchDeleteEditPlanClips(
|
||
templateId: string,
|
||
clipIds: string[],
|
||
): Promise<ClipBatchDeleteResponse> {
|
||
const response = await apiClient.post<ClipBatchDeleteResponse>(
|
||
`/templates/${templateId}/editor/clips/batch-delete`,
|
||
{ clip_ids: clipIds },
|
||
)
|
||
return response.data
|
||
}
|
||
|
||
/** 从素材批量创建片段(追加到时间线末尾) */
|
||
export async function createClipsFromAssets(
|
||
templateId: string,
|
||
assetIds: string[],
|
||
clipType = "main",
|
||
requiredClipsCount?: number,
|
||
opts?: { signal?: AbortSignal; silentErrorToast?: boolean },
|
||
): Promise<ClipsFromAssetsResponse> {
|
||
const body: Record<string, unknown> = {
|
||
asset_ids: assetIds,
|
||
clip_type: clipType,
|
||
}
|
||
if (requiredClipsCount !== undefined) {
|
||
body.required_clips_count = requiredClipsCount
|
||
}
|
||
// from-assets 后端会调用 MediaKit 智能选片(最长 60s),单独延长超时
|
||
const response = await apiClient.post<ClipsFromAssetsResponse>(
|
||
`/templates/${templateId}/editor/clips/from-assets`,
|
||
body,
|
||
{
|
||
timeout: 60000,
|
||
signal: opts?.signal,
|
||
// _silentErrorToast 由 api/client.ts 响应拦截器读取(抑制全局错误 toast,#1777)
|
||
...(opts?.silentErrorToast ? ({ _silentErrorToast: true } as Record<string, unknown>) : {}),
|
||
},
|
||
)
|
||
return response.data
|
||
}
|