import { useEffect } from 'react'; import { useAnalysisStore } from '@/stores/analysisStore'; import { ErrorBanner } from '@/components/ErrorBanner'; import { Lightbulb, AlertTriangle, CheckCircle, Info, XCircle, TrendingUp, TrendingDown, Clock, } from 'lucide-react'; const TYPE_CONFIG = { warning: { icon: AlertTriangle, bg: 'bg-warning-light', border: 'border-warning', iconColor: 'text-warning', badge: 'bg-warning text-white', }, danger: { icon: XCircle, bg: 'bg-danger-light', border: 'border-danger', iconColor: 'text-danger', badge: 'bg-danger text-white', }, success: { icon: CheckCircle, bg: 'bg-success-light', border: 'border-success', iconColor: 'text-success', badge: 'bg-success text-white', }, info: { icon: Info, bg: 'bg-primary-muted', border: 'border-primary', iconColor: 'text-primary', badge: 'bg-primary text-white', }, }; export function Insights() { const { insights, isLoading, error, clearError, fetchInsights } = useAnalysisStore(); useEffect(() => { fetchInsights(); }, []); const stats = insights ? [ { label: '总洞察数', value: insights.total_insights || 0, icon: Lightbulb, color: 'text-primary', bg: 'bg-primary-muted', }, { label: '预警', value: (insights.warning_count || 0) + ((insights as any).danger_count || 0), icon: AlertTriangle, color: 'text-warning', bg: 'bg-warning-light', }, { label: '正常', value: insights.success_count || 0, icon: CheckCircle, color: 'text-success', bg: 'bg-success-light', }, { label: '信息', value: insights.info_count || 0, icon: Info, color: 'text-primary', bg: 'bg-primary-muted', }, ] : []; return (
基于数据分析自动生成的风险洞察与建议
{card.description}
{card.metric && card.metricValue && (暂无洞察数据