react+dva2.1 version, how to make a front-end route interceptor
function RouterConfig ({history, app}) {
const routes = [
{
path: "/user",
models: () => [import("./models/user")],
component: () => import("./routes/index"),
},
{
path: "/auth/login",
models: () => [import("./models/auth")],
component: () => import("./routes/auth/Login"),
},
]
return (
)<ConnectedRouter history={history}>
<App>
<Switch>
<Route exact path="/" render={() => (<Redirect to="/index" />)} />
{
routes.map(({ path, ...dynamics }, key) => (
<Route key={key}
exact
path={path}
component={dynamic({
app,
...dynamics,
})}
/>
))
}
</Switch>
</App>
</ConnectedRouter>
)