blob: d857a3698e655f424254f14fe45acc8487534b75 [file] [log] [blame]
San3yuan4d0e8032025-04-04 17:21:40 +08001import { createBrowserRouter } from 'react-router-dom'
2import PrivateRoute from './privateRoute'
San3yuan2534d422025-04-08 21:43:18 +08003import { useSelector } from 'react-redux'
San3yuan6f2ed692025-04-16 20:24:49 +08004import Login from '../views/login/login'
San3yuan4d0e8032025-04-04 17:21:40 +08005import React from 'react'
6import Forum from '../views/forum'
San3yuan2534d422025-04-08 21:43:18 +08007import { RootState } from '@/store'
San3yuan4d0e8032025-04-04 17:21:40 +08008
9const router = createBrowserRouter([
10 {
11 path: '/',
San3yuan6f2ed692025-04-16 20:24:49 +080012 element:
13 <PrivateRoute
San3yuan2534d422025-04-08 21:43:18 +080014 role={0} // 判断是否登录
15 redirectPath="/login"/>,
16 children: [
17 {
18 index: true,
19 element: <Forum /> // 论坛主页面
20 },
21 ]
San3yuan4d0e8032025-04-04 17:21:40 +080022 },
23 {
24 path: '/login',
25 element: <Login /> // 登录页作为独立路由
26 }
San3yuan2534d422025-04-08 21:43:18 +080027
28
29
San3yuan4d0e8032025-04-04 17:21:40 +080030]
31)
32
33export default router