File size: 2,790 Bytes
ad74240
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import React from 'react';
import { BrowserRouter, Routes, Route, Navigate } from 'react-router-dom';
import { Provider } from 'react-redux';
import { ConfigProvider, message } from 'antd';
import zhCN from 'antd/locale/zh_CN';
import store from './store/store';
import LoginPage from './pages/LoginPage';
import RegisterPage from './pages/RegisterPage';
import TeacherDashboard from './pages/teacher/TeacherDashboard';
import StudentDashboard from './pages/student/StudentDashboard';
import AgentChat from './pages/student/AgentChat';
import ProtectedRoute from './components/common/ProtectedRoute';
import './index.css';

// Ant Design 主题配置
const theme = {
  token: {
    colorPrimary: '#10b981',
    colorSuccess: '#10b981',
    colorWarning: '#f97316',
    colorError: '#f43f5e',
    colorInfo: '#8b5cf6',
    borderRadius: 8,
    fontSize: 14,
    fontFamily: "'Inter', 'PingFang SC', 'Microsoft YaHei', sans-serif",
  },
  components: {
    Button: {
      controlHeight: 40,
      fontWeight: 500,
    },
    Input: {
      controlHeight: 40,
    },
    Select: {
      controlHeight: 40,
    },
    Menu: {
      itemBorderRadius: 8,
      subMenuItemBorderRadius: 8,
    },
    Card: {
      borderRadiusLG: 12,
      boxShadow: '0 2px 8px rgba(0, 0, 0, 0.04)',
    },
  },
};

// 全局消息配置
message.config({
  top: 80,
  duration: 3,
  maxCount: 3,
});

function App() {
  return (
    <Provider store={store}>
      <ConfigProvider theme={theme} locale={zhCN}>
        <BrowserRouter>
          <Routes>
            <Route path="/login" element={<LoginPage />} />
            <Route path="/register" element={<RegisterPage />} />

            {/* Agent对话页面 - 不需要登录保护,通过token访问 */}
            {/* 注意:这个路由必须在 /student/* 之前,否则会被捕获并要求登录 */}
            <Route path="/student/chat/:agentId" element={<AgentChat />} />

            {/* 教师端路由 */}
            <Route
              path="/teacher/*"
              element={
                <ProtectedRoute requiredRole="teacher">
                  <TeacherDashboard />
                </ProtectedRoute>
              }
            />

            {/* 学生端路由 - 排除chat路径 */}
            <Route
              path="/student/*"
              element={
                <ProtectedRoute requiredRole="student">
                  <StudentDashboard />
                </ProtectedRoute>
              }
            />

            {/* 默认重定向到登录 */}
            <Route path="/" element={<Navigate to="/login" replace />} />
            <Route path="*" element={<Navigate to="/login" replace />} />
          </Routes>
        </BrowserRouter>
      </ConfigProvider>
    </Provider>
  );
}

export default App;