feat: 优化提醒注册逻辑,确保用户姓名存在时注册午餐、晚餐和心情提醒;更新睡眠详情页面,添加清醒时间段的判断和模拟数据展示;调整样式以提升用户体验
This commit is contained in:
@@ -651,7 +651,7 @@ export class WaterNotificationHelpers {
|
||||
* @returns 是否发送了通知
|
||||
*/
|
||||
static async checkWaterGoalAndNotify(
|
||||
userName: string,
|
||||
userName: string,
|
||||
todayStats: { totalAmount: number; dailyGoal: number; completionRate: number },
|
||||
currentHour: number = new Date().getHours()
|
||||
): Promise<boolean> {
|
||||
@@ -749,7 +749,7 @@ export class WaterNotificationHelpers {
|
||||
*/
|
||||
static async sendWaterReminder(userName: string, message?: string) {
|
||||
const defaultMessage = `${userName},记得要多喝水哦!保持身体水分充足很重要~💧`;
|
||||
|
||||
|
||||
return notificationService.sendImmediateNotification({
|
||||
title: '💧 喝水提醒',
|
||||
body: message || defaultMessage,
|
||||
@@ -770,12 +770,12 @@ export class WaterNotificationHelpers {
|
||||
static async scheduleRegularWaterReminders(userName: string): Promise<string[]> {
|
||||
try {
|
||||
const notificationIds: string[] = [];
|
||||
|
||||
|
||||
// 检查是否已经存在定期喝水提醒
|
||||
const existingNotifications = await notificationService.getAllScheduledNotifications();
|
||||
|
||||
|
||||
const existingWaterReminders = existingNotifications.filter(
|
||||
notification =>
|
||||
notification =>
|
||||
notification.content.data?.type === 'regular_water_reminder' &&
|
||||
notification.content.data?.isRegularReminder === true
|
||||
);
|
||||
@@ -787,7 +787,7 @@ export class WaterNotificationHelpers {
|
||||
|
||||
// 创建多个时间点的喝水提醒(9:00-21:00,每2小时一次)
|
||||
const reminderHours = [9, 11, 13, 15, 17, 19, 21];
|
||||
|
||||
|
||||
for (const hour of reminderHours) {
|
||||
const notificationId = await notificationService.scheduleCalendarRepeatingNotification(
|
||||
{
|
||||
@@ -808,7 +808,7 @@ export class WaterNotificationHelpers {
|
||||
minute: 0,
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
notificationIds.push(notificationId);
|
||||
console.log(`已安排${hour}:00的定期喝水提醒,通知ID: ${notificationId}`);
|
||||
}
|
||||
@@ -830,8 +830,8 @@ export class WaterNotificationHelpers {
|
||||
const notifications = await notificationService.getAllScheduledNotifications();
|
||||
|
||||
for (const notification of notifications) {
|
||||
if (notification.content.data?.type === 'water_reminder' ||
|
||||
notification.content.data?.type === 'regular_water_reminder') {
|
||||
if (notification.content.data?.type === 'water_reminder' ||
|
||||
notification.content.data?.type === 'regular_water_reminder') {
|
||||
await notificationService.cancelNotification(notification.identifier);
|
||||
console.log('已取消喝水提醒:', notification.identifier);
|
||||
}
|
||||
@@ -931,12 +931,12 @@ export class StandReminderHelpers {
|
||||
|
||||
// 动态导入健康工具,避免循环依赖
|
||||
const { getCurrentHourStandStatus } = await import('@/utils/health');
|
||||
|
||||
|
||||
// 获取当前小时站立状态
|
||||
const standStatus = await getCurrentHourStandStatus();
|
||||
|
||||
|
||||
console.log('当前站立状态:', standStatus);
|
||||
|
||||
|
||||
// 如果已经站立过,不需要提醒
|
||||
if (standStatus.hasStood) {
|
||||
console.log('用户当前小时已经站立,无需提醒');
|
||||
@@ -963,7 +963,7 @@ export class StandReminderHelpers {
|
||||
await notificationService.sendImmediateNotification({
|
||||
title: '站立提醒',
|
||||
body: reminderMessage,
|
||||
data: {
|
||||
data: {
|
||||
type: 'stand_reminder',
|
||||
currentStandHours: standStatus.standHours,
|
||||
standHoursGoal: standStatus.standHoursGoal,
|
||||
@@ -988,7 +988,7 @@ export class StandReminderHelpers {
|
||||
private static generateStandReminderMessage(userName: string, currentStandHours: number, goalHours: number): string {
|
||||
const currentHour = new Date().getHours();
|
||||
const progress = Math.round((currentStandHours / goalHours) * 100);
|
||||
|
||||
|
||||
const messages = [
|
||||
`${userName},该站起来活动一下了!当前已完成${progress}%的站立目标`,
|
||||
`${userName},久坐伤身,起来走走吧~已站立${currentStandHours}/${goalHours}小时`,
|
||||
|
||||
Reference in New Issue
Block a user