import { Navigate } from 'react-router-dom';
import { lazyLoad, authComponent } from './lazyLoadAndDelay'; // 添加一个固定的延迟时间，以便你可以看到加载状态

import Layout from '@/layout/index';
import UserModule from '@/pages/user-module';
import UserLogin from '@/pages/user-module/login';

import UserInfo from '@/pages/user-module/userInfo';

import NotFound from '@/common/notFound';
import notPermission from '@/common/notPermission';

const baseRouter = [
  {
    path: '/',
    key: 'layout',
    element: authComponent(Layout),
    meta: {
      title: '控制台',
    },
    children: [
      { path: '/userinfo', element: lazyLoad(UserInfo) },
      // { path: '*', element: lazyLoad(notPermission) },
    ],
  },
  {
    path: '/user',
    key: 'user',
    element: lazyLoad(UserModule),
    hidden: true,
    meta: {
      title: '用户',
    },
    children: [
      {
        index: true,
        element: <Navigate to='/user/login' />,
      },
      {
        path: '/user/login',
        element: lazyLoad(UserLogin),
      },
    ],
  },
  {
    path: '/404',
    key: '404',
    hidden: true,
    element: lazyLoad(NotFound),
    meta: {},
  },
  // { path: '*', hidden: true, element: <Navigate to='/404' /> },
];

export default baseRouter;
