100 lines
2.7 KiB
TypeScript
100 lines
2.7 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",
|
|
): Promise<ClipsFromAssetsResponse> {
|
|
const response = await apiClient.post<ClipsFromAssetsResponse>(
|
|
`/templates/${templateId}/editor/clips/from-assets`,
|
|
{ asset_ids: assetIds, clip_type: clipType },
|
|
)
|
|
return response.data
|
|
}
|