perf: 优化食物选择

This commit is contained in:
richarjiang
2025-08-29 10:13:59 +08:00
parent 8d567fb4cb
commit f38f495008
2 changed files with 79 additions and 12 deletions

View File

@@ -3,6 +3,27 @@ import { api } from '@/services/api';
export type MealType = 'breakfast' | 'lunch' | 'dinner' | 'snack' | 'other';
export type RecordSource = 'manual' | 'vision' | 'other';
export type CreateDietRecordDto = {
mealType: MealType;
foodName: string;
foodDescription?: string;
weightGrams?: number;
portionDescription?: string;
estimatedCalories?: number;
proteinGrams?: number;
carbohydrateGrams?: number;
fatGrams?: number;
fiberGrams?: number;
sugarGrams?: number;
sodiumMg?: number;
additionalNutrition?: Record<string, any>;
source?: RecordSource;
mealTime?: string;
imageUrl?: string;
aiAnalysisResult?: Record<string, any>;
notes?: string;
};
export type DietRecord = {
id: number;
mealType: MealType;
@@ -68,6 +89,10 @@ export async function getDietRecords({
}>(`/diet-records${params}`);
}
export async function addDietRecord(dto: CreateDietRecordDto): Promise<DietRecord> {
return await api.post<DietRecord>('/diet-records', dto);
}
export async function deleteDietRecord(recordId: number): Promise<void> {
await api.delete(`/diet-records/${recordId}`);
}