Files
xiaoxia-saas/apps/web/src/api/templates.ts
T
xiaoxia abcca337e7
CI/CD Pipeline / Validate Code Quality And Tests (push) Has been cancelled
CI/CD Pipeline / Frontend Lint (push) Has been cancelled
Deploy / Deploy Staging (push) Has been cancelled
Deploy / Build Production Runtime Images (push) Has been cancelled
Deploy / Deploy Production (push) Has been cancelled
Deploy / Production Browser E2E (push) Has been cancelled
feat: Phase 1 - 前端重构(新路由/新页面/手机端适配/清理旧页面) (#73)
2026-06-28 14:50:17 +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;
};