You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.3 KiB
54 lines
1.3 KiB
import { BrowserRouter as Router, Switch, Redirect, Route, Link } from "react-router-dom"
|
|
import React, { Fragment } from "react"
|
|
|
|
import { pageList } from "@/plugins/pageHoc"
|
|
|
|
import Layout from "@/views/Layout"
|
|
|
|
import Auth from "@/ui/Auth"
|
|
import routes from "./route"
|
|
|
|
function RouteMap(props: any) {
|
|
const routes: any[] = props.routes
|
|
return (
|
|
<Switch>
|
|
{routes.map((route, index) => {
|
|
console.log(route.path, route.exact)
|
|
|
|
const { exact = false } = route
|
|
if (route.redirect) {
|
|
return (
|
|
<Route key={index} path={route.path} exact={exact}>
|
|
<Redirect to={route.redirect}></Redirect>
|
|
</Route>
|
|
)
|
|
}
|
|
if (route.component) {
|
|
return (
|
|
<Auth key={index} needAuth={!!route.meta?.auth} path={route.path} exact={exact}>
|
|
<route.component>{route.children && <RouteMap routes={route.children}></RouteMap>}</route.component>
|
|
</Auth>
|
|
)
|
|
}
|
|
})}
|
|
</Switch>
|
|
)
|
|
}
|
|
|
|
export default function () {
|
|
console.log(pageList)
|
|
|
|
return (
|
|
<Router>
|
|
{/* <Switch> */}
|
|
<Layout
|
|
render={() => {
|
|
return (
|
|
<RouteMap routes={routes}></RouteMap>
|
|
)
|
|
}}
|
|
></Layout>
|
|
{/* </Switch> */}
|
|
</Router>
|
|
)
|
|
}
|
|
|