2026-05-22 00:38:56 +08:00
|
|
|
|
import { Suspense, lazy } from 'react'
|
2026-05-20 22:36:22 +08:00
|
|
|
|
import { BrowserRouter, Routes, Route } from 'react-router-dom'
|
|
|
|
|
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
|
|
|
|
import { ConfigProvider } from 'antd'
|
|
|
|
|
|
import zhCN from 'antd/locale/zh_CN'
|
2026-05-21 17:19:58 +08:00
|
|
|
|
import { AuthProvider } from './contexts/AuthContext'
|
|
|
|
|
|
import AuthGuard from './components/AuthGuard'
|
|
|
|
|
|
import PermissionGuard from './components/PermissionGuard'
|
|
|
|
|
|
import PageLoading from './components/PageLoading'
|
|
|
|
|
|
import AdminLayout from './layouts/AdminLayout'
|
|
|
|
|
|
|
|
|
|
|
|
const Login = lazy(() => import('./pages/Login'))
|
2026-05-22 15:55:33 +08:00
|
|
|
|
const KnowledgeBasesPage = lazy(() => import('./pages/KnowledgeBases'))
|
2026-05-22 15:31:00 +08:00
|
|
|
|
const BillingPage = lazy(() => import('./pages/Billing'))
|
2026-05-22 14:35:26 +08:00
|
|
|
|
const GiteaEmbed = lazy(() => import('./pages/GiteaEmbed'))
|
2026-05-22 22:37:45 +08:00
|
|
|
|
const ConfigPage = lazy(() => import("./pages/Config"))
|
2026-05-23 20:37:26 +08:00
|
|
|
|
const SecretsPage = lazy(() => import('./pages/Secrets'))
|
2026-05-23 20:19:14 +08:00
|
|
|
|
const MembershipPage = lazy(() => import("./pages/Membership"))
|
2026-05-23 09:45:09 +08:00
|
|
|
|
const FilesAdminPage = lazy(() => import("./pages/FilesAdmin"))
|
2026-05-23 09:40:05 +08:00
|
|
|
|
const AiGatewayPage = lazy(() => import("./pages/AiGateway"))
|
2026-05-22 23:21:30 +08:00
|
|
|
|
const CSPage = lazy(() => import("./pages/ContentSafety"))
|
|
|
|
|
|
const MetricsPage = lazy(() => import("./pages/Metrics"))
|
2026-05-22 22:32:04 +08:00
|
|
|
|
const EventsPage = lazy(() => import("./pages/Events"))
|
2026-05-22 13:30:37 +08:00
|
|
|
|
const ServersPage = lazy(() => import("./pages/Servers"))
|
2026-05-22 12:10:46 +08:00
|
|
|
|
const AuditLogPage = lazy(() => import("./pages/AuditLog"))
|
2026-05-21 17:19:58 +08:00
|
|
|
|
const Dashboard = lazy(() => import('./pages/Dashboard'))
|
|
|
|
|
|
const UserManagement = lazy(() => import('./pages/UserManagement'))
|
2026-05-22 17:13:09 +08:00
|
|
|
|
const HermesSettings = lazy(() => import('./pages/HermesSettings'))
|
2026-05-22 17:14:05 +08:00
|
|
|
|
const TaskAssistant = lazy(() => import('./pages/TaskAssistant'))
|
2026-05-21 17:19:58 +08:00
|
|
|
|
const Placeholder = lazy(() => import('./pages/Placeholder'))
|
|
|
|
|
|
const ForbiddenPage = lazy(() => import('./pages/403'))
|
|
|
|
|
|
const NotFoundPage = lazy(() => import('./pages/404'))
|
|
|
|
|
|
const ServerErrorPage = lazy(() => import('./pages/500'))
|
2026-05-20 22:36:22 +08:00
|
|
|
|
|
|
|
|
|
|
const queryClient = new QueryClient()
|
|
|
|
|
|
|
|
|
|
|
|
function App() {
|
|
|
|
|
|
return (
|
|
|
|
|
|
<QueryClientProvider client={queryClient}>
|
|
|
|
|
|
<ConfigProvider locale={zhCN}>
|
2026-05-21 17:19:58 +08:00
|
|
|
|
<AuthProvider>
|
|
|
|
|
|
<BrowserRouter>
|
|
|
|
|
|
<Suspense fallback={<PageLoading />}>
|
|
|
|
|
|
<Routes>
|
|
|
|
|
|
<Route path="/login" element={<Login />} />
|
|
|
|
|
|
<Route path="/403" element={<ForbiddenPage />} />
|
|
|
|
|
|
<Route path="/500" element={<ServerErrorPage />} />
|
|
|
|
|
|
<Route path="/404" element={<NotFoundPage />} />
|
|
|
|
|
|
<Route
|
|
|
|
|
|
element={
|
|
|
|
|
|
<AuthGuard>
|
|
|
|
|
|
<AdminLayout />
|
|
|
|
|
|
</AuthGuard>
|
|
|
|
|
|
}
|
|
|
|
|
|
>
|
|
|
|
|
|
<Route index element={<Dashboard />} />
|
2026-05-22 17:14:05 +08:00
|
|
|
|
<Route path="assistant" element={<TaskAssistant />} />
|
2026-05-22 17:14:37 +08:00
|
|
|
|
<Route path="hermes" element={<Suspense fallback={<PageLoading />}><HermesSettings /></Suspense>} />
|
2026-05-21 17:19:58 +08:00
|
|
|
|
<Route
|
|
|
|
|
|
path="users"
|
|
|
|
|
|
element={
|
|
|
|
|
|
<PermissionGuard requiredRole="ADMIN">
|
|
|
|
|
|
<UserManagement />
|
|
|
|
|
|
</PermissionGuard>
|
|
|
|
|
|
}
|
|
|
|
|
|
/>
|
|
|
|
|
|
<Route
|
|
|
|
|
|
path="users/admins"
|
|
|
|
|
|
element={
|
|
|
|
|
|
<PermissionGuard requiredRole="SUPER_ADMIN">
|
|
|
|
|
|
<UserManagement />
|
|
|
|
|
|
</PermissionGuard>
|
|
|
|
|
|
}
|
|
|
|
|
|
/>
|
|
|
|
|
|
<Route path="users/members" element={<Placeholder title="普通用户" />} />
|
2026-05-23 20:37:26 +08:00
|
|
|
|
<Route
|
|
|
|
|
|
path="secrets"
|
|
|
|
|
|
element={<PermissionGuard requiredRole="SUPER_ADMIN"><Suspense fallback={<PageLoading />}><SecretsPage /></Suspense></PermissionGuard>}
|
|
|
|
|
|
/>
|
2026-05-21 17:19:58 +08:00
|
|
|
|
<Route
|
|
|
|
|
|
path="membership"
|
|
|
|
|
|
element={
|
|
|
|
|
|
<PermissionGuard requiredRole="ADMIN">
|
2026-05-23 20:18:55 +08:00
|
|
|
|
<Suspense fallback={<PageLoading />}><MembershipPage /></Suspense>
|
2026-05-21 17:19:58 +08:00
|
|
|
|
</PermissionGuard>
|
|
|
|
|
|
}
|
|
|
|
|
|
/>
|
2026-05-22 16:02:51 +08:00
|
|
|
|
<Route path="knowledge/bases" element={<Suspense fallback={<PageLoading />}><KnowledgeBasesPage /></Suspense>} />
|
2026-05-21 17:19:58 +08:00
|
|
|
|
<Route path="knowledge/sources" element={<Placeholder title="知识源列表" />} />
|
|
|
|
|
|
<Route path="imports" element={<Placeholder title="文档导入" />} />
|
2026-05-23 09:44:58 +08:00
|
|
|
|
<Route path="files" element={<Suspense fallback={<PageLoading />}><FilesAdminPage /></Suspense>} />
|
2026-05-21 17:19:58 +08:00
|
|
|
|
<Route
|
|
|
|
|
|
path="settings"
|
|
|
|
|
|
element={
|
|
|
|
|
|
<PermissionGuard requiredRole="ADMIN">
|
|
|
|
|
|
<Placeholder title="系统配置" />
|
|
|
|
|
|
</PermissionGuard>
|
|
|
|
|
|
}
|
|
|
|
|
|
/>
|
2026-05-22 15:55:33 +08:00
|
|
|
|
<Route
|
|
|
|
|
|
path="knowledge/bases"
|
|
|
|
|
|
element={<Suspense fallback={<PageLoading />}><KnowledgeBasesPage /></Suspense>}
|
|
|
|
|
|
/>
|
2026-05-22 15:31:00 +08:00
|
|
|
|
<Route
|
|
|
|
|
|
path="billing"
|
|
|
|
|
|
element={<PermissionGuard requiredRole="SUPER_ADMIN"><Suspense fallback={<PageLoading />}><BillingPage /></Suspense></PermissionGuard>}
|
|
|
|
|
|
/>
|
2026-05-22 14:35:26 +08:00
|
|
|
|
<Route
|
|
|
|
|
|
path="git"
|
|
|
|
|
|
element={
|
|
|
|
|
|
<Suspense fallback={<PageLoading />}><GiteaEmbed /></Suspense>
|
|
|
|
|
|
}
|
|
|
|
|
|
/>
|
2026-05-22 22:37:28 +08:00
|
|
|
|
<Route
|
|
|
|
|
|
path="config"
|
|
|
|
|
|
element={<PermissionGuard requiredRole="SUPER_ADMIN"><Suspense fallback={<PageLoading />}><ConfigPage /></Suspense></PermissionGuard>}
|
|
|
|
|
|
/>
|
2026-05-23 09:39:53 +08:00
|
|
|
|
<Route
|
|
|
|
|
|
path="ai-gateway"
|
|
|
|
|
|
element={<PermissionGuard requiredRole="SUPER_ADMIN"><Suspense fallback={<PageLoading />}><AiGatewayPage /></Suspense></PermissionGuard>}
|
|
|
|
|
|
/>
|
2026-05-22 23:21:15 +08:00
|
|
|
|
<Route
|
|
|
|
|
|
path="metrics"
|
|
|
|
|
|
element={<PermissionGuard requiredRole="SUPER_ADMIN"><Suspense fallback={<PageLoading />}><MetricsPage /></Suspense></PermissionGuard>}
|
|
|
|
|
|
/>
|
|
|
|
|
|
<Route
|
|
|
|
|
|
path="safety"
|
|
|
|
|
|
element={<PermissionGuard requiredRole="SUPER_ADMIN"><Suspense fallback={<PageLoading />}><CSPage /></Suspense></PermissionGuard>}
|
|
|
|
|
|
/>
|
2026-05-22 22:31:46 +08:00
|
|
|
|
<Route
|
|
|
|
|
|
path="events"
|
|
|
|
|
|
element={<PermissionGuard requiredRole="SUPER_ADMIN"><Suspense fallback={<PageLoading />}><EventsPage /></Suspense></PermissionGuard>}
|
|
|
|
|
|
/>
|
2026-05-22 13:30:37 +08:00
|
|
|
|
<Route
|
|
|
|
|
|
path="servers"
|
|
|
|
|
|
element={
|
|
|
|
|
|
<PermissionGuard requiredRole="SUPER_ADMIN">
|
|
|
|
|
|
<Suspense fallback={<PageLoading />}><ServersPage /></Suspense>
|
|
|
|
|
|
</PermissionGuard>
|
|
|
|
|
|
}
|
|
|
|
|
|
/>
|
2026-05-21 17:19:58 +08:00
|
|
|
|
<Route
|
|
|
|
|
|
path="audit"
|
|
|
|
|
|
element={
|
|
|
|
|
|
<PermissionGuard requiredRole="ADMIN">
|
2026-05-22 12:10:46 +08:00
|
|
|
|
<Suspense fallback={<PageLoading />}><AuditLogPage /></Suspense>
|
2026-05-21 17:19:58 +08:00
|
|
|
|
</PermissionGuard>
|
|
|
|
|
|
}
|
|
|
|
|
|
/>
|
|
|
|
|
|
<Route path="*" element={<NotFoundPage />} />
|
|
|
|
|
|
</Route>
|
|
|
|
|
|
</Routes>
|
|
|
|
|
|
</Suspense>
|
|
|
|
|
|
</BrowserRouter>
|
|
|
|
|
|
</AuthProvider>
|
2026-05-20 22:36:22 +08:00
|
|
|
|
</ConfigProvider>
|
|
|
|
|
|
</QueryClientProvider>
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export default App
|