router.js 866 Bytes
Newer Older
1
import React from 'react';
afc163's avatar
afc163 committed
2
import { Router, Route, Switch } from 'dva/router';
afc163's avatar
afc163 committed
3 4
import { LocaleProvider } from 'antd';
import zhCN from 'antd/lib/locale-provider/zh_CN';
WhatAKitty's avatar
WhatAKitty committed
5 6 7 8 9
import dynamic from 'dva/dynamic';

function RouterConfig({ history, app }) {
  const BasicLayout = dynamic({
    app,
WhatAKitty's avatar
WhatAKitty committed
10 11 12
    models: () => [
      import('./models/user'),
    ],
WhatAKitty's avatar
WhatAKitty committed
13 14 15 16 17 18
    component: () => import('./layouts/BasicLayout'),
  });
  const UserLayout = dynamic({
    app,
    component: () => import('./layouts/UserLayout'),
  });
19 20

  return (
afc163's avatar
afc163 committed
21 22
    <LocaleProvider locale={zhCN}>
      <Router history={history}>
ddcat1115's avatar
ddcat1115 committed
23
        <Switch>
WhatAKitty's avatar
WhatAKitty committed
24 25
          <Route path="/user" render={props => <UserLayout {...props} app={app} />} />
          <Route path="/" render={props => <BasicLayout {...props} app={app} />} />
ddcat1115's avatar
ddcat1115 committed
26
        </Switch>
afc163's avatar
afc163 committed
27 28
      </Router>
    </LocaleProvider>
29 30 31 32
  );
}

export default RouterConfig;