fix: 修复压力数据

This commit is contained in:
2025-09-12 22:51:14 +08:00
parent 4627cb650e
commit ab87bddd51
7 changed files with 47 additions and 57 deletions

View File

@@ -461,27 +461,7 @@ async function fetchHeartRateVariability(options: HealthDataOptions): Promise<nu
return resolve(null);
}
logSuccess('HRV', res);
console.log('HRV数据样本数量:', res.length);
// 打印最新的几个样本用于调试
const latestSamples = res.slice(-3);
console.log('最新的HRV样本:', latestSamples.map(sample => ({
value: sample.value,
startDate: sample.startDate,
endDate: sample.endDate
})));
const latestHrv = res[res.length - 1];
if (latestHrv && latestHrv.value !== undefined && latestHrv.value !== null) {
// HealthKit 中的 HRV 数据已经是毫秒单位,无需转换
const hrvValue = Math.round(latestHrv.value);
console.log('最终HRV值:', hrvValue);
resolve(hrvValue);
} else {
console.warn('HRV样本值无效:', latestHrv);
resolve(null);
}
resolve(Math.round(res[0].value * 1000))
});
});
}