import type { RouteRecordRaw } from 'vue-router';
import ErrorPage from '@/pages/Error/index.vue';
import AppLayout from '@/layouts/app/index.vue';

export enum EnumPage {
  App = '/app',
  Login = '/login',
  Error = '/error'
}
export const RootRoute: RouteRecordRaw = {
  path: '/',
  name: 'Root',
  redirect: EnumPage.App
}

export const AppRoute: RouteRecordRaw = {
  path: EnumPage.App,
  name: 'App',
  redirect: '/app/home',
  component: AppLayout,
  children: [
    {
      path: 'home',
      name: 'Home',
      component: () => import('@/pages/Home/index.vue'),
      meta: {
        title: '首页'
      }
    }
  ]
}

export const LoginRoute: RouteRecordRaw = {
  path: EnumPage.Login,
  name: 'Login',
  component: () => import('@/pages/Login/index.vue'),
  meta: {
    title: '登录页'
  }
}

export const ErrorRoute: RouteRecordRaw = {
  path: EnumPage.Error,
  name: 'Error',
  component: ErrorPage,
  meta: {
    title: '异常页'
  }
}

export const NotFoundRoute: RouteRecordRaw = {
  path: '/:notFound(.*)*',
  name: 'NotFound',
  redirect: '/error'
}

export const baseRoutes: RouteRecordRaw[] = [
  RootRoute,
  AppRoute,
  LoginRoute,
  ErrorRoute
]
