fix(mp): 安全修复 + 健康Tab重构为总览
Phase 0 安全修复: - 移除 secure-storage-aes.ts 硬编码 'hms-default-key' fallback - production 模式空密钥时拒绝加解密(返回空/不加密) - dev 模式保留明文兼容(warn 日志提醒) - .env/.env.h5 注入随机加密密钥 - secureGet 明文 fallback 按环境分级处理 - 新增 8 个测试覆盖空密钥 dev/production 行为 Phase 1 健康Tab重构: - health/index.tsx 从体征录入页改为健康总览Dashboard - 新增今日体征摘要卡片(2x2 网格 + 状态标签) - 新增快捷入口(录入体征/趋势/报告/用药) - 新增告警提示卡片(待处理告警数量) - 体征录入移至 pkg-health/input/index(已有页面) - useHealthData → useHealthOverview(新增 alertCount) 首页增强: - useHomeData 新增告警计数查询(listPatientAlerts) - 首页新增告警提示卡片入口 - "记录体征"按钮改为跳转录入页而非健康Tab
This commit is contained in:
@@ -7,6 +7,7 @@ import * as appointmentApi from '@/services/appointment';
|
||||
import * as followupApi from '@/services/followup';
|
||||
import { listPendingSuggestions, type AiSuggestionItem } from '@/services/ai-analysis';
|
||||
import { notificationService } from '@/services/notification';
|
||||
import { listPatientAlerts } from '@/services/alert';
|
||||
|
||||
export interface ReminderItem {
|
||||
id: string;
|
||||
@@ -37,6 +38,7 @@ export function useHomeData() {
|
||||
const [reminders, setReminders] = useState<ReminderItem[]>([]);
|
||||
const [unreadCount, setUnreadCount] = useState(0);
|
||||
const [remindersLoading, setRemindersLoading] = useState(false);
|
||||
const [alertCount, setAlertCount] = useState(0);
|
||||
|
||||
const fetchData = async () => {
|
||||
const patientId = useAuthStore.getState().currentPatient?.id;
|
||||
@@ -44,6 +46,7 @@ export function useHomeData() {
|
||||
refreshToday();
|
||||
loadReminders(patientId);
|
||||
loadUnread();
|
||||
loadAlertCount(patientId);
|
||||
trackPageView('home');
|
||||
};
|
||||
|
||||
@@ -118,6 +121,15 @@ export function useHomeData() {
|
||||
}
|
||||
};
|
||||
|
||||
const loadAlertCount = async (patientId: string) => {
|
||||
try {
|
||||
const res = await listPatientAlerts(patientId, { status: 'pending', page: 1, page_size: 1 });
|
||||
setAlertCount(res.total ?? 0);
|
||||
} catch {
|
||||
setAlertCount(0);
|
||||
}
|
||||
};
|
||||
|
||||
const summary = todaySummary || {};
|
||||
const indicators = [!!summary.blood_pressure, !!summary.heart_rate, !!summary.blood_sugar, !!summary.weight];
|
||||
const completedCount = indicators.filter(Boolean).length;
|
||||
@@ -149,6 +161,7 @@ export function useHomeData() {
|
||||
reminders,
|
||||
unreadCount,
|
||||
remindersLoading,
|
||||
alertCount,
|
||||
indicatorCapsules,
|
||||
healthItems,
|
||||
completedCount,
|
||||
|
||||
Reference in New Issue
Block a user