index.js 735 Bytes
Newer Older
zhanghaozhe committed
1
import React from 'react'
zhanghaozhe committed
2
import { Switch, Route } from 'react-router-dom'
zhanghaozhe committed
3
import RouterConfig from './router-config'
4
import PrivateRoute from './privateRoute'
wangshuo committed
5 6 7 8 9 10 11 12 13 14
// 动态改变title
// const RouteWithSubRoutes = route => {
//     return (
//         <Route
//             exact
//             {...route}
//             onChange={document.title = route.name}
//         />
//     );
// };
zhanghaozhe committed
15 16

export default function () {
xuzhenghua committed
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
  return (
    <Switch>
      {RouterConfig.map((item, index) => {
        let {isPrivate, ...rest} = item
        if (isPrivate) {
          return <PrivateRoute {...rest} key={index}/>
        } else {
          return (
            <Route {...rest} key={index}/>
          )
        }
      })}
    </Switch>
  )
}