feat(background-task): 完善iOS后台任务系统并优化断食通知和UI体验

- 修复iOS后台任务注册时机问题,确保任务能正常触发
- 添加后台任务调试辅助工具和完整测试指南
- 优化断食通知系统,增加防抖机制避免频繁重调度
- 改进断食自动续订逻辑,使用固定时间而非相对时间计算
- 优化统计页面布局,添加身体指标section标题
- 增强饮水详情页面视觉效果,改进卡片样式和配色
- 添加用户反馈入口到个人设置页面
- 完善锻炼摘要卡片条件渲染逻辑
- 增强日志记录和错误处理机制

这些改进显著提升了应用的稳定性、性能和用户体验,特别是在iOS后台任务执行和断食功能方面。
This commit is contained in:
richarjiang
2025-11-05 11:23:33 +08:00
parent d74046498d
commit ea22901553
12 changed files with 1060 additions and 171 deletions

View File

@@ -1,8 +1,8 @@
import { FastingPlan } from '@/constants/Fasting';
import {
ensureFastingNotificationsReady,
resyncFastingNotifications,
verifyFastingNotifications,
ensureFastingNotificationsReady,
resyncFastingNotifications,
verifyFastingNotifications,
} from '@/services/fastingNotifications';
import { FastingSchedule } from '@/store/fastingSlice';
import { FastingNotificationIds, loadStoredFastingNotificationIds } from '@/utils/fasting';
@@ -169,11 +169,17 @@ export const useFastingNotifications = (
}, [initialize]);
// 当计划或方案变化时验证和同步
// 添加防抖机制,避免频繁的通知重新调度
useEffect(() => {
if (state.isReady) {
if (!state.isReady) return;
// 使用防抖延迟执行,避免在快速状态变化时重复触发
const debounceTimer = setTimeout(() => {
verifyAndSync();
}
}, [state.isReady, schedule?.startISO, schedule?.endISO, plan?.id, verifyAndSync]);
}, 1000); // 1秒防抖
return () => clearTimeout(debounceTimer);
}, [state.isReady, schedule?.startISO, schedule?.endISO, plan?.id]);
return {
...state,