feat(mp): App 级告警长轮询 + 健康总览 TS 修复
- 新增 useAlertPolling hook:10s 间隔轮询 critical 告警 - requestUnlimited 独立通道,不占并发槽位 - generation counter 防重叠 + 失败指数退避(max 30s/10次) - 新告警弹窗 Taro.showModal + TabBar 角标 - 修复 HealthThreshold 属性名(indicator/level 非 indicator_name/severity) - 修复 usePageData fetchData 返回类型
This commit is contained in:
@@ -64,15 +64,15 @@ export default function Health() {
|
||||
if (!thresholds.length) return null;
|
||||
const th = thresholds;
|
||||
if (type === 'blood_pressure') {
|
||||
const v = th.find((t) => t.indicator_name === 'systolic_bp' && t.severity === 'high');
|
||||
const v = th.find((t) => t.indicator === 'systolic_bp' && t.level === 'high');
|
||||
return v?.threshold_value ?? 140;
|
||||
}
|
||||
if (type === 'heart_rate') {
|
||||
const v = th.find((t) => t.indicator_name === 'heart_rate' && t.severity === 'high');
|
||||
const v = th.find((t) => t.indicator === 'heart_rate' && t.level === 'high');
|
||||
return v?.threshold_value ?? 100;
|
||||
}
|
||||
if (type === 'blood_sugar') {
|
||||
const v = th.find((t) => t.indicator_name === 'blood_sugar_fasting' && t.severity === 'high');
|
||||
const v = th.find((t) => t.indicator === 'blood_sugar_fasting' && t.level === 'high');
|
||||
return v?.threshold_value ?? 6.1;
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -74,14 +74,13 @@ export function useHealthOverview() {
|
||||
};
|
||||
|
||||
const fetchData = async () => {
|
||||
const results = await Promise.allSettled([
|
||||
await Promise.allSettled([
|
||||
refreshToday(),
|
||||
loadTrend(activeTab),
|
||||
loadAiSuggestions(),
|
||||
loadAlertCount(),
|
||||
getHealthThresholds().then((t) => { if (t.length > 0) setThresholds(t); }),
|
||||
]);
|
||||
return results;
|
||||
};
|
||||
|
||||
usePageData(fetchData, {
|
||||
|
||||
Reference in New Issue
Block a user