page.tsx 847 B

123456789101112131415161718192021222324252627
  1. "use client";
  2. import DashboardContent from "@/components/DashboardContent";
  3. import TeacherDashboard from "@/components/TeacherDashboard";
  4. import { useAuth } from "@/components/AuthProvider";
  5. import { Loader2 } from "lucide-react";
  6. export default function Home() {
  7. const { user, isLoading } = useAuth();
  8. if (isLoading) {
  9. return (
  10. <div className="flex-1 h-full w-full flex items-center justify-center p-8 text-secondary">
  11. <Loader2 className="w-10 h-10 animate-spin mr-3 text-primary" />
  12. <span className="font-bold text-lg animate-pulse">正在验证身份与加载数据门户...</span>
  13. </div>
  14. );
  15. }
  16. // Teacher specific view spanning aggregate stats
  17. if (user?.role === "teacher") {
  18. return <TeacherDashboard />;
  19. }
  20. // Fallback to default granular student view
  21. return <DashboardContent />;
  22. }