2026-01-30 05:00:57 +00:00
|
|
|
import { useEffect } from 'react'
|
2025-12-29 12:53:50 +00:00
|
|
|
import { BrowserRouter, Routes, Route, Navigate, useParams, Outlet } from 'react-router-dom'
|
2026-01-30 05:00:57 +00:00
|
|
|
import { ConfigProvider, theme } from 'antd'
|
2025-12-20 11:18:59 +00:00
|
|
|
import zhCN from 'antd/locale/zh_CN'
|
2026-02-11 02:26:50 +00:00
|
|
|
import dayjs from 'dayjs'
|
|
|
|
|
import 'dayjs/locale/zh-cn'
|
2026-01-30 05:00:57 +00:00
|
|
|
import useThemeStore from '@/stores/themeStore'
|
2025-12-20 11:18:59 +00:00
|
|
|
import Login from '@/pages/Login/Login'
|
|
|
|
|
import ProjectList from '@/pages/ProjectList/ProjectList'
|
|
|
|
|
import DocumentPage from '@/pages/Document/DocumentPage'
|
|
|
|
|
import DocumentEditor from '@/pages/Document/DocumentEditor'
|
|
|
|
|
import Dashboard from '@/pages/Dashboard'
|
|
|
|
|
import Desktop from '@/pages/Desktop'
|
|
|
|
|
import Constructing from '@/pages/Constructing'
|
2026-05-09 02:45:30 +00:00
|
|
|
import ProjectSharePage from '@/pages/Preview/ProjectSharePage'
|
|
|
|
|
import FileSharePage from '@/pages/Preview/FileSharePage'
|
2025-12-20 11:18:59 +00:00
|
|
|
import ProfilePage from '@/pages/Profile/ProfilePage'
|
2025-12-23 05:02:10 +00:00
|
|
|
import Permissions from '@/pages/System/Permissions'
|
|
|
|
|
import Users from '@/pages/System/Users'
|
|
|
|
|
import Roles from '@/pages/System/Roles'
|
2025-12-29 12:53:50 +00:00
|
|
|
import SystemLogs from '@/pages/SystemLogs/SystemLogs'
|
2026-01-06 10:04:06 +00:00
|
|
|
import NotificationList from '@/pages/Notifications/NotificationList'
|
2025-12-20 11:18:59 +00:00
|
|
|
import ProtectedRoute from '@/components/ProtectedRoute'
|
2025-12-29 12:53:50 +00:00
|
|
|
import MainLayout from '@/components/MainLayout/MainLayout'
|
2025-12-20 11:18:59 +00:00
|
|
|
import '@/App.css'
|
|
|
|
|
|
2026-02-11 02:26:50 +00:00
|
|
|
dayjs.locale('zh-cn')
|
|
|
|
|
|
2025-12-25 04:22:35 +00:00
|
|
|
// 重定向到文档页面的组件
|
|
|
|
|
function RedirectToDocs() {
|
|
|
|
|
const { projectId } = useParams()
|
|
|
|
|
return <Navigate to={`/projects/${projectId}/docs`} replace />
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-29 12:53:50 +00:00
|
|
|
// 共享布局的包装组件
|
|
|
|
|
function LayoutWrapper() {
|
|
|
|
|
return (
|
|
|
|
|
<MainLayout>
|
|
|
|
|
<Outlet />
|
|
|
|
|
</MainLayout>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-20 11:18:59 +00:00
|
|
|
function App() {
|
2026-01-30 05:00:57 +00:00
|
|
|
const { isDarkMode } = useThemeStore()
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (isDarkMode) {
|
|
|
|
|
document.body.classList.add('dark')
|
|
|
|
|
} else {
|
|
|
|
|
document.body.classList.remove('dark')
|
|
|
|
|
}
|
|
|
|
|
}, [isDarkMode])
|
|
|
|
|
|
2025-12-20 11:18:59 +00:00
|
|
|
return (
|
2026-01-30 05:00:57 +00:00
|
|
|
<ConfigProvider
|
|
|
|
|
locale={zhCN}
|
|
|
|
|
theme={{
|
|
|
|
|
algorithm: isDarkMode ? theme.darkAlgorithm : theme.defaultAlgorithm,
|
|
|
|
|
}}
|
|
|
|
|
>
|
2025-12-20 11:18:59 +00:00
|
|
|
<BrowserRouter>
|
|
|
|
|
<Routes>
|
|
|
|
|
<Route path="/login" element={<Login />} />
|
2026-05-09 02:45:30 +00:00
|
|
|
<Route path="/share/project/:shareCode" element={<ProjectSharePage />} />
|
|
|
|
|
<Route path="/share/file/:shareCode" element={<FileSharePage />} />
|
2025-12-29 12:53:50 +00:00
|
|
|
|
|
|
|
|
{/* 使用共享布局的路由 */}
|
|
|
|
|
<Route element={<ProtectedRoute><LayoutWrapper /></ProtectedRoute>}>
|
|
|
|
|
<Route path="/dashboard" element={<Dashboard />} />
|
|
|
|
|
<Route path="/desktop" element={<Desktop />} />
|
|
|
|
|
<Route path="/projects" element={<Navigate to="/projects/my" replace />} />
|
|
|
|
|
<Route path="/projects/my" element={<ProjectList type="my" />} />
|
|
|
|
|
<Route path="/projects/share" element={<ProjectList type="share" />} />
|
|
|
|
|
<Route path="/projects/:projectId/docs" element={<DocumentPage />} />
|
|
|
|
|
<Route path="/projects/:projectId/editor" element={<DocumentEditor />} />
|
|
|
|
|
<Route path="/projects/:projectId/*" element={<RedirectToDocs />} />
|
|
|
|
|
<Route path="/constructing" element={<Constructing />} />
|
|
|
|
|
<Route path="/profile" element={<ProfilePage />} />
|
2026-01-06 10:04:06 +00:00
|
|
|
<Route path="/notifications" element={<NotificationList />} />
|
2025-12-29 12:53:50 +00:00
|
|
|
<Route path="/system/permissions" element={<Permissions />} />
|
|
|
|
|
<Route path="/system/users" element={<Users />} />
|
|
|
|
|
<Route path="/system/roles" element={<Roles />} />
|
|
|
|
|
<Route path="/system/logs" element={<SystemLogs />} />
|
|
|
|
|
</Route>
|
|
|
|
|
|
2025-12-20 11:18:59 +00:00
|
|
|
<Route path="/" element={<Navigate to="/projects" replace />} />
|
|
|
|
|
</Routes>
|
|
|
|
|
</BrowserRouter>
|
|
|
|
|
</ConfigProvider>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default App
|