fix(ai): Copilot 审计修复 — C-1/H-1/H-2/H-3/H-4/H-5/L-2

- L-2: value_to_f64 对 Null 返回 NaN(防止误触发规则)
- C-1: load_patient_data 空数据时跳过写入快照
- H-1: 每日刷新定时器添加初始延迟
- H-2: copilot_consumer 传内层 content
- H-3: 前端 hooks/Alert 修复分页响应解析
- H-4: risk_handler 动态选择 AI provider
- H-5: 新增 DELETE /copilot/rules/{id} 软删除路由
This commit is contained in:
iven
2026-05-13 00:21:27 +08:00
parent 6d97328ff6
commit d6676abecf
9 changed files with 73 additions and 9 deletions

View File

@@ -19,8 +19,8 @@ export function CopilotAlert() {
setLoading(true);
try {
const res = await listAlerts({ page_size: 50 });
const result = res.data as unknown as { items: CopilotInsight[]; total: number };
setAlerts(result.items ?? []);
const payload = (res.data as { data?: CopilotInsight[] }).data ?? [];
setAlerts(payload);
} catch {
// 静默
} finally {

View File

@@ -12,9 +12,10 @@ export function useCopilotInsights(patientId: string | undefined) {
setLoading(true);
try {
const res = await listInsights({ patient_id: patientId, page_size: 20 });
const result = res.data as unknown as { items: CopilotInsight[]; total: number };
setData(result.items ?? []);
setTotal(result.total ?? 0);
const payload = (res.data as { data?: CopilotInsight[]; total?: number }).data ?? [];
const total = (res.data as { total?: number }).total ?? 0;
setData(payload);
setTotal(total);
} catch {
// 静默失败
} finally {

View File

@@ -13,7 +13,8 @@ export function useCopilotRisk(patientId: string | undefined) {
setError(null);
try {
const res = await getPatientRisk(patientId);
setData(res.data as unknown as RiskScore);
const payload = (res.data as { data?: RiskScore }).data ?? null;
setData(payload);
} catch (err) {
setError(err instanceof Error ? err.message : '加载风险评分失败');
} finally {