fix(miniprogram): 首页体征数据加载时序 + 并发控制 + 权限修复
- ConcurrencyLimiter 12→8 预留长轮询通道,避免超微信 10 并发限制 - usePageData 添加 AbortController,页面隐藏/卸载自动取消请求 - useHomeData 添加 useEffect 监听 currentPatient 变化自动触发数据加载 - 医护人员首页跳转前不渲染 HomeDashboard,避免触发无用 API 请求 - auth.ts getPatients 正确提取分页响应 .data 数组 - health.ts getTodaySummary 从 Storage 回退读取 patient_id - health store refreshToday 从 auth store 回退获取 currentPatient.id - auth store restore() 状态变化时清理请求缓存,避免返回过期数据
This commit is contained in:
@@ -48,6 +48,12 @@ export async function wechatBindPhone(openid: string, encryptedData: string, iv:
|
||||
});
|
||||
}
|
||||
|
||||
export async function getPatients() {
|
||||
return api.get<PatientInfo[]>('/health/patients');
|
||||
interface PaginatedData<T> {
|
||||
data: T[];
|
||||
total: number;
|
||||
}
|
||||
|
||||
export async function getPatients() {
|
||||
const res = await api.get<PaginatedData<PatientInfo>>('/health/patients');
|
||||
return Array.isArray(res?.data) ? res.data : (Array.isArray(res) ? res : []);
|
||||
}
|
||||
|
||||
@@ -17,8 +17,9 @@ export interface TodaySummary {
|
||||
}
|
||||
|
||||
export async function getTodaySummary(patientId?: string) {
|
||||
const pid = patientId || Taro.getStorageSync('current_patient_id') || '';
|
||||
const params: Record<string, string> = {};
|
||||
if (patientId) params.patient_id = patientId;
|
||||
if (pid) params.patient_id = pid;
|
||||
return api.get<TodaySummary>('/health/vital-signs/today', params);
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ class ConcurrencyLimiter {
|
||||
}
|
||||
}
|
||||
|
||||
const limiter = new ConcurrencyLimiter(12);
|
||||
const limiter = new ConcurrencyLimiter(8);
|
||||
|
||||
// --- Response cache + deduplication ---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user