fix(mp): 患者端卡死深度审查修复 — CRITICAL 回归 + 并发保护 + 页栈溢出防护
CRITICAL: - 咨询详情页 loadData 引用已删除的 pollingRef → 移除残余引用 HIGH: - 401 重试递归改循环结构,避免并发限制器双 slot 占用 - 医生端 4 个列表页添加 loadingRef 防重入(consultation/alerts/dialysis/prescription) - 新增 safeNavigateTo 页栈溢出保护(栈≥9 自动 redirectTo) 前期修复一并提交: - 全局并发限制 MAX_CONCURRENT=8 - doRefresh 失败时完整清理 Storage + 重置缓存状态 - 401 跳转登录页修正 - 长轮询 generation counter 模式 - 首页/健康页 loadingRef + refreshToday 去重
This commit is contained in:
@@ -21,6 +21,8 @@ const CACHE_TTL = 5 * 60 * 1000;
|
||||
const TODAY_SUMMARY_TTL = 60_000;
|
||||
const MAX_TREND_KEYS = 20;
|
||||
|
||||
let refreshingToday = false;
|
||||
|
||||
export const useHealthStore = create<HealthState>((set, get) => ({
|
||||
todaySummary: null,
|
||||
todaySummaryFetchedAt: 0,
|
||||
@@ -28,10 +30,12 @@ export const useHealthStore = create<HealthState>((set, get) => ({
|
||||
loading: false,
|
||||
|
||||
refreshToday: async (force = false) => {
|
||||
if (refreshingToday) return;
|
||||
const state = get();
|
||||
if (!force && state.todaySummary && Date.now() - state.todaySummaryFetchedAt < TODAY_SUMMARY_TTL) {
|
||||
return;
|
||||
}
|
||||
refreshingToday = true;
|
||||
set({ loading: true });
|
||||
try {
|
||||
const patientId = Taro.getStorageSync('current_patient_id') || undefined;
|
||||
@@ -39,6 +43,8 @@ export const useHealthStore = create<HealthState>((set, get) => ({
|
||||
set({ todaySummary: data, todaySummaryFetchedAt: Date.now(), loading: false });
|
||||
} catch {
|
||||
set({ loading: false });
|
||||
} finally {
|
||||
refreshingToday = false;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user