import React from 'react'
import { LocaleProvider } from 'antd'
import { Router, Route, Switch } from 'dva/router'
import MainLayout from './mainLayout'
import ChartDesigner from '../components/chartDesigner/layout'
import DashboardDesigner from '../components/dashboardDesigner/layout'
// 由于 antd 组件的默认文案是英文，所以需要修改为中文
import zhCN from 'antd/lib/locale-provider/zh_CN'

function RouterConfig({ history }) {
  return (
    <LocaleProvider locale={zhCN}>
      <Router history={history}>
        <Switch>
          <Route sensitive path='/chart/:code' component={ChartDesigner}/>
          <Route sensitive path='/dashboard/:id/' component={DashboardDesigner}/>
          <Route path='/' component={MainLayout}/>
        </Switch>
      </Router>
    </LocaleProvider>
  );
}

export default RouterConfig;
