/** * 片段 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 { const response = await apiClient.get( `/templates/${templateId}/editor/clips`, { params }, ) return response.data } /** 获取单个片段详情 */ export async function getEditPlanClip(templateId: string, clipId: string): Promise { const response = await apiClient.get( `/templates/${templateId}/editor/clips/${clipId}`, ) return response.data } /** 创建片段 */ export async function createEditPlanClip( templateId: string, data: CreateEditPlanClipRequest, ): Promise { const response = await apiClient.post(`/templates/${templateId}/editor/clips`, data) return response.data } /** 更新片段 */ export async function updateEditPlanClip( templateId: string, clipId: string, data: UpdateEditPlanClipRequest, ): Promise { const response = await apiClient.put( `/templates/${templateId}/editor/clips/${clipId}`, data, ) return response.data } /** 删除片段 */ export async function deleteEditPlanClip(templateId: string, clipId: string): Promise { await apiClient.delete(`/templates/${templateId}/editor/clips/${clipId}`) } /** 片段重排序(拖拽排序后一次性提交) */ export async function reorderEditPlanClips( templateId: string, items: ClipReorderItem[], ): Promise { const response = await apiClient.post( `/templates/${templateId}/editor/clips/reorder`, { items }, ) return response.data } /** 批量删除片段 */ export async function batchDeleteEditPlanClips( templateId: string, clipIds: string[], ): Promise { const response = await apiClient.post( `/templates/${templateId}/editor/clips/batch-delete`, { clip_ids: clipIds }, ) return response.data } /** 从素材批量创建片段(追加到时间线末尾) */ export async function createClipsFromAssets( templateId: string, assetIds: string[], clipType = "main", ): Promise { const response = await apiClient.post( `/templates/${templateId}/editor/clips/from-assets`, { asset_ids: assetIds, clip_type: clipType }, ) return response.data }