feat: 更新 CLAUDE.md 文件及多个组件以优化用户体验和功能

- 更新 CLAUDE.md 文件,重构架构部分,增加认证和数据层的描述
- 在 GoalsScreen 中新增目标模板选择功能,支持用户选择和创建目标
- 在 CreateGoalModal 中添加初始数据支持,优化目标创建体验
- 新增 GoalTemplateModal 组件,提供目标模板选择界面
- 更新 NotificationHelpers,支持构建深度链接以便于导航
- 在 CoachScreen 中处理路由参数,增强用户交互体验
- 更新多个组件的样式和逻辑,提升整体用户体验
- 删除不再使用的中文回复规则文档
This commit is contained in:
richarjiang
2025-08-26 15:04:04 +08:00
parent 7f2afdf671
commit 3f89023447
13 changed files with 1113 additions and 359 deletions

View File

@@ -1,6 +1,27 @@
import * as Notifications from 'expo-notifications';
import { NotificationData, notificationService } from '../services/notifications';
/**
* 构建 coach 页面的深度链接
*/
export function buildCoachDeepLink(params: {
action?: 'diet' | 'weight' | 'mood' | 'workout';
subAction?: 'record' | 'photo' | 'text' | 'card';
meal?: 'breakfast' | 'lunch' | 'dinner' | 'snack';
message?: string;
}): string {
const baseUrl = '/coach';
const searchParams = new URLSearchParams();
if (params.action) searchParams.set('action', params.action);
if (params.subAction) searchParams.set('subAction', params.subAction);
if (params.meal) searchParams.set('meal', params.meal);
if (params.message) searchParams.set('message', encodeURIComponent(params.message));
const queryString = searchParams.toString();
return queryString ? `${baseUrl}?${queryString}` : baseUrl;
}
/**
* 运动相关的通知辅助函数
*/
@@ -353,6 +374,13 @@ export class NutritionNotificationHelpers {
return existingLunchReminder.identifier;
}
// 构建跳转到 coach 页面的深度链接
const coachUrl = buildCoachDeepLink({
action: 'diet',
subAction: 'card',
meal: 'lunch'
});
// 创建午餐提醒通知
const notificationId = await notificationService.scheduleCalendarRepeatingNotification(
{
@@ -361,7 +389,8 @@ export class NutritionNotificationHelpers {
data: {
type: 'lunch_reminder',
isDailyReminder: true,
meal: '午餐'
meal: '午餐',
url: coachUrl // 添加深度链接
},
sound: true,
priority: 'normal',
@@ -385,10 +414,20 @@ 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: '午餐' },
data: {
type: 'lunch_reminder',
meal: '午餐',
url: coachUrl
},
sound: true,
priority: 'normal',
});
@@ -436,11 +475,28 @@ export class NutritionNotificationHelpers {
reminderTime.setDate(reminderTime.getDate() + 1);
}
// 构建深度链接
const mealTypeMap: Record<string, string> = {
'早餐': 'breakfast',
'午餐': 'lunch',
'晚餐': 'dinner'
};
const coachUrl = buildCoachDeepLink({
action: 'diet',
subAction: 'card',
meal: mealTypeMap[mealTime.meal] as 'breakfast' | 'lunch' | 'dinner'
});
const notificationId = await notificationService.scheduleRepeatingNotification(
{
title: `${mealTime.meal}提醒`,
body: `${userName},记得记录您的${mealTime.meal}情况`,
data: { type: 'meal_reminder', meal: mealTime.meal },
data: {
type: 'meal_reminder',
meal: mealTime.meal,
url: coachUrl
},
sound: true,
priority: 'normal',
},
@@ -575,19 +631,50 @@ export const NotificationTemplates = {
}),
},
nutrition: {
reminder: (userName: string, meal: string) => ({
title: `${meal}提醒`,
body: `${userName},记得记录您的${meal}情况`,
data: { type: 'meal_reminder', meal },
sound: true,
priority: 'normal' as const,
}),
lunch: (userName: string) => ({
title: '午餐记录提醒',
body: `${userName},记得记录今天的午餐情况哦!`,
data: { type: 'lunch_reminder', meal: '午餐' },
sound: true,
priority: 'normal' as const,
}),
reminder: (userName: string, meal: string) => {
const mealTypeMap: Record<string, string> = {
'早餐': 'breakfast',
'午餐': 'lunch',
'晚餐': 'dinner',
'加餐': 'snack'
};
const coachUrl = buildCoachDeepLink({
action: 'diet',
subAction: 'card',
meal: mealTypeMap[meal] as 'breakfast' | 'lunch' | 'dinner' | 'snack'
});
return {
title: `${meal}提醒`,
body: `${userName},记得记录您的${meal}情况`,
data: {
type: 'meal_reminder',
meal,
url: coachUrl
},
sound: true,
priority: 'normal' as const,
};
},
lunch: (userName: string) => {
const coachUrl = buildCoachDeepLink({
action: 'diet',
subAction: 'card',
meal: 'lunch'
});
return {
title: '午餐记录提醒',
body: `${userName},记得记录今天的午餐情况哦!`,
data: {
type: 'lunch_reminder',
meal: '午餐',
url: coachUrl
},
sound: true,
priority: 'normal' as const,
};
},
},
};