|
|
@@ -1,31 +1,43 @@
|
|
|
import React from "react";
|
|
|
-import { Link } from "react-router";
|
|
|
+import { useNavigate } from "react-router";
|
|
|
+import { useAuth } from "./hooks.tsx";
|
|
|
|
|
|
export default function StockHomePage() {
|
|
|
+ const { user } = useAuth();
|
|
|
+ const navigate = useNavigate();
|
|
|
+
|
|
|
+ const handleClassroomClick = () => {
|
|
|
+ if (user?.role === 'admin') {
|
|
|
+ navigate('/mobile/classroom?role=admin');
|
|
|
+ } else {
|
|
|
+ navigate('/mobile/classroom?role=student');
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
return (
|
|
|
<div className="min-h-screen bg-gray-50 p-4 md:p-8">
|
|
|
<h1 className="text-3xl font-bold text-center text-gray-800 mb-8 md:mb-12">
|
|
|
股票训练系统
|
|
|
</h1>
|
|
|
<div className="flex flex-col gap-4 max-w-md mx-auto">
|
|
|
- <Link
|
|
|
- to="/mobile/classroom"
|
|
|
+ <button
|
|
|
+ onClick={handleClassroomClick}
|
|
|
className="bg-blue-600 hover:bg-blue-700 text-white font-medium py-3 px-6 rounded-lg shadow-md transition-colors duration-200 text-center"
|
|
|
>
|
|
|
- 课堂训练
|
|
|
- </Link>
|
|
|
- <Link
|
|
|
- to="/mobile/exam"
|
|
|
+ 解盘室
|
|
|
+ </button>
|
|
|
+ <button
|
|
|
+ onClick={() => navigate('/mobile/exam')}
|
|
|
className="bg-green-600 hover:bg-green-700 text-white font-medium py-3 px-6 rounded-lg shadow-md transition-colors duration-200 text-center"
|
|
|
>
|
|
|
考试模式
|
|
|
- </Link>
|
|
|
- <Link
|
|
|
- to="/mobile/xunlian"
|
|
|
+ </button>
|
|
|
+ <button
|
|
|
+ onClick={() => navigate('/mobile/xunlian')}
|
|
|
className="bg-purple-600 hover:bg-purple-700 text-white font-medium py-3 px-6 rounded-lg shadow-md transition-colors duration-200 text-center"
|
|
|
>
|
|
|
训练模式
|
|
|
- </Link>
|
|
|
+ </button>
|
|
|
</div>
|
|
|
</div>
|
|
|
);
|