feat(nutrition): 添加营养数据保存功能到HealthKit,包括蛋白质、脂肪和碳水化合物

This commit is contained in:
richarjiang
2025-11-19 14:27:49 +08:00
parent f43cfe7ac6
commit dc205ad56e
7 changed files with 371 additions and 48 deletions

View File

@@ -187,49 +187,6 @@ export class NutritionNotificationHelpers {
}
}
/**
* 发送午餐记录提醒
*/
static async sendLunchReminder(userName: string) {
const coachUrl = buildCoachDeepLink({
action: 'diet',
subAction: 'card',
meal: 'lunch'
});
return notificationService.sendImmediateNotification({
title: '午餐记录提醒',
body: `${userName},记得记录今天的午餐情况哦!`,
data: {
type: 'lunch_reminder',
meal: '午餐',
url: coachUrl
},
sound: true,
priority: 'normal',
});
}
/**
* 取消午餐提醒
*/
static async cancelLunchReminder(): Promise<void> {
try {
const notifications = await notificationService.getAllScheduledNotifications();
for (const notification of notifications) {
if (notification.content.data?.type === 'lunch_reminder' &&
notification.content.data?.isDailyReminder === true) {
await notificationService.cancelNotification(notification.identifier);
console.log('已取消午餐提醒:', notification.identifier);
}
}
} catch (error) {
console.error('取消午餐提醒失败:', error);
throw error;
}
}
/**
* 安排每日晚餐提醒
* @param userName 用户名