index.ts 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import { createRouter, createWebHistory } from 'vue-router'
  2. // import HomeView from '@/views/home/index.vue'
  3. import { authGuard } from './guard'
  4. // 自动加载modules目录下的所有路由文件
  5. const moduleRoutes = Object.values(import.meta.glob('./modules/*.ts', { eager: true })).flatMap(
  6. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  7. (module) => (module as { default: any }).default
  8. )
  9. const router = createRouter({
  10. history: createWebHistory(import.meta.env.BASE_URL),
  11. routes: [
  12. // 自动合并所有模块路由
  13. ...moduleRoutes,
  14. {
  15. path: '/',
  16. name: 'home',
  17. // component: HomeView,
  18. // meta: { title: '首页看板', isFullScreen: false, keepAlive: false },
  19. redirect: '/community/list',
  20. meta: { title: '小区管理', isFullScreen: false, keepAlive: false, hidden: true },
  21. },
  22. {
  23. path: '/pointCloud',
  24. name: 'pointCloud',
  25. component: () => import('@/views/pointCloudMap/index.vue'),
  26. meta: { title: '设备点云图', isFullScreen: true, keepAlive: false, hidden: true },
  27. },
  28. {
  29. path: '/dashboard',
  30. name: 'dashboard',
  31. component: () => import('@/views/dashboard/index.vue'),
  32. meta: { title: '大屏', isFullScreen: true, keepAlive: false, hidden: true },
  33. },
  34. ],
  35. })
  36. router.beforeEach(authGuard)
  37. export default router