import history from '@/utils/history'
import React from 'react'
import { Route, Router, Switch } from 'react-router-dom'
import SpinLoding from './SpinLoding'
import NotFound from '@/components/NotFound'
import A0base from '@/pages/A0base'

const routerArr = [
  {
    id: 1,
    name: '首页',
    path: '/',
    exact: true,
    Com: React.lazy(() => import('@/pages/A0base'))
  },
  {
    id: 2,
    name: '主页',
    path: '/home',
    exact: true,
    Com: React.lazy(() => import('@/pages/A1home'))
  },

  {
    id: 9,
    name: '找不到页面',
    path: '*',
    exact: false,
    Com: NotFound
  }
]

function RouterOrder() {
  return (
    <Router history={history}>
      <React.Suspense fallback={<SpinLoding />}>
        <Switch>
          {routerArr.map(v => (
            <Route key={v.id} path={v.path} exact={v.exact} component={v.Com} />
          ))}
        </Switch>
      </React.Suspense>
    </Router>
  )
}

const MemoRouterOrder = React.memo(RouterOrder)

export default MemoRouterOrder
