import Layout from '@/layout/index.vue'
import Home from '@/views/dashboard/index.vue'
import System from './modules/system.js'

export const basicRoutes = [
  {
    path: '/login',
    title: 'Login',
    component: () => import('@/views/login/index.vue'),
    isHidden: true,
    meta: {
      title: '登录页'
    }
  },
  {
    path: '/',
    title: '控制台',
    component: Layout,
    redirect: '/home',
    meta: {
      title: '控制台'
    },
    children: [
      {
        path: 'home',
        title: 'Home',
        component: Home,
        meta: {
          title: '首页',
          affix: true
        }
      }
    ]
  },
  ...System
]

export const NOT_FOUND_ROUTE = {
  title: 'NOT_FOUND',
  path: '/:pathMatch(.*)*',
  redirect: '/404',
  isHidden: true
}

export const REDIRECT_ROUTE = {
  path: '/redirect',
  title: 'Redirect',
  component: Layout,
  meta: {
    title: 'Redirect',
    hideBreadcrumb: true
  },
  children: [
    {
      path: '/redirect/:path(.*)',
      name: 'Redirect',
      component: () => import('@/views/redirect/index.vue'),
      meta: {
        title: 'Redirect',
        hideBreadcrumb: true
      }
    }
  ]
}

const modules = import.meta.globEager('./modules/*.js')
const asyncRoutes = []
Object.keys(modules).forEach((key) => {
  asyncRoutes.push(...modules[key].default)
})

export { asyncRoutes }
