import Layout from '@/layout/index.vue'
import Home from '@/views/dashboard/index.vue'

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

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

export const REDIRECT_ROUTE = {
  path: '/redirect',
  title: 'Redirect',
  component: Layout,
  meta: {
    title: 'Redirect',
    hideBreadcrumb: true,
    hideChild: 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 }
