routes.ts 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. import type { Route } from '#/global'
  2. import type { RouteRecordRaw } from 'vue-router'
  3. import useSettingsStore from '@/store/modules/settings'
  4. import generatedRoutes from 'virtual:generated-pages'
  5. import { setupLayouts } from 'virtual:meta-layouts'
  6. import organizationManagement from './modules/organization'
  7. import personnel from './modules/personnel'
  8. // 固定路由(默认路由)
  9. const constantRoutes: RouteRecordRaw[] = [
  10. {
  11. path: '/login',
  12. name: 'login',
  13. component: () => import('@/views/login.vue'),
  14. meta: {
  15. title: '登录',
  16. },
  17. },
  18. {
  19. path: '/:all(.*)*',
  20. name: 'notFound',
  21. component: () => import('@/views/[...all].vue'),
  22. meta: {
  23. title: '找不到页面',
  24. },
  25. },
  26. ]
  27. // 系统路由
  28. const systemRoutes: RouteRecordRaw[] = [
  29. {
  30. path: '/',
  31. component: () => import('@/layouts/index.vue'),
  32. meta: {
  33. title: () => useSettingsStore().settings.home.title,
  34. breadcrumb: false,
  35. },
  36. children: [
  37. {
  38. path: '',
  39. component: () => import('@/views/index.vue'),
  40. meta: {
  41. title: () => useSettingsStore().settings.home.title,
  42. icon: 'i-ant-design:home-twotone',
  43. breadcrumb: false,
  44. },
  45. },
  46. {
  47. path: 'reload',
  48. name: 'reload',
  49. component: () => import('@/views/reload.vue'),
  50. meta: {
  51. title: '重新加载',
  52. breadcrumb: false,
  53. },
  54. },
  55. ],
  56. },
  57. ]
  58. // 动态路由(异步路由、导航栏路由)
  59. const asyncRoutes: Route.recordMainRaw[] = [
  60. {
  61. meta: {
  62. title: '组织架构',
  63. icon: 'i-uim:box',
  64. },
  65. children: [
  66. personnel
  67. ],
  68. },
  69. {
  70. meta: {
  71. title: '租户管理',
  72. icon: 'i-uim:box',
  73. },
  74. children: [
  75. organizationManagement
  76. ],
  77. },
  78. {
  79. meta: {
  80. title: '租户运营',
  81. icon: 'i-uim:box',
  82. },
  83. children: [
  84. ],
  85. },
  86. {
  87. meta: {
  88. title: '数据中心',
  89. icon: 'i-uim:box',
  90. },
  91. children: [
  92. ],
  93. },
  94. {
  95. meta: {
  96. title: '增值服务',
  97. icon: 'i-uim:box',
  98. },
  99. children: [
  100. ],
  101. },
  102. {
  103. meta: {
  104. title: '基础设置',
  105. icon: 'i-uim:box',
  106. },
  107. children: [
  108. ],
  109. },
  110. ]
  111. const constantRoutesByFilesystem = generatedRoutes.filter((item) => {
  112. return item.meta?.enabled !== false && item.meta?.constant === true
  113. })
  114. const asyncRoutesByFilesystem = setupLayouts(generatedRoutes.filter((item) => {
  115. return item.meta?.enabled !== false && item.meta?.constant !== true && item.meta?.layout !== false
  116. }))
  117. export {
  118. asyncRoutes,
  119. asyncRoutesByFilesystem,
  120. constantRoutes,
  121. constantRoutesByFilesystem,
  122. systemRoutes,
  123. }