"use client"; import { useState, useEffect } from "react"; import { Download, Users, TrendingUp, Award, UserCheck, Loader2 } from "lucide-react"; import { mockApi, ClassStats, LeaderboardEntry } from "@/lib/mockApi"; import Link from "next/link"; export default function TeacherDashboard() { const [activeTab, setActiveTab] = useState<"K" | "A" | "S" | "D">("K"); const [stats, setStats] = useState(null); const [topPerformers, setTopPerformers] = useState([]); const [loading, setLoading] = useState(true); useEffect(() => { const fetchData = async () => { const [classStats, leaderboard] = await Promise.all([ mockApi.getClassStats(), mockApi.getLeaderboard(5), ]); setStats(classStats); setTopPerformers(leaderboard); setLoading(false); }; fetchData(); }, []); // Visual config for each dimension const dimConfig = { K: { trend: "+2.1%", label: "软件工程知识", color: "text-chart-3", bg: "bg-primary-container", icon: }, A: { trend: "+4.5%", label: "AI输出获取", color: "text-chart-4", bg: "bg-chart-5-container", icon: }, S: { trend: "-1.2%", label: "文档编程实现", color: "text-tertiary", bg: "bg-tertiary-container", icon: }, D: { trend: "+0.8%", label: "协作态度考核", color: "text-chart-1", bg: "bg-secondary-container", icon: } }; if (loading || !stats) { return (
正在加载教学大盘数据...
); } const classAverages = Object.entries(dimConfig).map(([key, cfg]) => ({ key, score: stats.averages[key as keyof typeof stats.averages], ...cfg, })); const distributions = stats.distributions; return (
{/* Header */}

教学大盘数据总览

全体学生多维度能力评估核心统计基准板

{/* Aggregate Score Cards */}
{classAverages.map((data) => (
{/* Gradient splash */}

大类平均维度 {data.key}

{data.label}

{data.icon}
{data.score}
{data.trend} {data.trend.startsWith('+') ? ' ↑' : ' ↓'}
))}
{/* Disbribution Section (2 cols) */}

能力等级分布图

{distributions[activeTab].map((item, idx) => { // Dynamic styling based on tier let barColor = "bg-metric-high"; if (idx === 1) barColor = "bg-metric-mid"; else if (idx === 2) barColor = "bg-metric-warn"; else if (idx === 3) barColor = "bg-metric-low"; return (
{item.tier} {item.count} 人 ({item.percent})
) })}
{/* Top Performers (1 col) */}

班级领军学霸榜

{topPerformers.map((stu, i) => (
{i+1} {stu.name[0]}

{stu.name}

{stu.id}

{stu.score}
强项: {stu.bestAt}
))}
查看全体排名及明细 →
); }