|
@ -1,45 +1,24 @@ |
|
|
import React, {Suspense} from "react"; |
|
|
|
|
|
import { Redirect, Route, Switch } from 'react-router-dom' |
|
|
|
|
|
import routes from './config' |
|
|
|
|
|
|
|
|
import React from 'react'; |
|
|
|
|
|
import routes from "./routes"; |
|
|
|
|
|
import { BrowserRouter, Route, Routes } from "react-router-dom"; |
|
|
|
|
|
|
|
|
const RouterView = () => { |
|
|
|
|
|
// const { routes } = props
|
|
|
|
|
|
// console.log(routes)
|
|
|
|
|
|
|
|
|
function router() { |
|
|
|
|
|
return ( |
|
|
|
|
|
<BrowserRouter> |
|
|
|
|
|
<Routes> |
|
|
|
|
|
{routes.map((item) => { |
|
|
|
|
|
return ( |
|
|
|
|
|
<Route |
|
|
|
|
|
key={item.id} |
|
|
|
|
|
path={item.path} |
|
|
|
|
|
element={<item.component/>} |
|
|
|
|
|
/> |
|
|
|
|
|
); |
|
|
|
|
|
})} |
|
|
|
|
|
</Routes> |
|
|
|
|
|
</BrowserRouter> |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return <Suspense fallback="loading"> |
|
|
|
|
|
<Switch> |
|
|
|
|
|
{ |
|
|
|
|
|
routes.map(route => { |
|
|
|
|
|
if (route.redirect) { |
|
|
|
|
|
return <Route key={route.path} |
|
|
|
|
|
path={route.path} |
|
|
|
|
|
exact={route.exact} |
|
|
|
|
|
> |
|
|
|
|
|
<Redirect to={route.redirect}/> |
|
|
|
|
|
</Route> |
|
|
|
|
|
} else { |
|
|
|
|
|
return <Route key={route.path} |
|
|
|
|
|
path={route.path} |
|
|
|
|
|
exact={route.exact} |
|
|
|
|
|
component={route.component} |
|
|
|
|
|
> |
|
|
|
|
|
|
|
|
|
|
|
</Route> |
|
|
|
|
|
} |
|
|
|
|
|
})} |
|
|
|
|
|
</Switch> |
|
|
|
|
|
</Suspense> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// routes.map((item, index) => {
|
|
|
|
|
|
// return (
|
|
|
|
|
|
// <Routes key={item.id}>
|
|
|
|
|
|
// <Route key={index} path={item.path} />
|
|
|
|
|
|
// </Routes>
|
|
|
|
|
|
// )
|
|
|
|
|
|
// })
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export default RouterView |
|
|
|
|
|
|
|
|
|
|
|
{/* <Routes key={item.id}></Routes> */ } |
|
|
|
|
|
|
|
|
export default router; |