feat: 更新应用配置和引入新依赖
- 修改 app.json,禁用平板支持以优化用户体验 - 在 package.json 和 package-lock.json 中新增 react-native-toast-message 依赖,支持消息提示功能 - 在多个组件中集成 Toast 组件,提升用户交互反馈 - 更新训练计划相关逻辑,优化状态管理和数据处理 - 调整样式以适应新功能的展示和交互
This commit is contained in:
@@ -11,56 +11,52 @@ export interface CreateTrainingPlanDto {
|
||||
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 type PlanMode = 'daysOfWeek' | 'sessionsPerWeek';
|
||||
|
||||
export interface TrainingPlanSummary {
|
||||
id: string;
|
||||
createdAt: string;
|
||||
startDate: string;
|
||||
goal: string;
|
||||
mode: 'daysOfWeek' | 'sessionsPerWeek';
|
||||
daysOfWeek: number[];
|
||||
sessionsPerWeek: number;
|
||||
preferredTimeOfDay: 'morning' | 'noon' | 'evening' | '';
|
||||
startWeightKg: number | null;
|
||||
}
|
||||
export type PlanGoal =
|
||||
| 'postpartum_recovery' // 产后恢复
|
||||
| 'fat_loss' // 减脂塑形
|
||||
| 'posture_correction' // 体态矫正
|
||||
| 'core_strength' // 核心力量
|
||||
| 'flexibility' // 柔韧灵活
|
||||
| 'rehab' // 康复保健
|
||||
| 'stress_relief'; // 释压放松
|
||||
|
||||
export type TrainingPlan = {
|
||||
id: string;
|
||||
createdAt: string; // ISO
|
||||
startDate: string; // ISO (当天或下周一)
|
||||
mode: PlanMode;
|
||||
daysOfWeek: number[]; // 0(日) - 6(六)
|
||||
sessionsPerWeek: number; // 1..7
|
||||
goal: PlanGoal | '';
|
||||
startWeightKg?: number;
|
||||
preferredTimeOfDay?: 'morning' | 'noon' | 'evening' | '';
|
||||
name?: string;
|
||||
isActive?: boolean;
|
||||
};
|
||||
export interface TrainingPlanListResponse {
|
||||
list: TrainingPlanSummary[];
|
||||
list: TrainingPlan[];
|
||||
total: number;
|
||||
page: number;
|
||||
limit: number;
|
||||
}
|
||||
|
||||
class TrainingPlanApi {
|
||||
async create(dto: CreateTrainingPlanDto): Promise<TrainingPlanResponse> {
|
||||
return api.post<TrainingPlanResponse>('/training-plans', dto);
|
||||
async create(dto: CreateTrainingPlanDto): Promise<TrainingPlan> {
|
||||
return api.post<TrainingPlan>('/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 detail(id: string): Promise<TrainingPlan> {
|
||||
return api.get<TrainingPlan>(`/training-plans/${id}`);
|
||||
}
|
||||
|
||||
async update(id: string, dto: CreateTrainingPlanDto): Promise<TrainingPlanResponse> {
|
||||
return api.post<TrainingPlanResponse>(`/training-plans/${id}/update`, dto);
|
||||
async update(id: string, dto: CreateTrainingPlanDto): Promise<TrainingPlan> {
|
||||
return api.post<TrainingPlan>(`/training-plans/${id}/update`, dto);
|
||||
}
|
||||
|
||||
async delete(id: string): Promise<{ success: boolean }> {
|
||||
@@ -71,9 +67,9 @@ class TrainingPlanApi {
|
||||
return api.post<{ success: boolean }>(`/training-plans/${id}/activate`);
|
||||
}
|
||||
|
||||
async getActivePlan(): Promise<TrainingPlanResponse | null> {
|
||||
async getActivePlan(): Promise<TrainingPlan | null> {
|
||||
try {
|
||||
return api.get<TrainingPlanResponse>('/training-plans/active');
|
||||
return api.get<TrainingPlan>('/training-plans/active');
|
||||
} catch (error) {
|
||||
// 如果没有激活的计划,返回null
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user