import React from 'react';
import { Router, Route, Redirect } from 'dva/router';
import { LocaleProvider } from 'antd';
import zhCN from 'antd/lib/locale-provider/zh_CN';
import navData from './common/nav';
function getRoutes(data, level = 0) {
return data.map((item, i) => {
let children;
if (item.children) {
children = getRoutes(item.children, level + 1);
}
let homePageRedirect;
if (level === 1 && i === 0) {
let indexPath;
// First children router
if (item.children && item.children[0]) {
indexPath = `/${item.path}/${item.children[0].path}`;
} else {
indexPath = item.path;
}
homePageRedirect = ;
}
if (item.noRoute) {
return null;
}
return (
{homePageRedirect}
{children}
);
});
}
function RouterConfig({ history }) {
return (
{getRoutes(navData)}
);
}
export default RouterConfig;