Files
digital-pilates/services/trainingPlanApi.ts
richarjiang 56d4c7fd7f feat: 更新应用图标和启动画面
- 将应用图标更改为 logo.jpeg,更新相关配置文件
- 删除旧的图标文件,确保资源整洁
- 更新启动画面使用新的 logo 图片,提升视觉一致性
- 在训练计划相关功能中集成新的 API 接口,支持训练计划的创建和管理
- 优化 Redux 状态管理,支持训练计划的加载和删除功能
- 更新样式以适应新图标和功能的展示
2025-08-14 19:28:38 +08:00

62 lines
1.6 KiB
TypeScript

import { api } from './api';
export interface CreateTrainingPlanDto {
startDate: string;
name?: string;
mode: 'daysOfWeek' | 'sessionsPerWeek';
daysOfWeek: number[];
sessionsPerWeek: number;
goal: string;
startWeightKg?: number;
preferredTimeOfDay?: 'morning' | 'noon' | 'evening' | '';
}
export interface TrainingPlanResponse {
id: string;
userId: string;
name: string;
createdAt: string;
startDate: string;
mode: 'daysOfWeek' | 'sessionsPerWeek';
daysOfWeek: number[];
sessionsPerWeek: number;
goal: string;
startWeightKg: number | null;
preferredTimeOfDay: 'morning' | 'noon' | 'evening' | '';
updatedAt: string;
deleted: boolean;
}
export interface TrainingPlanSummary {
id: string;
createdAt: string;
startDate: string;
goal: string;
}
export interface TrainingPlanListResponse {
list: TrainingPlanSummary[];
total: number;
page: number;
limit: number;
}
class TrainingPlanApi {
async create(dto: CreateTrainingPlanDto): Promise<TrainingPlanResponse> {
return api.post<TrainingPlanResponse>('/training-plans', dto);
}
async list(page: number = 1, limit: number = 10): Promise<TrainingPlanListResponse> {
return api.get<TrainingPlanListResponse>(`/training-plans?page=${page}&limit=${limit}`);
}
async detail(id: string): Promise<TrainingPlanResponse> {
return api.get<TrainingPlanResponse>(`/training-plans/${id}`);
}
async delete(id: string): Promise<{ success: boolean }> {
return api.delete<{ success: boolean }>(`/training-plans/${id}`);
}
}
export const trainingPlanApi = new TrainingPlanApi();