blob: c56ada35a5cee1c444059df718606b802017954c [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'
San3yuan03ab0642025-04-29 18:00:25 +08005import Frame from '../views/frame/frame'
San3yuan4d0e8032025-04-04 17:21:40 +08006import React from 'react'
7import Forum from '../views/forum'
San3yuan2534d422025-04-08 21:43:18 +08008import { RootState } from '@/store'
San3yuan4d0e8032025-04-04 17:21:40 +08009
10const router = createBrowserRouter([
11 {
12 path: '/',
San3yuan6f2ed692025-04-16 20:24:49 +080013 element:
14 <PrivateRoute
San3yuan2534d422025-04-08 21:43:18 +080015 role={0} // 判断是否登录
16 redirectPath="/login"/>,
17 children: [
18 {
San3yuan03ab0642025-04-29 18:00:25 +080019 path:'/',
20 element: <Frame/>,
21 children: [
22 {
23 index: true,
24 element:<Forum/>
25
26 },
27 ]
San3yuan2534d422025-04-08 21:43:18 +080028 },
29 ]
San3yuan4d0e8032025-04-04 17:21:40 +080030 },
31 {
32 path: '/login',
33 element: <Login /> // 登录页作为独立路由
34 }
San3yuan2534d422025-04-08 21:43:18 +080035
36
37
San3yuan4d0e8032025-04-04 17:21:40 +080038]
39)
40
41export default router