Files
xiaoxia-saas/apps/web/src/api/templates.ts
T
xiaoxia 560856cf22
Deploy / Build Production Runtime Images (push) Has been skipped
Deploy / Deploy Production (push) Has been skipped
Deploy / Production Browser E2E (push) Has been skipped
Deploy / Deploy Staging (push) Failing after 210h26m26s
CI/CD Pipeline / Frontend Lint (push) Failing after 210h27m0s
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 210h27m7s
fix: resolve all flake8 errors and apply Prettier formatting (#131)
2026-06-30 18:26:53 +08:00

45 lines
1.1 KiB
TypeScript

/**
* 模板相关 API
* Phase 1 新增:全局模板库
*/
import apiClient from "./client";
/** 模板条目 */
export interface TemplateItem {
id: string;
name: string;
description: string;
category: string;
target_duration: number;
clip_count: number;
thumbnail_url?: string;
preview_url?: string;
is_active: boolean;
is_favorite?: boolean;
created_at?: string;
}
/** 获取全局模板列表 */
export const getTemplates = async (): Promise<TemplateItem[]> => {
const response = await apiClient.get("/templates");
return response.data.items || response.data || [];
};
/** 获取单个模板详情 */
export const getTemplate = async (
templateId: string,
): Promise<TemplateItem> => {
const response = await apiClient.get(`/templates/${templateId}`);
return response.data;
};
/** 收藏 / 取消收藏模板 */
export const toggleFavoriteTemplate = async (
templateId: string,
): Promise<{ is_favorite: boolean }> => {
const response = await apiClient.post(
`/templates/${templateId}/toggle-favorite`,
);
return response.data;
};