feat: 更新应用版本和主题设置
- 将应用版本更新至 1.0.3,修改相关配置文件 - 强制全局使用浅色主题,确保一致的用户体验 - 在训练计划功能中新增激活计划的 API 接口,支持用户激活训练计划 - 优化打卡功能,支持自动同步打卡记录至服务器 - 更新样式以适应新功能的展示和交互
This commit is contained in:
@@ -31,6 +31,13 @@ export type RemoveCheckinDto = {
|
||||
id: string;
|
||||
};
|
||||
|
||||
export type SyncCheckinDto = {
|
||||
date: string; // YYYY-MM-DD
|
||||
items: any[]; // CheckinExercise[]
|
||||
note?: string;
|
||||
id?: string;
|
||||
};
|
||||
|
||||
export async function createCheckin(dto: CreateCheckinDto): Promise<{ id: string } & Record<string, any>> {
|
||||
return await api.post('/api/checkins/create', dto);
|
||||
}
|
||||
@@ -70,4 +77,11 @@ export async function fetchDailyStatusRange(startDate: string, endDate: string):
|
||||
return Array.isArray(data) ? data : [];
|
||||
}
|
||||
|
||||
// 同步打卡数据到服务器
|
||||
export async function syncCheckin(dto: SyncCheckinDto): Promise<{ id: string } & Record<string, any>> {
|
||||
console.log('dto', dto);
|
||||
|
||||
return await api.post('/api/checkins/create', dto);
|
||||
}
|
||||
|
||||
|
||||
|
||||
44
services/exercises.ts
Normal file
44
services/exercises.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
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,
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,11 @@ export interface TrainingPlanSummary {
|
||||
createdAt: string;
|
||||
startDate: string;
|
||||
goal: string;
|
||||
mode: 'daysOfWeek' | 'sessionsPerWeek';
|
||||
daysOfWeek: number[];
|
||||
sessionsPerWeek: number;
|
||||
preferredTimeOfDay: 'morning' | 'noon' | 'evening' | '';
|
||||
startWeightKg: number | null;
|
||||
}
|
||||
|
||||
export interface TrainingPlanListResponse {
|
||||
@@ -54,9 +59,17 @@ class TrainingPlanApi {
|
||||
return api.get<TrainingPlanResponse>(`/training-plans/${id}`);
|
||||
}
|
||||
|
||||
async update(id: string, dto: CreateTrainingPlanDto): Promise<TrainingPlanResponse> {
|
||||
return api.post<TrainingPlanResponse>(`/training-plans/${id}/update`, dto);
|
||||
}
|
||||
|
||||
async delete(id: string): Promise<{ success: boolean }> {
|
||||
return api.delete<{ success: boolean }>(`/training-plans/${id}`);
|
||||
}
|
||||
|
||||
async activate(id: string): Promise<{ success: boolean }> {
|
||||
return api.post<{ success: boolean }>(`/training-plans/${id}/activate`);
|
||||
}
|
||||
}
|
||||
|
||||
export const trainingPlanApi = new TrainingPlanApi();
|
||||
Reference in New Issue
Block a user