feat(medication): 重构AI分析为结构化展示并支持喝水提醒个性化配置

- 将药品AI分析从Markdown流式输出重构为结构化数据展示(V2)
- 新增适合人群、不适合人群、主要成分、副作用等分类卡片展示
- 优化AI分析UI布局,采用卡片式设计提升可读性
- 新增药品跳过功能,支持用户标记本次用药为已跳过
- 修复喝水提醒逻辑,支持用户开关控制和自定义时间段配置
- 优化个人资料编辑页面键盘适配,避免输入框被遮挡
- 统一API响应码处理,兼容200和0两种成功状态码
- 更新版本号至1.0.28

BREAKING CHANGE: 药品AI分析接口从流式Markdown输出改为结构化JSON格式,旧版本分析结果将不再显示
This commit is contained in:
richarjiang
2025-11-20 10:10:53 +08:00
parent b36922756d
commit 84abfa2506
12 changed files with 913 additions and 293 deletions

View File

@@ -1,6 +1,6 @@
import * as Notifications from 'expo-notifications';
import { NotificationData, NotificationTypes, notificationService } from '../services/notifications';
import { getNotificationEnabled } from './userPreferences';
import { getNotificationEnabled, getWaterReminderEnabled } from './userPreferences';
/**
* 构建 coach 页面的深度链接
@@ -433,6 +433,13 @@ export class WaterNotificationHelpers {
currentHour: number = new Date().getHours()
): Promise<boolean> {
try {
// 首先检查用户是否启用了喝水提醒
const isWaterReminderEnabled = await getWaterReminderEnabled();
if (!isWaterReminderEnabled) {
console.log('用户未启用喝水提醒,跳过通知检查');
return false;
}
// 检查时间限制早上9点以前和晚上9点以后不通知
if (currentHour < 9 || currentHour >= 23) {
console.log(`当前时间${currentHour}不在通知时间范围内9:00-21:00跳过喝水提醒`);
@@ -546,6 +553,15 @@ export class WaterNotificationHelpers {
*/
static async scheduleRegularWaterReminders(userName: string): Promise<string[]> {
try {
// 首先检查用户是否启用了喝水提醒
const isWaterReminderEnabled = await getWaterReminderEnabled();
if (!isWaterReminderEnabled) {
console.log('用户未启用喝水提醒,不安排定期提醒');
// 确保取消任何可能存在的旧提醒
await this.cancelAllWaterReminders();
return [];
}
const notificationIds: string[] = [];
// 检查是否已经存在定期喝水提醒