import { createRouter, createWebHistory } from 'vue-router';
import Layout from '@/layouts/index.vue';

import demoRouters from './modules/demo';

export const constantRoutes = [
  // {
  //   path: '/404',
  //   name: '404',
  //   component: () => import('@/views/error/404.vue'),
  //   hidden: true,
  // },
  // {
  //   path: '/403',
  //   name: '403',
  //   component: () => import('@/views/error/403.vue'),
  //   hidden: true,
  // },
  {
    path: '/',
    name: 'layout',
    component: Layout,
    redirect: '/home',
    meta: { title: '首页', icon: 'House' },
    children: [
      {
        path: '/home',
        component: () => import('@/views/home/index.vue'),
        name: 'home',
        meta: { title: '首页', icon: 'House' },
      },
      {
        path: '/land',
        component: () => import('@/views/land/index.vue'),
        name: 'land',
        meta: { title: '土地资源', icon: 'House' },
      },
      {
        path: '/inputs',
        name: 'inputs',
        component: () => import('@/views/inputs/index.vue'),
        hidden: true,
      },
      {
        path: '/entities',
        name: 'entities',
        component: () => import('@/views/entities/index.vue'),
        hidden: true,
      },
      {
        path: '/breed',
        name: 'breed',
        component: () => import('@/views/breed/index.vue'),
        hidden: true,
      },
      {
        path: '/plant',
        name: 'plant',
        component: () => import('@/views/plant/index.vue'),
        hidden: true,
      },
      {
        path: '/trace',
        name: 'trace',
        component: () => import('@/views/trace/index.vue'),
        hidden: true,
      },
      {
        path: '/early',
        name: 'early',
        component: () => import('@/views/early/index.vue'),
        hidden: true,
      },
    ],
  },
  ...demoRouters,
  {
    path: '/test',
    name: 'test',
    component: () => import('@/views/test/index.vue'),
    hidden: true,
  },
];

/**
 * @Title notFoundRouter(找不到路由)
 */
export const notFoundRouter = {
  path: '/:pathMatch(.*)',
  name: 'notFound',
  redirect: '/404',
};

const router = createRouter({
  history: createWebHistory(),
  routes: constantRoutes,
});

export default router;
