feat: 优化统计页面和BMI卡片,移除压力分析相关代码
- 在统计页面中移除压力分析模态框及相关状态管理,简化组件逻辑 - 更新BMI卡片,改进弹窗展示方式,增加渐变背景和健康建议 - 新增更新体重的功能,支持将体重数据写入健康数据中 - 优化压力计组件,调整数据展示逻辑,提升用户体验
This commit is contained in:
@@ -10,7 +10,10 @@ const PERMISSIONS: HealthKitPermissions = {
|
||||
AppleHealthKit.Constants.Permissions.SleepAnalysis,
|
||||
AppleHealthKit.Constants.Permissions.HeartRateVariability,
|
||||
],
|
||||
write: [],
|
||||
write: [
|
||||
// 支持体重写入
|
||||
AppleHealthKit.Constants.Permissions.Weight,
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
@@ -192,4 +195,20 @@ export async function fetchHRVForDate(date: Date): Promise<number | null> {
|
||||
// 新增:获取今日HRV数据
|
||||
export async function fetchTodayHRV(): Promise<number | null> {
|
||||
return fetchHRVForDate(new Date());
|
||||
}
|
||||
}
|
||||
|
||||
// 更新healthkit中的体重
|
||||
export async function updateWeight(weight: number) {
|
||||
return new Promise((resolve) => {
|
||||
AppleHealthKit.saveWeight({
|
||||
value: weight,
|
||||
}, (err, res) => {
|
||||
if (err) {
|
||||
console.error('更新体重失败:', err);
|
||||
return resolve(false);
|
||||
}
|
||||
console.log('体重更新成功:', res);
|
||||
resolve(true);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user