import { createRouter, createWebHistory } from 'vue-router'
import Layout from '@/layout/index.vue'
import ModelManageRoute from './modules/tables'
import BimAnalysisRoute from './modules/bimAnalysis'
import StatisticsRoute from './modules/statistics'

const constantRoutes: any[] = [
  {
    path: '/login',
    meta: {
      title: '登录',
      hidden: true
    },
    component: () => import('@/views/login/index.vue')
  },
  {
    path: '/',
    component: Layout,
    redirect: '/modelManage',
    meta: {
      title: '首页'
    },
    children: [
      {
        path: '/index',
        name: 'Index',
        component: () =>
          import(/* webpackChunkName: "home" */ '@/views/index.vue'),
        meta: {
          title: '首页',
          icon: 'home'
        }
      }
    ]
  },
  {
    path: '/noFound',
    name: 'NoFound',
    component: () =>
      import(/* webpackChunkName: "noFound" */ '@/views/404.vue'),
    meta: {
      title: '404',
      hidden: true
    }
  },
  {
    path: '/:pathMatch(.*)*',
    name: 'not-found',
    component: () =>
      import(/* webpackChunkName: "noFound" */ '@/views/404.vue'),
    meta: {
      title: 'not-found',
      hidden: true
    }
  }
]
const asyncRoutes: any[] = [ModelManageRoute, BimAnalysisRoute, StatisticsRoute]

const history = createWebHistory('a')
const router = createRouter({
  history,
  routes: [...constantRoutes, ...asyncRoutes]
})

export default router
