Files
digital-pilates/services/exercises.ts
richarjiang 807e185761 feat: 更新应用版本和主题设置
- 将应用版本更新至 1.0.3,修改相关配置文件
- 强制全局使用浅色主题,确保一致的用户体验
- 在训练计划功能中新增激活计划的 API 接口,支持用户激活训练计划
- 优化打卡功能,支持自动同步打卡记录至服务器
- 更新样式以适应新功能的展示和交互
2025-08-14 22:23:45 +08:00

45 lines
1008 B
TypeScript

import { api } from '@/services/api';
export type ExerciseCategoryDto = {
key: string;
name: string;
sortOrder: number;
};
export type ExerciseDto = {
key: string;
name: string;
description: string;
categoryKey: string;
categoryName: string;
sortOrder: number;
};
export type ExerciseConfigResponse = {
categories: ExerciseCategoryDto[];
exercises: ExerciseDto[];
};
export type ExerciseLibraryItem = {
key: string;
name: string;
description: string;
category: string; // display name
};
export async function fetchExerciseConfig(): Promise<ExerciseConfigResponse> {
return await api.get<ExerciseConfigResponse>('/exercises/config');
}
export function normalizeToLibraryItems(resp: ExerciseConfigResponse | null | undefined): ExerciseLibraryItem[] {
if (!resp || !Array.isArray(resp.exercises)) return [];
return resp.exercises.map((e) => ({
key: e.key,
name: e.name,
description: e.description,
category: e.categoryName || e.categoryKey,
}));
}