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>
87 lines
2.7 KiB
TypeScript
87 lines
2.7 KiB
TypeScript
/**
|
||
* 模板编辑器 API 函数
|
||
*/
|
||
import apiClient from "../client"
|
||
import type {
|
||
EditingTemplate,
|
||
TemplateCategory,
|
||
SaveTemplatePayload,
|
||
GenerateFromTemplatePayload,
|
||
GenerateFromTemplateResponse,
|
||
ListTemplatesResponse,
|
||
ListCategoriesResponse,
|
||
} from "./types"
|
||
|
||
/** 获取模板列表
|
||
*
|
||
* valid_only=true 时请求后端仅返回已配置片段的模板(剪辑页选模板使用,
|
||
* 避免选中无片段配置的模板导致 from-assets 400,#1769/#1772);
|
||
* 后端尚未支持该参数时会忽略未知 query 字段,前端再按 segments/is_active 兜底过滤。
|
||
* 模板编辑器/我的模板不传,可查看全部模板(含未配置片段的草稿)。
|
||
*/
|
||
export const getEditingTemplates = async (params?: {
|
||
category?: string
|
||
tag?: string
|
||
skip?: number
|
||
limit?: number
|
||
validOnly?: boolean
|
||
}): Promise<EditingTemplate[]> => {
|
||
const response = await apiClient.get<ListTemplatesResponse>("/templates", {
|
||
params: {
|
||
skip: params?.skip ?? 0,
|
||
limit: params?.limit ?? 50,
|
||
...(params?.validOnly ? { valid_only: true } : {}),
|
||
},
|
||
})
|
||
let list = response.data.items
|
||
if (params?.category) list = list.filter((t) => t.category === params.category)
|
||
if (params?.tag) list = list.filter((t) => t.tags.includes(params.tag!))
|
||
return list
|
||
}
|
||
|
||
/** 获取模板详情 */
|
||
export const getEditingTemplate = async (id: string): Promise<EditingTemplate> => {
|
||
const response = await apiClient.get<EditingTemplate>(`/templates/${id}`)
|
||
return response.data
|
||
}
|
||
|
||
/** 创建模板 */
|
||
export const createEditingTemplate = async (
|
||
data: SaveTemplatePayload,
|
||
): Promise<EditingTemplate> => {
|
||
const response = await apiClient.post<EditingTemplate>("/templates", data)
|
||
return response.data
|
||
}
|
||
|
||
/** 更新模板 */
|
||
export const updateEditingTemplate = async (
|
||
id: string,
|
||
data: SaveTemplatePayload,
|
||
): Promise<EditingTemplate> => {
|
||
const response = await apiClient.patch<EditingTemplate>(`/templates/${id}`, data)
|
||
return response.data
|
||
}
|
||
|
||
/** 删除模板 */
|
||
export const deleteEditingTemplate = async (id: string): Promise<void> => {
|
||
await apiClient.delete(`/templates/${id}`)
|
||
}
|
||
|
||
/** 获取模板分类列表 */
|
||
export const getTemplateCategories = async (): Promise<TemplateCategory[]> => {
|
||
const response = await apiClient.get<ListCategoriesResponse>("/templates/categories/list")
|
||
return response.data.items
|
||
}
|
||
|
||
/** 使用模板生成视频(调用 validate 端点) */
|
||
export const generateFromTemplate = async (
|
||
templateId: string,
|
||
data: GenerateFromTemplatePayload,
|
||
): Promise<GenerateFromTemplateResponse> => {
|
||
const response = await apiClient.post<GenerateFromTemplateResponse>(
|
||
`/templates/${templateId}/validate`,
|
||
data,
|
||
)
|
||
return response.data
|
||
}
|