refactor(health): remove basalEnergyBurned from global state and move to local component
Remove basalEnergyBurned from global health data structure and refactor BasalMetabolismCard to fetch its own data locally. This decouples the component from global state and improves data locality. - Remove basalEnergyBurned from HealthData interface and health utilities - Update BasalMetabolismCard to use selectedDate prop and fetch data locally - Simplify statistics screen by removing unused basalMetabolism variable - Update nutrition radar card to use activeCalories only for burned calories calculation
This commit is contained in:
@@ -89,7 +89,6 @@ export default function ExploreScreen() {
|
||||
// 解构健康数据(支持mock数据)
|
||||
const mockData = useMockData ? getTestHealthData('mock') : null;
|
||||
const activeCalories = useMockData ? (mockData?.activeEnergyBurned ?? null) : (healthData?.activeEnergyBurned ?? null);
|
||||
const basalMetabolism: number | null = useMockData ? (mockData?.basalEnergyBurned ?? null) : (healthData?.basalEnergyBurned ?? null);
|
||||
|
||||
|
||||
|
||||
@@ -230,7 +229,6 @@ export default function ExploreScreen() {
|
||||
date: dateString,
|
||||
data: {
|
||||
activeCalories: data.activeEnergyBurned,
|
||||
basalEnergyBurned: data.basalEnergyBurned,
|
||||
hrv: data.hrv,
|
||||
heartRate: data.heartRate,
|
||||
activeEnergyBurned: data.activeEnergyBurned,
|
||||
@@ -459,8 +457,8 @@ export default function ExploreScreen() {
|
||||
{/* 营养摄入雷达图卡片 */}
|
||||
<NutritionRadarCard
|
||||
nutritionSummary={nutritionSummary}
|
||||
burnedCalories={(basalMetabolism || 0) + (activeCalories || 0)}
|
||||
basalMetabolism={basalMetabolism || 0}
|
||||
burnedCalories={activeCalories || 0}
|
||||
basalMetabolism={0}
|
||||
activeCalories={activeCalories || 0}
|
||||
resetToken={animToken}
|
||||
/>
|
||||
@@ -532,8 +530,7 @@ export default function ExploreScreen() {
|
||||
{/* 基础代谢卡片 */}
|
||||
<FloatingCard style={styles.masonryCard} delay={1250}>
|
||||
<BasalMetabolismCard
|
||||
value={basalMetabolism}
|
||||
resetToken={animToken}
|
||||
selectedDate={currentSelectedDate}
|
||||
style={styles.basalMetabolismCardOverride}
|
||||
/>
|
||||
</FloatingCard>
|
||||
|
||||
Reference in New Issue
Block a user