init

Change-Id: I62d8e17fdc3103133b9ddaff22c27ddd9ea9f6ac
diff --git a/src/route/index.tsx b/src/route/index.tsx
new file mode 100644
index 0000000..da0720e
--- /dev/null
+++ b/src/route/index.tsx
@@ -0,0 +1,19 @@
+import { createBrowserRouter } from 'react-router-dom'
+import PrivateRoute from './privateRoute'
+import Login from '../views/login'
+import React from 'react'
+import Forum from '../views/forum'
+
+const router = createBrowserRouter([
+    {
+        path: '/',
+        element: <Forum /> // 论坛主页面
+    },
+    {
+        path: '/login',
+        element: <Login /> // 登录页作为独立路由
+    }
+]
+)
+
+export default router
\ No newline at end of file
diff --git a/src/route/privateRoute.tsx b/src/route/privateRoute.tsx
new file mode 100644
index 0000000..8391f90
--- /dev/null
+++ b/src/route/privateRoute.tsx
@@ -0,0 +1,22 @@
+import { Navigate, Outlet } from 'react-router-dom'
+import React from 'react'
+
+interface PrivateRouteProps {
+  isAllowed: boolean
+  redirectPath?: string
+  children?: React.ReactNode
+}
+
+const PrivateRoute = ({
+  isAllowed,
+  redirectPath = '/login',
+  children
+}: PrivateRouteProps) => {
+  if (!isAllowed) {
+    return <Navigate to={redirectPath} replace />
+  }
+
+  return children ? children : <Outlet />
+}
+
+export default PrivateRoute
\ No newline at end of file