import { HashRouter as Router, Route } from 'react-router-dom';
import { Routes } from 'react-router-dom';
import { ConfigProvider } from 'antd';
import zhCN from 'antd/locale/zh_CN';
import mainRoutes from './mainRoute';
import debugRoutes from './debugRoute';

//定义的路由函数直接挂载到主页面上去
const HRoutes = function () {
  let allRoutes;

  if (process.env.NODE_ENV === 'development') {
    allRoutes = mainRoutes.concat(debugRoutes);
  } else {
    allRoutes = mainRoutes;
  }
  return (
    <ConfigProvider locale={zhCN}>
      <Router>
        <Routes>
          {allRoutes.map((item, index) => {
            return (
              <Route
                key={index}
                path={item.path}
                element={item.component}></Route>
            );
          })}
        </Routes>
      </Router>
    </ConfigProvider>
  );
};
export default HRoutes;
