Frontend features:
- 报表中心 (ReportsCenter): list/detail views, diagnosis breakdown chart, CSV export
- 多级行政下钻 (AdminBreadcrumb): 湖北省→武汉市→区→街道 hierarchical drill-down
- 按病种筛选 (DiseaseFilter): multi-select diagnosis filter on monitoring + reports pages
Backend:
- Add /forecast/{days} endpoint, diagnosis filter params on cases endpoints
- Add /streets aggregation endpoint, enrich reports with real case data
- Extract shared case_loader module
Bug fixes (14):
- Fix missing /risk/forecast route (404), historyApi pointing to non-existent router
- Fix min_risk filter silently ignored in insights/hotspots
- Fix type mismatches: CaseTrendResponse, CaseStatsResponse shapes
- Fix silent .catch(() => {}) swallowing errors, fetchAlerts not clearing stale state
- Fix lru_cache caching exceptions, generateReport used cachedGet for write op
- Fix missing useEffect deps in Insights, DistrictComparison, ReportsCenter
Performance (9):
- Zustand selectors across 9 components (eliminate re-render cascades)
- Fix districtCases.sort() mutating store state, inline IIFE → memo'd component
- CaseLocationMap: React.memo, race protection, correct deps
- AlertCard: stable callbacks, TimelinePlayer: useMemo, TopNav: clock isolation
- SideNav: modules array to module scope, DiseaseFilter: memoized filter
39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
import { create } from 'zustand';
|
|
import { caseApi } from '@/services/api';
|
|
|
|
interface DiseaseState {
|
|
availableDiagnoses: string[];
|
|
selectedDiagnoses: string[];
|
|
isLoading: boolean;
|
|
error: string | null;
|
|
|
|
fetchDiagnoses: () => Promise<void>;
|
|
setSelectedDiagnoses: (diagnoses: string[]) => void;
|
|
clearDiagnoses: () => void;
|
|
clearError: () => void;
|
|
}
|
|
|
|
export const useDiseaseStore = create<DiseaseState>((set, get) => ({
|
|
availableDiagnoses: [],
|
|
selectedDiagnoses: [],
|
|
isLoading: false,
|
|
error: null,
|
|
|
|
clearError: () => set({ error: null }),
|
|
|
|
fetchDiagnoses: async () => {
|
|
const { availableDiagnoses } = get();
|
|
if (availableDiagnoses.length > 0) return; // already loaded
|
|
set({ isLoading: true, error: null });
|
|
try {
|
|
const data = await caseApi.getDiagnoses();
|
|
set({ availableDiagnoses: data.diagnoses || [], isLoading: false });
|
|
} catch (e) {
|
|
set({ error: (e as Error).message || '加载诊断列表失败', isLoading: false });
|
|
}
|
|
},
|
|
|
|
setSelectedDiagnoses: (diagnoses) => set({ selectedDiagnoses: diagnoses }),
|
|
clearDiagnoses: () => set({ selectedDiagnoses: [] }),
|
|
}));
|