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:
@@ -207,7 +207,6 @@ export type HourlyStandData = {
|
||||
|
||||
export type TodayHealthData = {
|
||||
activeEnergyBurned: number; // kilocalories
|
||||
basalEnergyBurned: number; // kilocalories - 基础代谢率
|
||||
hrv: number | null; // 心率变异性 (ms)
|
||||
// 健身圆环数据
|
||||
activeCalories: number;
|
||||
@@ -608,7 +607,6 @@ export async function fetchMaximumHeartRate(_options: HealthDataOptions): Promis
|
||||
function getDefaultHealthData(): TodayHealthData {
|
||||
return {
|
||||
activeEnergyBurned: 0,
|
||||
basalEnergyBurned: 0,
|
||||
hrv: null,
|
||||
activeCalories: 0,
|
||||
activeCaloriesGoal: 350,
|
||||
@@ -630,13 +628,11 @@ export async function fetchHealthDataForDate(date: Date): Promise<TodayHealthDat
|
||||
// 并行获取所有健康数据
|
||||
const [
|
||||
activeEnergyBurned,
|
||||
basalEnergyBurned,
|
||||
hrv,
|
||||
activitySummary,
|
||||
heartRate
|
||||
] = await Promise.all([
|
||||
fetchActiveEnergyBurned(options),
|
||||
fetchBasalEnergyBurned(options),
|
||||
fetchHeartRateVariability(options),
|
||||
fetchActivitySummary(options),
|
||||
fetchHeartRate(options)
|
||||
@@ -644,7 +640,6 @@ export async function fetchHealthDataForDate(date: Date): Promise<TodayHealthDat
|
||||
|
||||
return {
|
||||
activeEnergyBurned,
|
||||
basalEnergyBurned,
|
||||
hrv,
|
||||
activeCalories: Math.round(activitySummary?.activeEnergyBurned || 0),
|
||||
activeCaloriesGoal: Math.round(activitySummary?.activeEnergyBurnedGoal || 350),
|
||||
|
||||
Reference in New Issue
Block a user