Commit 04367773 authored by Ethan_Wan's avatar Ethan_Wan Committed by 陈帅

feat: instead of dva/dynamic using react-loadable

parent f2b99a12
import React from 'react'; import React from 'react';
import { routerRedux, Route, Switch } from 'dva/router'; import { routerRedux, Route, Switch } from 'dva/router';
import { Spin } from 'antd';
import dynamic from 'dva/dynamic';
import { getRouterData } from './common/router'; import { getRouterData } from './common/router';
import Authorized from './utils/Authorized'; import Authorized from './utils/Authorized';
import { getQueryPath } from './utils/utils'; import { getQueryPath } from './utils/utils';
import { LocalComponent } from './locale/localeContext';
import styles from './index.less';
const { ConnectedRouter } = routerRedux; const { ConnectedRouter } = routerRedux;
const { AuthorizedRoute } = Authorized; const { AuthorizedRoute } = Authorized;
dynamic.setDefaultLoadingComponent(() => {
return <Spin size="large" className={styles.globalSpin} />;
});
function RouterConfig({ history, app }) { function RouterConfig({ history, app }) {
const routerData = getRouterData(app); const routerData = getRouterData(app);
const UserLayout = routerData['/user'].component; const UserLayout = routerData['/user'].component;
const BasicLayout = routerData['/'].component; const BasicLayout = routerData['/'].component;
return ( return (
<LocalComponent>
<ConnectedRouter history={history}> <ConnectedRouter history={history}>
<Switch> <Switch>
<Route path="/user" component={UserLayout} /> <Route path="/user" component={UserLayout} />
...@@ -33,7 +25,6 @@ function RouterConfig({ history, app }) { ...@@ -33,7 +25,6 @@ function RouterConfig({ history, app }) {
/> />
</Switch> </Switch>
</ConnectedRouter> </ConnectedRouter>
</LocalComponent>
); );
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment