index.tsx 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import AuthRoute from '@/components/AuthRoute'
  2. import LeftBar from '@/components/LeftBar'
  3. import NotFound from '@/components/NotFound'
  4. import SpinLoding from '@/components/SpinLoding'
  5. import React from 'react'
  6. import { useMemo } from 'react'
  7. import { Route, Switch } from 'react-router-dom'
  8. import styles from './index.module.scss'
  9. export default function System() {
  10. const data = useMemo(() => {
  11. return [
  12. {
  13. id: 1,
  14. name: '用户管理',
  15. Com: React.lazy(() => import('../SystemSon/System1')),
  16. path: '/system'
  17. },
  18. {
  19. id: 2,
  20. name: '角色管理',
  21. Com: React.lazy(() => import('../SystemSon/System2')),
  22. path: '/system/2'
  23. },
  24. {
  25. id: 3,
  26. name: '系统日志',
  27. Com: React.lazy(() => import('../SystemSon/System3')),
  28. path: '/system/3'
  29. },
  30. {
  31. id: 4,
  32. name: '数据字典',
  33. Com: React.lazy(() => import('../SystemSon/System4')),
  34. path: '/system/4'
  35. },
  36. {
  37. id: 5,
  38. name: '规划管理',
  39. Com: React.lazy(() => import('../SystemSon/System5')),
  40. path: '/system/5'
  41. }
  42. ]
  43. }, [])
  44. return (
  45. <div className={styles.System}>
  46. <div className='leftBar'>
  47. <LeftBar data={data} />
  48. </div>
  49. {/* 三级路由页面 */}
  50. <div className='rightMain'>
  51. <React.Suspense fallback={<SpinLoding />}>
  52. <Switch>
  53. {data.map((v, i) => (
  54. <AuthRoute
  55. exact
  56. // exact={i === 0 ? true : false}
  57. key={v.id}
  58. path={v.path}
  59. component={v.Com}
  60. />
  61. ))}
  62. {/* 查看页面,无需权限 */}
  63. {/* <AuthRoute path="/stores/3/look" component={LookStores3} /> */}
  64. {/* 新增 */}
  65. {/* {dataIn.map((v) => (
  66. <AuthRoute key={v.id} path={v.path} component={v.Com} />
  67. ))} */}
  68. <Route path='*' component={NotFound} />
  69. </Switch>
  70. </React.Suspense>
  71. </div>
  72. </div>
  73. )
  74. }