Kaynağa Gözat

已完成课堂训练页面角色视图控制

yourname 6 ay önce
ebeveyn
işleme
ddec2b647a
1 değiştirilmiş dosya ile 9 ekleme ve 0 silme
  1. 9 0
      client/mobile/pages_xunlian.tsx

+ 9 - 0
client/mobile/pages_xunlian.tsx

@@ -4,6 +4,9 @@ import { useQuery } from "@tanstack/react-query";
 import type { XunlianCode } from "../share/types_stock.ts";
 import { useNavigate } from "react-router";
 import { XunlianCodeAPI } from "./api/xunlian_codes.ts";
+import { useAuth } from "./hooks.tsx";
+import { TeacherView } from "./components/Classroom/TeacherView.tsx";
+import { StudentView } from "./components/Classroom/StudentView.tsx";
 
 export function XunlianPage() {
   const [visibleStocks, setVisibleStocks] = useState<Record<number, boolean>>({});
@@ -29,6 +32,12 @@ export function XunlianPage() {
     navigate(`/mobile/stock?code=${code.code}`);
   };
 
+  const { user } = useAuth();
+
+  if (user?.role === 'admin') {
+    return <TeacherView />;
+  }
+
   return (
     <div className="p-4">
       <div className="flex justify-between items-center mb-4">