"use client"; import { TrendingUp, Download, Info, CheckCircle2, AlertTriangle, User, } from "lucide-react"; import { useSearchParams } from "next/navigation"; import { metricsData } from "./metricsData"; import { getMockStudentById } from "@/lib/mockApi"; import { useAuth } from "@/components/AuthProvider"; export default function MetricsContent({ metricId }: { metricId: string }) { const searchParams = useSearchParams(); const { user } = useAuth(); const studentId = searchParams.get("student") || (user?.role === 'stu' ? user.id : null); const student = studentId ? getMockStudentById(studentId) : null; const categoryStr = metricId.charAt(0).toUpperCase(); const metricCategoryList = metricsData[categoryStr] || []; const metricObj = metricCategoryList.find(m => m.id === metricId.toUpperCase()); if (!metricObj) { return (

未找到指标 {metricId.toUpperCase()} 的详情

); } // When viewing a specific student, use their pre-generated score for this metric. // Otherwise use the static class average from metricsData. let scoreNum = parseFloat(metricObj.avgScore) || 85.0; if (student) { const storedScore = student.metricScores?.[metricId.toUpperCase()]; if (storedScore !== undefined) { scoreNum = storedScore; } } return (

子指标分析

关于 {metricObj.id} 的详细数据维度拆解

{metricObj.subMetrics.map((sub, i) => { // Generating some mock variation to make UI look realistic const subScore = Math.min(100, scoreNum + ((i % 3 === 0 ? 1 : -1) * (i * 2 + 3))); const isWarn = subScore < 80; return (
{sub.id}

{sub.name}

{isWarn ? : }
{sub.values.map((val, idx) => (

{val.name}

{idx === 0 ? subScore + '%' : (isWarn ? '一般' : '优秀')}
))}
); })}
); }