"use client" import { useState } from "react" import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card" import { Button } from "@/components/ui/button" import { Badge } from "@/components/ui/badge" import { Progress } from "@/components/ui/progress" import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select" import { Brain, TrendingUp, AlertTriangle, Zap, Filter, RefreshCw, Download, ChevronRight, ChevronDown, } from "lucide-react" import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible" export default function AIAnalysisPage() { const [timeRange, setTimeRange] = useState("today") const [expandedSections, setExpandedSections] = useState({ overview: true, trends: true, anomaly: false, predictions: false, }) // AI分析数据 const aiData = { overview: { totalInsights: 156, trendsIdentified: 23, anomaliesDetected: 3, predictionsGenerated: 89, accuracy: 94.2, modelPerformance: 97.8, }, trendAnalysis: [ { trend: "用户活跃度上升趋势", confidence: 95.8, impact: "高", timeframe: "未来7天", description: "基于用户行为模式分析,预测用户活跃度将持续上升", recommendation: "增加内容推送频率,优化用户体验", }, { trend: "移动端使用增长", confidence: 89.2, impact: "中高", timeframe: "未来14天", description: "移动端用户访问量呈现明显增长趋势", recommendation: "优化移动端界面,提升响应速度", }, { trend: "高价值用户转化提升", confidence: 92.5, impact: "高", timeframe: "未来30天", description: "高价值用户转化率预计将显著提升", recommendation: "制定针对性营销策略,加强用户维护", }, ], anomalyDetection: [ { type: "流量异常", severity: "中等", detected: "今天 13:45", description: "检测到异常流量峰值,比平时高出45%", status: "已处理", action: "已启动自动扩容机制", }, { type: "用户行为异常", severity: "低", detected: "今天 11:20", description: "部分用户群体行为模式发生变化", status: "监控中", action: "持续观察用户行为变化", }, { type: "数据质量异常", severity: "高", detected: "今天 09:15", description: "数据源同步出现延迟,影响实时分析", status: "已修复", action: "已重新同步数据,恢复正常", }, ], predictiveModels: [ { model: "用户流失预测模型", accuracy: 94.2, lastTrained: "今天 06:00", predictions: 1245, status: "运行中", description: "预测用户流失风险,准确率达94.2%", }, { model: "价值提升预测模型", accuracy: 91.8, lastTrained: "今天 05:30", predictions: 856, status: "运行中", description: "预测用户价值提升潜力,指导运营策略", }, { model: "内容推荐模型", accuracy: 87.5, lastTrained: "今天 04:45", predictions: 2341, status: "运行中", description: "个性化内容推荐,提升用户参与度", }, ], } const toggleSection = (section: string) => { setExpandedSections((prev) => ({ ...prev, [section]: !prev[section], })) } const getImpactColor = (impact: string) => { switch (impact) { case "高": return "bg-red-100 text-red-800" case "中高": return "bg-orange-100 text-orange-800" case "中": return "bg-yellow-100 text-yellow-800" case "低": return "bg-green-100 text-green-800" default: return "bg-gray-100 text-gray-800" } } const getSeverityColor = (severity: string) => { switch (severity) { case "高": return "bg-red-100 text-red-800" case "中等": return "bg-yellow-100 text-yellow-800" case "低": return "bg-green-100 text-green-800" default: return "bg-gray-100 text-gray-800" } } const getStatusColor = (status: string) => { switch (status) { case "运行中": return "bg-green-100 text-green-800" case "已处理": return "bg-blue-100 text-blue-800" case "监控中": return "bg-yellow-100 text-yellow-800" case "已修复": return "bg-green-100 text-green-800" default: return "bg-gray-100 text-gray-800" } } return (
智能数据洞察与预测分析
{trend.description}
建议: {trend.recommendation}
{anomaly.description}
处理措施: {anomaly.action}
{model.description}