feat: 移除目标管理功能模块

删除了完整的目标管理功能,包括目标创建、编辑、任务管理等相关页面和组件。同时移除了相关的API服务、Redux状态管理、类型定义和通知功能。应用版本从1.0.20升级到1.0.21。
This commit is contained in:
richarjiang
2025-10-31 08:49:22 +08:00
parent 7cd290d341
commit 16c2351160
31 changed files with 953 additions and 7884 deletions

View File

@@ -1,18 +1,16 @@
import AsyncStorage from '@/utils/kvStore';
// 引导状态存储键
const GUIDE_KEYS = {
GOALS_PAGE: '@guide_goals_page_completed',
} as const;
const GUIDE_KEYS = {} as const;
/**
* 检查用户是否已经完成特定引导
* @param guideKey 引导键名
* @returns Promise<boolean> 是否已完成
*/
export const checkGuideCompleted = async (guideKey: keyof typeof GUIDE_KEYS): Promise<boolean> => {
export const checkGuideCompleted = async (guideKey: string): Promise<boolean> => {
try {
const completed = await AsyncStorage.getItem(GUIDE_KEYS[guideKey]);
const completed = await AsyncStorage.getItem(guideKey);
return completed === 'true';
} catch (error) {
console.error('检查引导状态失败:', error);
@@ -24,9 +22,9 @@ export const checkGuideCompleted = async (guideKey: keyof typeof GUIDE_KEYS): Pr
* 标记引导为已完成
* @param guideKey 引导键名
*/
export const markGuideCompleted = async (guideKey: keyof typeof GUIDE_KEYS): Promise<void> => {
export const markGuideCompleted = async (guideKey: string): Promise<void> => {
try {
await AsyncStorage.setItem(GUIDE_KEYS[guideKey], 'true');
await AsyncStorage.setItem(guideKey, 'true');
} catch (error) {
console.error('保存引导状态失败:', error);
}
@@ -37,9 +35,8 @@ export const markGuideCompleted = async (guideKey: keyof typeof GUIDE_KEYS): Pro
*/
export const resetAllGuides = async (): Promise<void> => {
try {
const keys = Object.values(GUIDE_KEYS);
await AsyncStorage.multiRemove(keys);
console.log('所有引导状态已重置');
// 由于没有引导键,这个函数现在什么都不做
console.log('所有引导状态已重置(无引导键)');
} catch (error) {
console.error('重置引导状态失败:', error);
}
@@ -51,15 +48,8 @@ export const resetAllGuides = async (): Promise<void> => {
*/
export const getAllGuideStatus = async (): Promise<Record<string, boolean>> => {
try {
const result: Record<string, boolean> = {};
const keys = Object.values(GUIDE_KEYS);
for (const key of keys) {
const completed = await AsyncStorage.getItem(key);
result[key] = completed === 'true';
}
return result;
// 由于没有引导键,返回空对象
return {};
} catch (error) {
console.error('获取引导状态失败:', error);
return {};

View File

@@ -78,214 +78,7 @@ export class WorkoutNotificationHelpers {
}
}
/**
* 目标相关的通知辅助函数
*/
export class GoalNotificationHelpers {
/**
* 发送目标达成通知
*/
static async sendGoalAchievementNotification(userName: string, goalName: string) {
return notificationService.sendImmediateNotification({
title: '目标达成',
body: `${userName},恭喜您达成了目标:${goalName}`,
data: { type: 'goal_achievement', goalName },
sound: true,
priority: 'high',
});
}
/**
* 发送目标进度更新通知
*/
static async sendGoalProgressNotification(userName: string, goalName: string, progress: number) {
return notificationService.sendImmediateNotification({
title: '目标进度',
body: `${userName},您的目标"${goalName}"已完成${progress}%`,
data: { type: 'goal_progress', goalName, progress },
sound: true,
priority: 'normal',
});
}
/**
* 安排目标提醒
*/
static async scheduleGoalReminder(userName: string, goalName: string, deadline: Date) {
// 在截止日期前一天发送提醒
const reminderDate = new Date(deadline);
reminderDate.setDate(reminderDate.getDate() - 1);
return notificationService.scheduleNotificationAtDate(
{
title: '目标截止提醒',
body: `${userName},您的目标"${goalName}"明天就要截止了,加油!`,
data: { type: 'goal_deadline_reminder', goalName },
sound: true,
priority: 'high',
},
reminderDate
);
}
/**
* 根据目标设置创建定时推送
* @param goalData 目标数据
* @param userName 用户名
* @returns 通知ID数组
*/
static async scheduleGoalNotifications(
goalData: {
title: string;
repeatType: 'daily' | 'weekly' | 'monthly';
frequency: number;
hasReminder: boolean;
reminderTime?: string;
customRepeatRule?: {
weekdays?: number[];
dayOfMonth?: number[];
};
startTime?: number;
},
userName: string
): Promise<string[]> {
const notificationIds: string[] = [];
// 如果没有开启提醒,直接返回
if (!goalData.hasReminder || !goalData.reminderTime) {
console.log('目标未开启提醒或未设置提醒时间');
return notificationIds;
}
try {
// 解析提醒时间
const [hours, minutes] = goalData.reminderTime.split(':').map(Number);
// 创建通知内容
const notification: NotificationData = {
title: '目标提醒',
body: `${userName},该完成您的目标"${goalData.title}"了!`,
data: {
type: 'goal_reminder',
goalTitle: goalData.title,
repeatType: goalData.repeatType,
frequency: goalData.frequency
},
sound: true,
priority: 'high',
};
// 根据重复类型创建不同的通知
switch (goalData.repeatType) {
case 'daily':
// 每日重复 - 使用日历重复通知
const dailyId = await notificationService.scheduleCalendarRepeatingNotification(
notification,
{
type: Notifications.SchedulableTriggerInputTypes.DAILY,
hour: hours,
minute: minutes,
}
);
notificationIds.push(dailyId);
console.log(`已安排每日目标提醒通知ID${dailyId}`);
break;
case 'weekly':
// 每周重复 - 为每个选中的星期几创建单独的通知
if (goalData.customRepeatRule?.weekdays && goalData.customRepeatRule.weekdays.length > 0) {
for (const weekday of goalData.customRepeatRule.weekdays) {
const weeklyId = await notificationService.scheduleCalendarRepeatingNotification(
notification,
{
type: Notifications.SchedulableTriggerInputTypes.WEEKLY,
hour: hours,
minute: minutes,
weekdays: [weekday],
}
);
notificationIds.push(weeklyId);
console.log(`已安排每周目标提醒,星期${weekday}通知ID${weeklyId}`);
}
} else {
// 默认每周重复
const weeklyId = await notificationService.scheduleCalendarRepeatingNotification(
notification,
{
type: Notifications.SchedulableTriggerInputTypes.WEEKLY,
hour: hours,
minute: minutes,
}
);
notificationIds.push(weeklyId);
console.log(`已安排每周目标提醒通知ID${weeklyId}`);
}
break;
case 'monthly':
// 每月重复 - 为每个选中的日期创建单独的通知
if (goalData.customRepeatRule?.dayOfMonth && goalData.customRepeatRule.dayOfMonth.length > 0) {
for (const dayOfMonth of goalData.customRepeatRule.dayOfMonth) {
const monthlyId = await notificationService.scheduleCalendarRepeatingNotification(
notification,
{
type: Notifications.SchedulableTriggerInputTypes.MONTHLY,
hour: hours,
minute: minutes,
dayOfMonth: dayOfMonth,
}
);
notificationIds.push(monthlyId);
console.log(`已安排每月目标提醒,${dayOfMonth}通知ID${monthlyId}`);
}
} else {
// 默认每月重复
const monthlyId = await notificationService.scheduleCalendarRepeatingNotification(
notification,
{
type: Notifications.SchedulableTriggerInputTypes.MONTHLY,
hour: hours,
minute: minutes,
dayOfMonth: 1,
}
);
notificationIds.push(monthlyId);
console.log(`已安排每月目标提醒通知ID${monthlyId}`);
}
break;
}
console.log(`目标"${goalData.title}"的定时推送已创建完成,共${notificationIds.length}个通知`);
return notificationIds;
} catch (error) {
console.error('创建目标定时推送失败:', error);
throw error;
}
}
/**
* 取消特定目标的所有通知
*/
static async cancelGoalNotifications(goalTitle: string): Promise<void> {
try {
const notifications = await notificationService.getAllScheduledNotifications();
for (const notification of notifications) {
if (notification.content.data?.type === 'goal_reminder' &&
notification.content.data?.goalTitle === goalTitle) {
await notificationService.cancelNotification(notification.identifier);
console.log(`已取消目标"${goalTitle}"的通知:${notification.identifier}`);
}
}
} catch (error) {
console.error('取消目标通知失败:', error);
throw error;
}
}
}
// GoalNotificationHelpers 类已删除,因为目标功能已移除
export class ChallengeNotificationHelpers {
static buildChallengesTabUrl(): string {

View File

@@ -46,7 +46,6 @@ export function generateWelcomeMessage(params: GenerateWelcomeMessageParams): We
content: `你好,${name}!🐳\n\n我是你的小海豹Seal发现你还没有完善健康档案呢让我帮你开启个性化的健康管理之旅吧\n\n完善档案后我就能为你量身定制专属的营养方案、运动计划和生活建议啦`,
choices: [
{ id: 'profile_setup', label: '完善我的健康档案', value: '我想要完善健康档案,建立个人健康数据', emoji: '📋', recommended: true },
{ id: 'health_goals', label: '了解健康目标设定', value: '我想了解如何设定合理的健康目标', emoji: '🎯' },
{ id: 'nutrition_basics', label: '营养基础知识科普', value: '我想了解一些基础的营养知识', emoji: '🥗' },
{ id: 'quick_start', label: '快速开始体验', value: '我想直接体验一下你的功能', emoji: '🚀' }
],