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.
40 lines
1.3 KiB
40 lines
1.3 KiB
import React from 'react';
|
|
import { routerRedux, Route, Switch } from 'dva/router';
|
|
import { Spin } from 'antd';
|
|
import dynamic from 'dva/dynamic';
|
|
import { getRouterData } from './common/router';
|
|
import Authorized from './utils/Authorized';
|
|
import { getQueryPath } from './utils/utils';
|
|
import { LocalComponent } from './locale/localeContext';
|
|
import styles from './index.less';
|
|
|
|
const { ConnectedRouter } = routerRedux;
|
|
const { AuthorizedRoute } = Authorized;
|
|
dynamic.setDefaultLoadingComponent(() => {
|
|
return <Spin size="large" className={styles.globalSpin} />;
|
|
});
|
|
|
|
function RouterConfig({ history, app }) {
|
|
const routerData = getRouterData(app);
|
|
const UserLayout = routerData['/user'].component;
|
|
const BasicLayout = routerData['/'].component;
|
|
return (
|
|
<LocalComponent>
|
|
<ConnectedRouter history={history}>
|
|
<Switch>
|
|
<Route path="/user" component={UserLayout} />
|
|
<AuthorizedRoute
|
|
path="/"
|
|
render={props => <BasicLayout {...props} />}
|
|
authority={['admin', 'user']}
|
|
redirectPath={getQueryPath('/user/login', {
|
|
redirect: window.location.href,
|
|
})}
|
|
/>
|
|
</Switch>
|
|
</ConnectedRouter>
|
|
</LocalComponent>
|
|
);
|
|
}
|
|
|
|
export default RouterConfig;
|
|
|