fix(mp): 空 catch 块添加 console.warn 日志(82 处)

55 个文件中 82 处空 catch 块添加模块前缀日志输出:
- stores: auth/health/points (7 处)
- services: request/ai-chat/health/ble/* (10 处)
- hooks: useLongPolling/usePagination (3 处)
- pages: 核心+子包共 35 个页面 (62 处)

保留静默的 catch: secure-storage fallback、Storage 恢复、
analytics 防洪、BLE 断连清理、用户拒绝订阅等合理忽略场景
This commit is contained in:
iven
2026-05-21 13:44:13 +08:00
parent 652cccf66c
commit d576b8ba8f
68 changed files with 223 additions and 124 deletions

View File

@@ -55,7 +55,8 @@ export function useLongPolling<T>({
onDataRef.current(data); onDataRef.current(data);
} }
failCount = 0; failCount = 0;
} catch { } catch (err) {
console.warn('[long-polling] 轮询失败:', err);
failCount++; failCount++;
} }
if (gen !== generation.current || !mountedRef.current) return; if (gen !== generation.current || !mountedRef.current) return;

View File

@@ -32,8 +32,8 @@ export function usePagination<T>(
setTotal(res.total); setTotal(res.total);
setHasMore(items.length >= pageSize); setHasMore(items.length >= pageSize);
pageRef.current += 1; pageRef.current += 1;
} catch { } catch (err) {
// 错误由调用方处理 console.warn('[pagination] 加载分页数据失败:', err);
} finally { } finally {
loadingRef.current = false; loadingRef.current = false;
setLoading(false); setLoading(false);
@@ -53,8 +53,8 @@ export function usePagination<T>(
setTotal(res.total); setTotal(res.total);
setHasMore(items.length >= pageSize); setHasMore(items.length >= pageSize);
pageRef.current = 2; pageRef.current = 2;
} catch { } catch (err) {
// 错误由调用方处理 console.warn('[pagination] 加载分页数据失败:', err);
} finally { } finally {
loadingRef.current = false; loadingRef.current = false;
setLoading(false); setLoading(false);

View File

@@ -44,7 +44,8 @@ export default function AiReportDetail() {
try { try {
const data = await getAiAnalysisDetail(id); const data = await getAiAnalysisDetail(id);
setAnalysis(data); setAnalysis(data);
} catch { } catch (err) {
console.warn('[ai-report] 加载分析详情失败:', err);
Taro.showToast({ title: '加载失败', icon: 'none' }); Taro.showToast({ title: '加载失败', icon: 'none' });
} finally { } finally {
setLoading(false); setLoading(false);

View File

@@ -40,7 +40,8 @@ export default function AiReportList() {
setPage(p); setPage(p);
setHasMore(items.length >= 20); setHasMore(items.length >= 20);
} catch { } catch (err) {
console.warn('[ai-report] 加载分析列表失败:', err);
Taro.showToast({ title: '加载失败', icon: 'none' }); Taro.showToast({ title: '加载失败', icon: 'none' });
} finally { } finally {
setLoading(false); setLoading(false);

View File

@@ -64,7 +64,8 @@ export default function AppointmentCreate() {
try { try {
const res = await listDoctors(dept); const res = await listDoctors(dept);
setDoctors(res.data || []); setDoctors(res.data || []);
} catch { } catch (err) {
console.warn('[appointment] 加载医生列表失败:', err);
Taro.showToast({ title: '加载医生失败', icon: 'none' }); Taro.showToast({ title: '加载医生失败', icon: 'none' });
} }
}, []); }, []);
@@ -79,8 +80,8 @@ export default function AppointmentCreate() {
const fmt = (d: Date) => `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`; const fmt = (d: Date) => `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;
const res = await calendarView(fmt(today), fmt(endDate), doctor.id); const res = await calendarView(fmt(today), fmt(endDate), doctor.id);
setSchedules(res || []); setSchedules(res || []);
} catch { } catch (err) {
// 日历加载失败不阻塞 console.warn('[appointment] 加载日历排班失败:', err);
} finally { } finally {
setLoading(false); setLoading(false);
} }

View File

@@ -61,7 +61,8 @@ export default function AppointmentDetail() {
await cancelAppointment(appointment.id, appointment.version); await cancelAppointment(appointment.id, appointment.version);
Taro.showToast({ title: '已取消预约', icon: 'success' }); Taro.showToast({ title: '已取消预约', icon: 'success' });
safeSetTimeout(() => Taro.navigateBack(), 1500); safeSetTimeout(() => Taro.navigateBack(), 1500);
} catch { } catch (err) {
console.warn('[appointment] 取消预约失败:', err);
Taro.showToast({ title: '取消失败', icon: 'none' }); Taro.showToast({ title: '取消失败', icon: 'none' });
} finally { } finally {
setCancelling(false); setCancelling(false);

View File

@@ -47,7 +47,8 @@ export default function AppointmentList() {
} }
setTotal(res.total); setTotal(res.total);
setPage(pageNum); setPage(pageNum);
} catch { } catch (err) {
console.warn('[appointment] 加载预约列表失败:', err);
Taro.showToast({ title: '加载失败', icon: 'none' }); Taro.showToast({ title: '加载失败', icon: 'none' });
} finally { } finally {
setLoading(false); setLoading(false);

View File

@@ -34,7 +34,8 @@ export default function ArticleDetail() {
const fetcher = user ? getArticleDetail(id) : getPublicArticleDetail(id); const fetcher = user ? getArticleDetail(id) : getPublicArticleDetail(id);
const data = await fetcher; const data = await fetcher;
setArticle(data); setArticle(data);
} catch { } catch (err) {
console.warn('[article] 加载文章详情失败:', err);
Taro.showToast({ title: '加载失败', icon: 'none' }); Taro.showToast({ title: '加载失败', icon: 'none' });
} finally { } finally {
setLoading(false); setLoading(false);

View File

@@ -54,7 +54,8 @@ export default function ArticleList() {
setArticles(append ? (prev) => [...prev, ...list] : list); setArticles(append ? (prev) => [...prev, ...list] : list);
setTotal(res.total); setTotal(res.total);
setPage(p); setPage(p);
} catch { } catch (err) {
console.warn('[article] 加载文章列表失败:', err);
setError(true); setError(true);
Taro.showToast({ title: '加载失败', icon: 'none' }); Taro.showToast({ title: '加载失败', icon: 'none' });
} finally { } finally {
@@ -67,7 +68,8 @@ export default function ArticleList() {
try { try {
const cats = await listCategories(); const cats = await listCategories();
setCategories(cats || []); setCategories(cats || []);
} catch { } catch (err) {
console.warn('[article] 加载分类失败:', err);
setCategories([]); setCategories([]);
} }
await fetchData(1); await fetchData(1);

View File

@@ -36,7 +36,8 @@ export default function ConsultationCreate() {
const items = (res.data || []).map((d: any) => ({ id: d.id, name: d.name })); const items = (res.data || []).map((d: any) => ({ id: d.id, name: d.name }));
setDoctorList(items); setDoctorList(items);
setDoctorsLoaded(true); setDoctorsLoaded(true);
} catch { } catch (err) {
console.warn('[consultation] 加载医生列表失败:', err);
Taro.showToast({ title: '加载医生列表失败', icon: 'none' }); Taro.showToast({ title: '加载医生列表失败', icon: 'none' });
} }
}; };
@@ -58,7 +59,8 @@ export default function ConsultationCreate() {
setTimeout(() => { setTimeout(() => {
Taro.redirectTo({ url: `/pages/pkg-consultation/detail/index?id=${session.id}` }); Taro.redirectTo({ url: `/pages/pkg-consultation/detail/index?id=${session.id}` });
}, 500); }, 500);
} catch { } catch (err) {
console.warn('[consultation] 创建会话失败:', err);
Taro.showToast({ title: '创建失败,请重试', icon: 'none' }); Taro.showToast({ title: '创建失败,请重试', icon: 'none' });
} finally { } finally {
setSubmitting(false); setSubmitting(false);

View File

@@ -29,7 +29,8 @@ function getQueryParams(): Record<string, string> {
} }
} }
return result; return result;
} catch { } catch (err) {
console.warn('[consultation] 解析查询参数失败:', err);
return {}; return {};
} }
} }
@@ -93,7 +94,8 @@ export default function Consultation() {
} }
setTotal(resp.total || 0); setTotal(resp.total || 0);
setPage(pageNum); setPage(pageNum);
} catch { } catch (err) {
console.warn('[consultation] 加载会话列表失败:', err);
if (isRefresh) { if (isRefresh) {
setSessions([]); setSessions([]);
setTotal(0); setTotal(0);

View File

@@ -148,7 +148,8 @@ export default function Health() {
Taro.showToast({ title: '保存成功', icon: 'success' }); Taro.showToast({ title: '保存成功', icon: 'success' });
refreshToday(true); refreshToday(true);
loadTrend(activeTab); loadTrend(activeTab);
} catch { } catch (err) {
console.warn('[health] 保存体征数据失败:', err);
Taro.showToast({ title: '保存失败', icon: 'none' }); Taro.showToast({ title: '保存失败', icon: 'none' });
} finally { } finally {
setSaving(false); setSaving(false);
@@ -200,7 +201,7 @@ export default function Health() {
await submitSuggestionFeedback(s.id, 'adopt'); await submitSuggestionFeedback(s.id, 'adopt');
Taro.showToast({ title: '已采纳', icon: 'success' }); Taro.showToast({ title: '已采纳', icon: 'success' });
fetchData(); fetchData();
} catch { Taro.showToast({ title: '操作失败', icon: 'none' }); } } catch (err) { console.warn('[health] AI建议反馈失败:', err); Taro.showToast({ title: '操作失败', icon: 'none' }); }
}}> }}>
<Text className='ai-feedback-btn-text'></Text> <Text className='ai-feedback-btn-text'></Text>
</View> </View>
@@ -209,7 +210,7 @@ export default function Health() {
await submitSuggestionFeedback(s.id, 'ignore'); await submitSuggestionFeedback(s.id, 'ignore');
Taro.showToast({ title: '已忽略', icon: 'success' }); Taro.showToast({ title: '已忽略', icon: 'success' });
fetchData(); fetchData();
} catch { Taro.showToast({ title: '操作失败', icon: 'none' }); } } catch (err) { console.warn('[health] AI建议反馈失败:', err); Taro.showToast({ title: '操作失败', icon: 'none' }); }
}}> }}>
<Text className='ai-feedback-btn-text'></Text> <Text className='ai-feedback-btn-text'></Text>
</View> </View>
@@ -217,7 +218,7 @@ export default function Health() {
try { try {
await submitSuggestionFeedback(s.id, 'consult'); await submitSuggestionFeedback(s.id, 'consult');
safeNavigateTo('/pages/consultation/index'); safeNavigateTo('/pages/consultation/index');
} catch { Taro.showToast({ title: '操作失败', icon: 'none' }); } } catch (err) { console.warn('[health] AI建议反馈失败:', err); Taro.showToast({ title: '操作失败', icon: 'none' }); }
}}> }}>
<Text className='ai-feedback-btn-text'></Text> <Text className='ai-feedback-btn-text'></Text>
</View> </View>

View File

@@ -44,7 +44,8 @@ export function useHealthData() {
}; };
const points = await fetchTrend(indicatorMap[type], '7d'); const points = await fetchTrend(indicatorMap[type], '7d');
setTrendData(points); setTrendData(points);
} catch { } catch (err) {
console.warn('[health] 加载趋势数据失败:', err);
setTrendData([]); setTrendData([]);
} finally { } finally {
setTrendLoading(false); setTrendLoading(false);
@@ -55,7 +56,8 @@ export function useHealthData() {
try { try {
const items = await listPendingSuggestions(); const items = await listPendingSuggestions();
setAiSuggestions(items.slice(0, 3)); setAiSuggestions(items.slice(0, 3));
} catch { } catch (err) {
console.warn('[health] 加载 AI 建议失败:', err);
setAiSuggestions([]); setAiSuggestions([]);
} }
}; };

View File

@@ -75,7 +75,8 @@ function GuestHome({ modeClass }: { modeClass: string }) {
if (articleData.status === 'fulfilled' && articleData.value?.data?.length > 0) { if (articleData.status === 'fulfilled' && articleData.value?.data?.length > 0) {
setArticles(articleData.value.data); setArticles(articleData.value.data);
} }
} catch { } catch (err) {
console.warn('[home] 加载首页数据失败:', err);
setBanners(FALLBACK_SLIDES); setBanners(FALLBACK_SLIDES);
Taro.showToast({ title: '内容加载失败', icon: 'none' }); Taro.showToast({ title: '内容加载失败', icon: 'none' });
} }

View File

@@ -69,7 +69,7 @@ export function useHomeData() {
const res = await notificationService.getUnreadCount() as { data?: { count?: number } | number }; const res = await notificationService.getUnreadCount() as { data?: { count?: number } | number };
const d = res.data; const d = res.data;
setUnreadCount(typeof d === 'object' && d ? (d.count ?? 0) : 0); setUnreadCount(typeof d === 'object' && d ? (d.count ?? 0) : 0);
} catch { /* ignore */ } } catch (err) { console.warn('[home] 获取未读消息数失败:', err); }
}; };
const loadReminders = async (patientId: string) => { const loadReminders = async (patientId: string) => {
@@ -110,7 +110,8 @@ export function useHomeData() {
} }
} }
setReminders(items.slice(0, 3)); setReminders(items.slice(0, 3));
} catch { } catch (err) {
console.warn('[home] 加载提醒列表失败:', err);
setReminders([]); setReminders([]);
} finally { } finally {
setRemindersLoading(false); setRemindersLoading(false);

View File

@@ -64,7 +64,8 @@ export default function Login() {
} else { } else {
Taro.showToast({ title: '账号或密码错误', icon: 'none' }); Taro.showToast({ title: '账号或密码错误', icon: 'none' });
} }
} catch { } catch (err) {
console.warn('[login] 登录失败:', err);
Taro.showToast({ title: '登录失败,请重试', icon: 'none' }); Taro.showToast({ title: '登录失败,请重试', icon: 'none' });
} }
}; };

View File

@@ -62,7 +62,8 @@ export default function Mall() {
} }
setTotal(res.total); setTotal(res.total);
setPage(pageNum); setPage(pageNum);
} catch { } catch (err) {
console.warn('[mall] 加载商品列表失败:', err);
setError(true); setError(true);
Taro.showToast({ title: '加载失败', icon: 'none' }); Taro.showToast({ title: '加载失败', icon: 'none' });
} finally { } finally {

View File

@@ -82,7 +82,8 @@ export default function Messages() {
setMessages(updated); setMessages(updated);
scrollToBottom(updated); scrollToBottom(updated);
saveLocalHistory(updated); saveLocalHistory(updated);
} catch { } catch (err) {
console.warn('[ai-chat] 发送消息失败:', err);
const errMsg: AiChatMessage = { const errMsg: AiChatMessage = {
id: genId(), id: genId(),
role: 'assistant', role: 'assistant',

View File

@@ -71,7 +71,8 @@ export default function ConsultationDetail() {
messagesRef.current = msgs; messagesRef.current = msgs;
scrollViewRef.current = `msg-${msgs.length}`; scrollViewRef.current = `msg-${msgs.length}`;
setDataLoaded(true); setDataLoaded(true);
} catch { } catch (err) {
console.warn('[consultation] 加载失败:', err);
Taro.showToast({ title: '加载失败', icon: 'none' }); Taro.showToast({ title: '加载失败', icon: 'none' });
} finally { } finally {
setLoading(false); setLoading(false);
@@ -97,7 +98,8 @@ export default function ConsultationDetail() {
scrollViewRef.current = `msg-${next.length}`; scrollViewRef.current = `msg-${next.length}`;
return next; return next;
}); });
} catch { } catch (err) {
console.warn('[consultation] 发送失败:', err);
Taro.showToast({ title: '发送失败', icon: 'none' }); Taro.showToast({ title: '发送失败', icon: 'none' });
setInputText(text); setInputText(text);
} finally { } finally {

View File

@@ -39,7 +39,8 @@ export default function AlertDetail() {
try { try {
const data = await getAlert(alertId); const data = await getAlert(alertId);
setAlert(data); setAlert(data);
} catch { } catch (err) {
console.warn('[doctor-alert] 加载失败:', err);
Taro.showToast({ title: '加载失败', icon: 'none' }); Taro.showToast({ title: '加载失败', icon: 'none' });
} finally { } finally {
setLoading(false); setLoading(false);
@@ -55,7 +56,8 @@ export default function AlertDetail() {
const updated = await acknowledgeAlert(alert.id, alert.version); const updated = await acknowledgeAlert(alert.id, alert.version);
setAlert(updated); setAlert(updated);
Taro.showToast({ title: '已确认', icon: 'success' }); Taro.showToast({ title: '已确认', icon: 'success' });
} catch { } catch (err) {
console.warn('[doctor-alert] 操作失败:', err);
Taro.showToast({ title: '操作失败', icon: 'none' }); Taro.showToast({ title: '操作失败', icon: 'none' });
} finally { } finally {
setActionLoading(false); setActionLoading(false);
@@ -69,7 +71,8 @@ export default function AlertDetail() {
const updated = await dismissAlert(alert.id, alert.version); const updated = await dismissAlert(alert.id, alert.version);
setAlert(updated); setAlert(updated);
Taro.showToast({ title: '已忽略', icon: 'success' }); Taro.showToast({ title: '已忽略', icon: 'success' });
} catch { } catch (err) {
console.warn('[doctor-alert] 操作失败:', err);
Taro.showToast({ title: '操作失败', icon: 'none' }); Taro.showToast({ title: '操作失败', icon: 'none' });
} finally { } finally {
setActionLoading(false); setActionLoading(false);
@@ -83,7 +86,8 @@ export default function AlertDetail() {
const updated = await resolveAlert(alert.id, alert.version); const updated = await resolveAlert(alert.id, alert.version);
setAlert(updated); setAlert(updated);
Taro.showToast({ title: '已恢复', icon: 'success' }); Taro.showToast({ title: '已恢复', icon: 'success' });
} catch { } catch (err) {
console.warn('[doctor-alert] 操作失败:', err);
Taro.showToast({ title: '操作失败', icon: 'none' }); Taro.showToast({ title: '操作失败', icon: 'none' });
} finally { } finally {
setActionLoading(false); setActionLoading(false);

View File

@@ -71,7 +71,8 @@ export default function AlertList() {
}); });
setAlerts(res.data || []); setAlerts(res.data || []);
setTotal(res.total || 0); setTotal(res.total || 0);
} catch { } catch (err) {
console.warn('[doctor-alert] 加载数据失败:', err);
setError(true); setError(true);
Taro.showToast({ title: '加载失败', icon: 'none' }); Taro.showToast({ title: '加载失败', icon: 'none' });
} finally { } finally {

View File

@@ -113,7 +113,8 @@ export default function DialysisCreate() {
ultrafiltration_volume: r.ultrafiltration_volume != null ? String(r.ultrafiltration_volume) : '', ultrafiltration_volume: r.ultrafiltration_volume != null ? String(r.ultrafiltration_volume) : '',
complication_notes: r.complication_notes || '', complication_notes: r.complication_notes || '',
}); });
} catch { } catch (err) {
console.warn('[doctor-dialysis] 加载失败:', err);
Taro.showToast({ title: '加载失败', icon: 'none' }); Taro.showToast({ title: '加载失败', icon: 'none' });
} finally { } finally {
setLoading(false); setLoading(false);
@@ -167,7 +168,8 @@ export default function DialysisCreate() {
Taro.showToast({ title: '创建成功', icon: 'success' }); Taro.showToast({ title: '创建成功', icon: 'success' });
} }
safeSetTimeout(() => Taro.navigateBack(), 1000); safeSetTimeout(() => Taro.navigateBack(), 1000);
} catch { } catch (err) {
console.warn('[doctor-dialysis] 操作失败:', err);
Taro.showToast({ title: isEdit ? '更新失败' : '创建失败', icon: 'none' }); Taro.showToast({ title: isEdit ? '更新失败' : '创建失败', icon: 'none' });
} finally { } finally {
setSubmitting(false); setSubmitting(false);

View File

@@ -30,7 +30,8 @@ export default function DialysisDetail() {
try { try {
const r = await getDialysisRecord(id); const r = await getDialysisRecord(id);
setRecord(r); setRecord(r);
} catch { } catch (err) {
console.warn('[doctor-dialysis] 加载失败:', err);
Taro.showToast({ title: '加载失败', icon: 'none' }); Taro.showToast({ title: '加载失败', icon: 'none' });
} finally { } finally {
setLoading(false); setLoading(false);
@@ -46,7 +47,8 @@ export default function DialysisDetail() {
const updated = await reviewDialysisRecord(id, record.version); const updated = await reviewDialysisRecord(id, record.version);
setRecord(updated); setRecord(updated);
Taro.showToast({ title: '审核完成', icon: 'success' }); Taro.showToast({ title: '审核完成', icon: 'success' });
} catch { } catch (err) {
console.warn('[doctor-dialysis] 审核失败:', err);
Taro.showToast({ title: '审核失败', icon: 'none' }); Taro.showToast({ title: '审核失败', icon: 'none' });
} finally { } finally {
setSubmitting(false); setSubmitting(false);
@@ -60,7 +62,8 @@ export default function DialysisDetail() {
const updated = await updateDialysisRecord(id, { status: 'completed' }, record.version); const updated = await updateDialysisRecord(id, { status: 'completed' }, record.version);
setRecord(updated); setRecord(updated);
Taro.showToast({ title: '已标记完成', icon: 'success' }); Taro.showToast({ title: '已标记完成', icon: 'success' });
} catch { } catch (err) {
console.warn('[doctor-dialysis] 操作失败:', err);
Taro.showToast({ title: '操作失败', icon: 'none' }); Taro.showToast({ title: '操作失败', icon: 'none' });
} finally { } finally {
setSubmitting(false); setSubmitting(false);
@@ -79,7 +82,8 @@ export default function DialysisDetail() {
await deleteDialysisRecord(id, record.version); await deleteDialysisRecord(id, record.version);
Taro.showToast({ title: '已删除', icon: 'success' }); Taro.showToast({ title: '已删除', icon: 'success' });
safeSetTimeout(() => Taro.navigateBack(), 1000); safeSetTimeout(() => Taro.navigateBack(), 1000);
} catch { } catch (err) {
console.warn('[doctor-dialysis] 删除失败:', err);
Taro.showToast({ title: '删除失败', icon: 'none' }); Taro.showToast({ title: '删除失败', icon: 'none' });
setSubmitting(false); setSubmitting(false);
} }

View File

@@ -57,7 +57,8 @@ export default function DialysisList() {
setRecords(res.data || []); setRecords(res.data || []);
setTotal(res.total || 0); setTotal(res.total || 0);
setPage(p); setPage(p);
} catch { } catch (err) {
console.warn('[doctor-dialysis] 加载数据失败:', err);
setError(true); setError(true);
Taro.showToast({ title: '加载失败', icon: 'none' }); Taro.showToast({ title: '加载失败', icon: 'none' });
} finally { } finally {
@@ -89,7 +90,8 @@ export default function DialysisList() {
} else { } else {
Taro.showToast({ title: '未找到患者', icon: 'none' }); Taro.showToast({ title: '未找到患者', icon: 'none' });
} }
} catch { } catch (err) {
console.warn('[doctor-dialysis] 搜索失败:', err);
Taro.showToast({ title: '搜索失败', icon: 'none' }); Taro.showToast({ title: '搜索失败', icon: 'none' });
} finally { } finally {
setLoading(false); setLoading(false);

View File

@@ -97,7 +97,8 @@ export default function PrescriptionCreate() {
await createDialysisPrescription(payload); await createDialysisPrescription(payload);
Taro.showToast({ title: '创建成功', icon: 'success' }); Taro.showToast({ title: '创建成功', icon: 'success' });
safeSetTimeout(() => Taro.navigateBack(), 1000); safeSetTimeout(() => Taro.navigateBack(), 1000);
} catch { } catch (err) {
console.warn('[doctor-prescription] 创建处方失败:', err);
Taro.showToast({ title: '创建失败', icon: 'none' }); Taro.showToast({ title: '创建失败', icon: 'none' });
} finally { } finally {
setSubmitting(false); setSubmitting(false);

View File

@@ -28,7 +28,8 @@ export default function PrescriptionDetail() {
try { try {
const data = await getDialysisPrescription(id); const data = await getDialysisPrescription(id);
setRx(data); setRx(data);
} catch { } catch (err) {
console.warn('[doctor-prescription] 加载失败:', err);
Taro.showToast({ title: '加载失败', icon: 'none' }); Taro.showToast({ title: '加载失败', icon: 'none' });
} finally { } finally {
setLoading(false); setLoading(false);
@@ -49,7 +50,8 @@ export default function PrescriptionDetail() {
const updated = await updateDialysisPrescription(id, { status: 'inactive' }, rx.version); const updated = await updateDialysisPrescription(id, { status: 'inactive' }, rx.version);
setRx(updated); setRx(updated);
Taro.showToast({ title: '已停用', icon: 'success' }); Taro.showToast({ title: '已停用', icon: 'success' });
} catch { } catch (err) {
console.warn('[doctor-prescription] 操作失败:', err);
Taro.showToast({ title: '操作失败', icon: 'none' }); Taro.showToast({ title: '操作失败', icon: 'none' });
} finally { } finally {
setSubmitting(false); setSubmitting(false);
@@ -68,7 +70,8 @@ export default function PrescriptionDetail() {
await deleteDialysisPrescription(id, rx.version); await deleteDialysisPrescription(id, rx.version);
Taro.showToast({ title: '已删除', icon: 'success' }); Taro.showToast({ title: '已删除', icon: 'success' });
safeSetTimeout(() => Taro.navigateBack(), 1000); safeSetTimeout(() => Taro.navigateBack(), 1000);
} catch { } catch (err) {
console.warn('[doctor-prescription] 删除失败:', err);
Taro.showToast({ title: '删除失败', icon: 'none' }); Taro.showToast({ title: '删除失败', icon: 'none' });
setSubmitting(false); setSubmitting(false);
} }

View File

@@ -55,7 +55,8 @@ export default function PrescriptionList() {
setPrescriptions(res.data || []); setPrescriptions(res.data || []);
setTotal(res.total || 0); setTotal(res.total || 0);
setPage(p); setPage(p);
} catch { } catch (err) {
console.warn('[doctor-prescription] 加载数据失败:', err);
setError(true); setError(true);
Taro.showToast({ title: '加载失败', icon: 'none' }); Taro.showToast({ title: '加载失败', icon: 'none' });
} finally { } finally {
@@ -85,7 +86,8 @@ export default function PrescriptionList() {
} else { } else {
Taro.showToast({ title: '未找到患者', icon: 'none' }); Taro.showToast({ title: '未找到患者', icon: 'none' });
} }
} catch { } catch (err) {
console.warn('[doctor-prescription] 搜索失败:', err);
Taro.showToast({ title: '搜索失败', icon: 'none' }); Taro.showToast({ title: '搜索失败', icon: 'none' });
} finally { } finally {
setLoading(false); setLoading(false);

View File

@@ -26,7 +26,8 @@ export default function ReportDetail() {
const r = await getLabReport(patientId, reportId); const r = await getLabReport(patientId, reportId);
setReport(r); setReport(r);
setDoctorNotes(r.doctor_notes || ''); setDoctorNotes(r.doctor_notes || '');
} catch { } catch (err) {
console.warn('[doctor-report] 加载失败:', err);
Taro.showToast({ title: '加载失败', icon: 'none' }); Taro.showToast({ title: '加载失败', icon: 'none' });
} finally { } finally {
setLoading(false); setLoading(false);
@@ -45,7 +46,8 @@ export default function ReportDetail() {
}); });
setReport(updated); setReport(updated);
Taro.showToast({ title: '审核完成', icon: 'success' }); Taro.showToast({ title: '审核完成', icon: 'success' });
} catch { } catch (err) {
console.warn('[doctor-report] 审核失败:', err);
Taro.showToast({ title: '审核失败', icon: 'none' }); Taro.showToast({ title: '审核失败', icon: 'none' });
} finally { } finally {
setSubmitting(false); setSubmitting(false);

View File

@@ -35,7 +35,8 @@ export default function ReportList() {
const res = await listLabReports(currentPatientId, { page: 1, page_size: 50 }); const res = await listLabReports(currentPatientId, { page: 1, page_size: 50 });
setReports(res.data || []); setReports(res.data || []);
setTotal(res.total || 0); setTotal(res.total || 0);
} catch { } catch (err) {
console.warn('[doctor-report] 加载数据失败:', err);
setError(true); setError(true);
Taro.showToast({ title: '加载失败', icon: 'none' }); Taro.showToast({ title: '加载失败', icon: 'none' });
} finally { } finally {
@@ -64,7 +65,8 @@ export default function ReportList() {
} else { } else {
Taro.showToast({ title: '未找到患者', icon: 'none' }); Taro.showToast({ title: '未找到患者', icon: 'none' });
} }
} catch { } catch (err) {
console.warn('[doctor-report] 搜索失败:', err);
Taro.showToast({ title: '搜索失败', icon: 'none' }); Taro.showToast({ title: '搜索失败', icon: 'none' });
} finally { } finally {
setLoading(false); setLoading(false);

View File

@@ -75,7 +75,8 @@ export default function ActionInboxPage() {
} else { } else {
setItems((prev) => [...prev, ...list]); setItems((prev) => [...prev, ...list]);
} }
} catch { } catch (err) {
console.warn('[action-inbox] 加载待办列表失败:', err);
setError(true); setError(true);
Taro.showToast({ title: '加载失败', icon: 'none' }); Taro.showToast({ title: '加载失败', icon: 'none' });
} finally { } finally {
@@ -103,7 +104,8 @@ export default function ActionInboxPage() {
const data = await getActionThread(item.source_ref); const data = await getActionThread(item.source_ref);
setThreadData(data); setThreadData(data);
setShowDetail(true); setShowDetail(true);
} catch { } catch (err) {
console.warn('[action-inbox] 加载待办详情失败:', err);
Taro.showToast({ title: '加载失败', icon: 'none' }); Taro.showToast({ title: '加载失败', icon: 'none' });
} }
}; };
@@ -119,7 +121,8 @@ export default function ActionInboxPage() {
Taro.showToast({ title: '操作成功', icon: 'success' }); Taro.showToast({ title: '操作成功', icon: 'success' });
setShowDetail(false); setShowDetail(false);
fetchItems(1, FILTER_MAP[activeFilter], true); fetchItems(1, FILTER_MAP[activeFilter], true);
} catch { } catch (err) {
console.warn('[action-inbox] 执行操作失败:', err);
Taro.showToast({ title: '操作失败', icon: 'none' }); Taro.showToast({ title: '操作失败', icon: 'none' });
} }
}; };

View File

@@ -67,7 +67,8 @@ export default function ConsultationDetail() {
messagesRef.current = msgs; messagesRef.current = msgs;
scrollViewRef.current = `msg-${msgs.length}`; scrollViewRef.current = `msg-${msgs.length}`;
dataLoadedRef.current = true; dataLoadedRef.current = true;
} catch { } catch (err) {
console.warn('[doctor-consult] 加载失败:', err);
Taro.showToast({ title: '加载失败', icon: 'none' }); Taro.showToast({ title: '加载失败', icon: 'none' });
} finally { } finally {
setLoading(false); setLoading(false);
@@ -93,7 +94,8 @@ export default function ConsultationDetail() {
scrollViewRef.current = `msg-${next.length}`; scrollViewRef.current = `msg-${next.length}`;
return next; return next;
}); });
} catch { } catch (err) {
console.warn('[doctor-consult] 发送失败:', err);
Taro.showToast({ title: '发送失败', icon: 'none' }); Taro.showToast({ title: '发送失败', icon: 'none' });
setInputText(text); setInputText(text);
} finally { } finally {
@@ -111,7 +113,8 @@ export default function ConsultationDetail() {
await closeSession(sessionId, session?.version ?? 0); await closeSession(sessionId, session?.version ?? 0);
Taro.showToast({ title: '已关闭', icon: 'success' }); Taro.showToast({ title: '已关闭', icon: 'success' });
loadData(); loadData();
} catch { } catch (err) {
console.warn('[doctor-consult] 操作失败:', err);
Taro.showToast({ title: '操作失败', icon: 'none' }); Taro.showToast({ title: '操作失败', icon: 'none' });
} }
} }

View File

@@ -42,7 +42,8 @@ export default function ConsultationList() {
status: activeTab || undefined, status: activeTab || undefined,
}); });
setSessions(res.data || []); setSessions(res.data || []);
} catch { } catch (err) {
console.warn('[doctor-consult] 加载数据失败:', err);
setError(true); setError(true);
Taro.showToast({ title: '加载失败', icon: 'none' }); Taro.showToast({ title: '加载失败', icon: 'none' });
} finally { } finally {

View File

@@ -46,7 +46,8 @@ export default function FollowUpDetail() {
]); ]);
setTask(t); setTask(t);
setRecords(r.data || []); setRecords(r.data || []);
} catch { } catch (err) {
console.warn('[doctor-followup] 加载失败:', err);
Taro.showToast({ title: '加载失败', icon: 'none' }); Taro.showToast({ title: '加载失败', icon: 'none' });
} finally { } finally {
setLoading(false); setLoading(false);
@@ -74,7 +75,8 @@ export default function FollowUpDetail() {
setMedicalAdvice(''); setMedicalAdvice('');
setNextDate(''); setNextDate('');
loadData(); loadData();
} catch { } catch (err) {
console.warn('[doctor-followup] 提交失败:', err);
Taro.showToast({ title: '提交失败', icon: 'none' }); Taro.showToast({ title: '提交失败', icon: 'none' });
} finally { } finally {
setSubmitting(false); setSubmitting(false);
@@ -87,7 +89,8 @@ export default function FollowUpDetail() {
await updateFollowUpTask(taskId, { status: 'in_progress' }, task.version); await updateFollowUpTask(taskId, { status: 'in_progress' }, task.version);
Taro.showToast({ title: '已开始', icon: 'success' }); Taro.showToast({ title: '已开始', icon: 'success' });
loadData(); loadData();
} catch { } catch (err) {
console.warn('[doctor-followup] 操作失败:', err);
Taro.showToast({ title: '操作失败', icon: 'none' }); Taro.showToast({ title: '操作失败', icon: 'none' });
} }
}; };

View File

@@ -48,7 +48,8 @@ export default function FollowUpList() {
}); });
setTasks(res.data || []); setTasks(res.data || []);
setTotal(res.total || 0); setTotal(res.total || 0);
} catch { } catch (err) {
console.warn('[doctor-followup] 加载随访列表失败:', err);
setError(true); setError(true);
Taro.showToast({ title: '加载失败', icon: 'none' }); Taro.showToast({ title: '加载失败', icon: 'none' });
} finally { } finally {

View File

@@ -57,8 +57,8 @@ export default function DoctorHome() {
try { try {
const data = await getDashboard(); const data = await getDashboard();
setDashboard(data); setDashboard(data);
} catch { } catch (err) {
// 静默失败 console.warn('[doctor] 加载工作台数据失败:', err);
} finally { } finally {
setLoading(false); setLoading(false);
} }

View File

@@ -28,7 +28,8 @@ export default function PatientDetail() {
]); ]);
setPatient(p); setPatient(p);
setSummary(s); setSummary(s);
} catch { } catch (err) {
console.warn('[doctor-patient] 加载患者详情失败:', err);
Taro.showToast({ title: '加载失败', icon: 'none' }); Taro.showToast({ title: '加载失败', icon: 'none' });
} finally { } finally {
setLoading(false); setLoading(false);

View File

@@ -38,7 +38,8 @@ export default function PatientList() {
setPatients(prev => isRefresh ? list : [...prev, ...list]); setPatients(prev => isRefresh ? list : [...prev, ...list]);
setTotal(res.total || 0); setTotal(res.total || 0);
setPage(pageNum); setPage(pageNum);
} catch { } catch (err) {
console.warn('[doctor-patients] 加载患者列表失败:', err);
Taro.showToast({ title: '加载失败', icon: 'none' }); Taro.showToast({ title: '加载失败', icon: 'none' });
} finally { } finally {
setLoading(false); setLoading(false);

View File

@@ -57,7 +57,8 @@ export default function PatientAlerts() {
} }
setTotal(res.total); setTotal(res.total);
setPage(pageNum); setPage(pageNum);
} catch { } catch (err) {
console.warn('[alert] 加载数据失败:', err);
setError(true); setError(true);
Taro.showToast({ title: '加载失败', icon: 'none' }); Taro.showToast({ title: '加载失败', icon: 'none' });
} finally { } finally {

View File

@@ -45,7 +45,8 @@ export default function Trend() {
try { try {
const data = await getTrend(indicator, range); const data = await getTrend(indicator, range);
setPoints(data); setPoints(data);
} catch { } catch (err) {
console.warn('[trend] 加载数据失败:', err);
setError(true); setError(true);
setPoints([]); setPoints([]);
} finally { } finally {

View File

@@ -46,7 +46,8 @@ export default function PointsDetail() {
} }
setTotal(res.total); setTotal(res.total);
setPage(pageNum); setPage(pageNum);
} catch { } catch (err) {
console.warn('[mall] 加载失败:', err);
Taro.showToast({ title: '加载失败', icon: 'none' }); Taro.showToast({ title: '加载失败', icon: 'none' });
} finally { } finally {
setLoading(false); setLoading(false);

View File

@@ -53,7 +53,8 @@ export default function ExchangeConfirm() {
let found: PointsProduct | null = null; let found: PointsProduct | null = null;
try { try {
found = await getProduct(productId); found = await getProduct(productId);
} catch { } catch (err) {
console.warn('[exchange] 单商品接口失败,降级列表查找:', err);
const productRes = await listProducts({ page: 1, page_size: 100 }); const productRes = await listProducts({ page: 1, page_size: 100 });
found = productRes.data.find((p) => p.id === productId) || null; found = productRes.data.find((p) => p.id === productId) || null;
} }
@@ -64,7 +65,8 @@ export default function ExchangeConfirm() {
} }
setProduct(found); setProduct(found);
await refreshPoints(); await refreshPoints();
} catch { } catch (err) {
console.warn('[exchange] 加载兑换页面失败:', err);
Taro.showToast({ title: '加载失败', icon: 'none' }); Taro.showToast({ title: '加载失败', icon: 'none' });
safeSetTimeout(() => Taro.navigateBack(), 1500); safeSetTimeout(() => Taro.navigateBack(), 1500);
} finally { } finally {

View File

@@ -57,7 +57,8 @@ export default function MallOrders() {
} }
setTotal(res.total); setTotal(res.total);
setPage(pageNum); setPage(pageNum);
} catch { } catch (err) {
console.warn('[orders] 加载订单列表失败:', err);
setError(true); setError(true);
Taro.showToast({ title: '加载失败', icon: 'none' }); Taro.showToast({ title: '加载失败', icon: 'none' });
} finally { } finally {

View File

@@ -33,14 +33,15 @@ export default function ProductDetail() {
try { try {
const data = await getProduct(productId); const data = await getProduct(productId);
setProduct(data); setProduct(data);
} catch { } catch (err) {
// 降级:从列表接口查找 console.warn('[product] 单商品接口失败,降级列表查找:', err);
try { try {
const { listProducts } = await import('../../../services/points'); const { listProducts } = await import('../../../services/points');
const res = await listProducts({ page: 1, page_size: 100 }); const res = await listProducts({ page: 1, page_size: 100 });
const found = res.data.find((p) => p.id === productId); const found = res.data.find((p) => p.id === productId);
if (found) setProduct(found); if (found) setProduct(found);
} catch { } catch (fallbackErr) {
console.warn('[product] 降级列表查找也失败:', fallbackErr);
Taro.showToast({ title: '加载失败', icon: 'none' }); Taro.showToast({ title: '加载失败', icon: 'none' });
} }
} finally { } finally {

View File

@@ -49,7 +49,8 @@ export default function ConsentList() {
setConsents(append ? (prev) => [...prev, ...list] : list); setConsents(append ? (prev) => [...prev, ...list] : list);
setTotal(res.total); setTotal(res.total);
setPage(p); setPage(p);
} catch { } catch (err) {
console.warn('[consent] 加载失败:', err);
Taro.showToast({ title: '加载失败', icon: 'none' }); Taro.showToast({ title: '加载失败', icon: 'none' });
} finally { } finally {
setLoading(false); setLoading(false);
@@ -75,7 +76,8 @@ export default function ConsentList() {
const updated = await revokeConsent(consent.id, consent.version); const updated = await revokeConsent(consent.id, consent.version);
setConsents((prev) => prev.map((c) => c.id === updated.id ? updated : c)); setConsents((prev) => prev.map((c) => c.id === updated.id ? updated : c));
Taro.showToast({ title: '已撤回', icon: 'success' }); Taro.showToast({ title: '已撤回', icon: 'success' });
} catch { } catch (err) {
console.warn('[consent] 撤回失败:', err);
Taro.showToast({ title: '撤回失败', icon: 'none' }); Taro.showToast({ title: '撤回失败', icon: 'none' });
} finally { } finally {
setRevoking(null); setRevoking(null);

View File

@@ -45,7 +45,8 @@ export default function Diagnoses() {
setRecords(append ? (prev) => [...prev, ...list] : list); setRecords(append ? (prev) => [...prev, ...list] : list);
setTotal(res.total); setTotal(res.total);
setPage(p); setPage(p);
} catch { } catch (err) {
console.warn('[diagnosis] 加载失败:', err);
Taro.showToast({ title: '加载失败', icon: 'none' }); Taro.showToast({ title: '加载失败', icon: 'none' });
} finally { } finally {
setLoading(false); setLoading(false);

View File

@@ -29,7 +29,8 @@ export default function DialysisPrescriptionDetail() {
try { try {
const data = await getDialysisPrescription(id); const data = await getDialysisPrescription(id);
setRx(data); setRx(data);
} catch { } catch (err) {
console.warn('[prescription] 加载失败:', err);
Taro.showToast({ title: '加载失败', icon: 'none' }); Taro.showToast({ title: '加载失败', icon: 'none' });
} finally { } finally {
setLoading(false); setLoading(false);

View File

@@ -41,7 +41,8 @@ export default function DialysisPrescriptionList() {
setPrescriptions(append ? (prev) => [...prev, ...list] : list); setPrescriptions(append ? (prev) => [...prev, ...list] : list);
setTotal(res.total); setTotal(res.total);
setPage(p); setPage(p);
} catch { } catch (err) {
console.warn('[prescription] 加载失败:', err);
Taro.showToast({ title: '加载失败', icon: 'none' }); Taro.showToast({ title: '加载失败', icon: 'none' });
} finally { } finally {
setLoading(false); setLoading(false);

View File

@@ -35,7 +35,8 @@ export default function DialysisRecordDetail() {
try { try {
const data = await getDialysisRecord(id); const data = await getDialysisRecord(id);
setRecord(data); setRecord(data);
} catch { } catch (err) {
console.warn('[dialysis] 加载失败:', err);
Taro.showToast({ title: '加载失败', icon: 'none' }); Taro.showToast({ title: '加载失败', icon: 'none' });
} finally { } finally {
setLoading(false); setLoading(false);

View File

@@ -47,7 +47,8 @@ export default function DialysisRecordList() {
setRecords(append ? (prev) => [...prev, ...list] : list); setRecords(append ? (prev) => [...prev, ...list] : list);
setTotal(res.total); setTotal(res.total);
setPage(p); setPage(p);
} catch { } catch (err) {
console.warn('[dialysis] 加载失败:', err);
Taro.showToast({ title: '加载失败', icon: 'none' }); Taro.showToast({ title: '加载失败', icon: 'none' });
} finally { } finally {
setLoading(false); setLoading(false);

View File

@@ -27,7 +27,8 @@ export default function EventsPage() {
try { try {
const res = await pointsApi.listOfflineEvents({ page: 1, page_size: 50, status: 'published' }); const res = await pointsApi.listOfflineEvents({ page: 1, page_size: 50, status: 'published' });
setEvents(res.data || []); setEvents(res.data || []);
} catch { } catch (err) {
console.warn('[event] 加载失败:', err);
Taro.showToast({ title: '加载失败', icon: 'none' }); Taro.showToast({ title: '加载失败', icon: 'none' });
} finally { } finally {
setLoading(false); setLoading(false);

View File

@@ -58,7 +58,8 @@ export default function FamilyAdd() {
Taro.showToast({ title: '添加成功', icon: 'success' }); Taro.showToast({ title: '添加成功', icon: 'success' });
} }
safeSetTimeout(() => Taro.navigateBack(), 1000); safeSetTimeout(() => Taro.navigateBack(), 1000);
} catch { } catch (err) {
console.warn('[family] 操作失败:', err);
Taro.hideLoading(); Taro.hideLoading();
Taro.showToast({ title: editId ? '修改失败' : '添加失败', icon: 'none' }); Taro.showToast({ title: editId ? '修改失败' : '添加失败', icon: 'none' });
} finally { } finally {

View File

@@ -34,7 +34,8 @@ export default function FamilyList() {
try { try {
const res = await listPatients(); const res = await listPatients();
setPatients(res.data || []); setPatients(res.data || []);
} catch { } catch (err) {
console.warn('[family] 加载失败:', err);
Taro.showToast({ title: '加载失败', icon: 'none' }); Taro.showToast({ title: '加载失败', icon: 'none' });
} finally { } finally {
setLoading(false); setLoading(false);

View File

@@ -58,7 +58,8 @@ export default function FollowUpDetail() {
try { await (Taro.requestSubscribeMessage as any)({ tmplIds: [tmplId] }); } catch { /* 用户拒绝 */ } try { await (Taro.requestSubscribeMessage as any)({ tmplIds: [tmplId] }); } catch { /* 用户拒绝 */ }
} }
setContent(''); setContent('');
} catch { } catch (err) {
console.warn('[followup] 提交失败:', err);
Taro.showToast({ title: '提交失败', icon: 'none' }); Taro.showToast({ title: '提交失败', icon: 'none' });
} finally { } finally {
setSubmitting(false); setSubmitting(false);

View File

@@ -30,7 +30,8 @@ export default function MyFollowUps() {
try { try {
const res = await listTasks(status); const res = await listTasks(status);
setTasks(res.data || []); setTasks(res.data || []);
} catch { } catch (err) {
console.warn('[followup] 加载数据失败:', err);
setError(true); setError(true);
Taro.showToast({ title: '加载失败', icon: 'none' }); Taro.showToast({ title: '加载失败', icon: 'none' });
} finally { } finally {

View File

@@ -39,7 +39,8 @@ export default function HealthRecords() {
setRecords(append ? (prev) => [...prev, ...list] : list); setRecords(append ? (prev) => [...prev, ...list] : list);
setTotal(res.total); setTotal(res.total);
setPage(p); setPage(p);
} catch { } catch (err) {
console.warn('[health-records] 加载失败:', err);
Taro.showToast({ title: '加载失败', icon: 'none' }); Taro.showToast({ title: '加载失败', icon: 'none' });
} finally { } finally {
setLoading(false); setLoading(false);

View File

@@ -28,7 +28,8 @@ export default function MedicationReminder() {
try { try {
const res = await listReminders(); const res = await listReminders();
setReminders(res.data ?? []); setReminders(res.data ?? []);
} catch { } catch (err) {
console.warn('[medication] 加载失败:', err);
Taro.showToast({ title: '加载失败', icon: 'none' }); Taro.showToast({ title: '加载失败', icon: 'none' });
} finally { } finally {
setLoading(false); setLoading(false);
@@ -44,7 +45,8 @@ export default function MedicationReminder() {
version: r.version, version: r.version,
}); });
fetchReminders(); fetchReminders();
} catch { } catch (err) {
console.warn('[medication] 操作失败:', err);
Taro.showToast({ title: '操作失败', icon: 'none' }); Taro.showToast({ title: '操作失败', icon: 'none' });
} }
}; };
@@ -59,7 +61,8 @@ export default function MedicationReminder() {
await deleteReminder(r.id, r.version); await deleteReminder(r.id, r.version);
Taro.showToast({ title: '已删除', icon: 'success' }); Taro.showToast({ title: '已删除', icon: 'success' });
fetchReminders(); fetchReminders();
} catch { } catch (err) {
console.warn('[medication] 删除失败:', err);
Taro.showToast({ title: '删除失败', icon: 'none' }); Taro.showToast({ title: '删除失败', icon: 'none' });
} }
} }
@@ -90,7 +93,8 @@ export default function MedicationReminder() {
setShowForm(false); setShowForm(false);
Taro.showToast({ title: '添加成功', icon: 'success' }); Taro.showToast({ title: '添加成功', icon: 'success' });
fetchReminders(); fetchReminders();
} catch { } catch (err) {
console.warn('[medication] 添加失败:', err);
Taro.showToast({ title: '添加失败', icon: 'none' }); Taro.showToast({ title: '添加失败', icon: 'none' });
} }
}; };

View File

@@ -48,7 +48,8 @@ export default function Notifications() {
setItems((prev) => (isRefresh ? list : [...prev, ...list])); setItems((prev) => (isRefresh ? list : [...prev, ...list]));
setTotal(res.total || 0); setTotal(res.total || 0);
setPage(pageNum); setPage(pageNum);
} catch { } catch (err) {
console.warn('[notification] 加载数据失败:', err);
setError('加载失败'); setError('加载失败');
if (isRefresh) setItems([]); if (isRefresh) setItems([]);
} finally { } finally {

View File

@@ -35,7 +35,8 @@ export default function ReportDetail() {
try { try {
const data = await getReportDetail(patientId, id); const data = await getReportDetail(patientId, id);
setReport(data); setReport(data);
} catch { } catch (err) {
console.warn('[report] 加载失败:', err);
Taro.showToast({ title: '加载失败', icon: 'none' }); Taro.showToast({ title: '加载失败', icon: 'none' });
} finally { } finally {
setLoading(false); setLoading(false);

View File

@@ -34,7 +34,8 @@ export default function MyReports() {
setReports(append ? (prev) => [...prev, ...list] : list); setReports(append ? (prev) => [...prev, ...list] : list);
setTotal(res.total); setTotal(res.total);
setPage(p); setPage(p);
} catch { } catch (err) {
console.warn('[reports] 加载报告列表失败:', err);
Taro.showToast({ title: '加载失败', icon: 'none' }); Taro.showToast({ title: '加载失败', icon: 'none' });
} finally { } finally {
setLoading(false); setLoading(false);

View File

@@ -79,7 +79,8 @@ export function getLocalHistory(): AiChatMessage[] {
try { try {
const raw = wx.getStorageSync('ai_chat_history'); const raw = wx.getStorageSync('ai_chat_history');
return raw ? JSON.parse(raw) : []; return raw ? JSON.parse(raw) : [];
} catch { } catch (err) {
console.warn('[ai-chat] 读取本地聊天历史失败:', err);
return []; return [];
} }
} }
@@ -88,5 +89,5 @@ export function getLocalHistory(): AiChatMessage[] {
export function saveLocalHistory(messages: AiChatMessage[]): void { export function saveLocalHistory(messages: AiChatMessage[]): void {
try { try {
wx.setStorageSync('ai_chat_history', JSON.stringify(messages.slice(-100))); wx.setStorageSync('ai_chat_history', JSON.stringify(messages.slice(-100)));
} catch { /* ignore */ } } catch (err) { console.warn('[ai-chat] 保存本地聊天历史失败:', err); }
} }

View File

@@ -236,8 +236,8 @@ export class BLEManager {
serviceId: svc.uuid, serviceId: svc.uuid,
characteristicId: charUUID, characteristicId: charUUID,
}); });
} catch { } catch (err) {
// 某些特征值可能不支持读取 console.warn('[ble] 读取特征值失败:', err);
} }
} }
@@ -347,8 +347,8 @@ export class BLEManager {
try { try {
const uploaded = await uploadFn(batch); const uploaded = await uploadFn(batch);
return uploaded; return uploaded;
} catch { } catch (err) {
// 失败时放回 console.warn('[ble] 上传待处理读数失败:', err);
this.dataBuffer.push(batch); this.dataBuffer.push(batch);
return 0; return 0;
} }

View File

@@ -83,7 +83,8 @@ export class DataBuffer {
let raw: string; let raw: string;
try { try {
raw = Taro.getStorageSync(key) as string; raw = Taro.getStorageSync(key) as string;
} catch { } catch (err) {
console.warn('[ble-buffer] 读取 Storage 失败:', err);
break; break;
} }
if (!raw) break; if (!raw) break;
@@ -96,7 +97,8 @@ export class DataBuffer {
} }
total += parsed.length; total += parsed.length;
} }
} catch { } catch (err) {
console.warn('[ble-buffer] 解析 Storage 数据失败:', err);
break; break;
} }
idx++; idx++;
@@ -145,8 +147,8 @@ export class DataBuffer {
const key = `${this.config.storageKeyPrefix}_${this.currentBucketIndex}`; const key = `${this.config.storageKeyPrefix}_${this.currentBucketIndex}`;
try { try {
Taro.setStorageSync(key, JSON.stringify(this.buckets[this.currentBucketIndex])); Taro.setStorageSync(key, JSON.stringify(this.buckets[this.currentBucketIndex]));
} catch { } catch (err) {
// Storage 写入失败不影响主流程 console.warn('[ble-buffer] 持久化当前桶失败:', err);
} }
} }
@@ -157,7 +159,8 @@ export class DataBuffer {
let raw: string; let raw: string;
try { try {
raw = Taro.getStorageSync(key) as string; raw = Taro.getStorageSync(key) as string;
} catch { } catch (err) {
console.warn('[ble-buffer] 清理 Storage 读取失败:', err);
break; break;
} }
if (!raw) break; if (!raw) break;

View File

@@ -85,7 +85,8 @@ export class DataSyncScheduler {
const raw = Taro.getStorageSync(this.config.storageKey) as string; const raw = Taro.getStorageSync(this.config.storageKey) as string;
if (!raw) return null; if (!raw) return null;
return JSON.parse(raw) as SyncRecord; return JSON.parse(raw) as SyncRecord;
} catch { } catch (err) {
console.warn('[ble-sync] 数据加载失败:', err);
return null; return null;
} }
} }
@@ -93,7 +94,8 @@ export class DataSyncScheduler {
private saveRecord(record: SyncRecord): void { private saveRecord(record: SyncRecord): void {
try { try {
Taro.setStorageSync(this.config.storageKey, JSON.stringify(record)); Taro.setStorageSync(this.config.storageKey, JSON.stringify(record));
} catch { } catch (err) {
console.warn('[ble-sync] Storage 操作失败:', err);
// Storage 写入失败不影响主流程 // Storage 写入失败不影响主流程
} }
} }

View File

@@ -159,7 +159,8 @@ export async function getHealthThresholds(): Promise<HealthThreshold[]> {
const data = await api.get<HealthThreshold[]>('/health/critical-value-thresholds/public'); const data = await api.get<HealthThreshold[]>('/health/critical-value-thresholds/public');
Taro.setStorageSync(THRESHOLD_CACHE_KEY, { data, ts: Date.now() }); Taro.setStorageSync(THRESHOLD_CACHE_KEY, { data, ts: Date.now() });
return data; return data;
} catch { } catch (err) {
console.warn('[health] 数据加载失败:', err);
return []; return [];
} }
} }

View File

@@ -204,8 +204,8 @@ async function doRefresh(): Promise<boolean> {
invalidateHeadersCache(); invalidateHeadersCache();
return true; return true;
} }
} catch { } catch (err) {
// token 刷新失败 console.warn('[request] Token 刷新失败:', err);
} }
isLoggingOut = true; isLoggingOut = true;
secureRemove('access_token'); secureRemove('access_token');

View File

@@ -154,7 +154,8 @@ export const useAuthStore = create<AuthState>((set, get) => ({
secureSet('wechat_openid', resp.openid); secureSet('wechat_openid', resp.openid);
set({ loading: false }); set({ loading: false });
return false; return false;
} catch { } catch (err) {
console.warn('[auth] 微信登录失败:', err);
set({ loading: false }); set({ loading: false });
return false; return false;
} }
@@ -183,7 +184,8 @@ export const useAuthStore = create<AuthState>((set, get) => ({
// 登录成功后自动加载患者档案(如果有的话) // 登录成功后自动加载患者档案(如果有的话)
get().loadPatients(); get().loadPatients();
return true; return true;
} catch { } catch (err) {
console.warn('[auth] 账号密码登录失败:', err);
set({ loading: false }); set({ loading: false });
return false; return false;
} }
@@ -239,8 +241,8 @@ export const useAuthStore = create<AuthState>((set, get) => ({
if (patients.length > 0 && !get().currentPatient) { if (patients.length > 0 && !get().currentPatient) {
get().setCurrentPatient(patients[0]); get().setCurrentPatient(patients[0]);
} }
} catch { } catch (err) {
// 患者列表加载失败不阻塞流程 console.warn('[auth] 患者列表加载失败:', err);
} }
}, },

View File

@@ -43,7 +43,8 @@ export const useHealthStore = create<HealthState>((set, get) => ({
|| undefined; || undefined;
const data = await healthApi.getTodaySummary(patientId); const data = await healthApi.getTodaySummary(patientId);
set({ todaySummary: data, todaySummaryFetchedAt: Date.now(), loading: false, _refreshingToday: false }); set({ todaySummary: data, todaySummaryFetchedAt: Date.now(), loading: false, _refreshingToday: false });
} catch { } catch (err) {
console.warn('[health] 刷新今日摘要失败:', err);
set({ loading: false, _refreshingToday: false }); set({ loading: false, _refreshingToday: false });
} }
}, },
@@ -69,7 +70,8 @@ export const useHealthStore = create<HealthState>((set, get) => ({
return { trendData: updated }; return { trendData: updated };
}); });
return points; return points;
} catch { } catch (err) {
console.warn('[health] 获取趋势数据失败:', err);
return []; return [];
} }
}, },

View File

@@ -28,7 +28,8 @@ export const usePointsStore = create<PointsState>((set, get) => ({
pointsApi.getCheckinStatus(), pointsApi.getCheckinStatus(),
]); ]);
set({ account, checkinStatus, loading: false, lastFetched: Date.now() }); set({ account, checkinStatus, loading: false, lastFetched: Date.now() });
} catch { } catch (err) {
console.warn('[points] 刷新积分数据失败:', err);
set({ loading: false }); set({ loading: false });
} }
}, },
@@ -42,7 +43,8 @@ export const usePointsStore = create<PointsState>((set, get) => ({
const account = await pointsApi.getAccount(); const account = await pointsApi.getAccount();
set({ account }); set({ account });
return true; return true;
} catch { } catch (err) {
console.warn('[points] 签到失败:', err);
return false; return false;
} }
}, },