routes.ts 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. import type { Route } from '#/global'
  2. import type { RouteRecordRaw } from 'vue-router'
  3. import generatedRoutes from 'virtual:generated-pages'
  4. import { setupLayouts } from 'virtual:meta-layouts'
  5. import RoleManagement from './modules/role'
  6. import VoiceManagement from './modules/voice'
  7. import Recomendation from './modules/recomendation'
  8. import Model from './modules/model'
  9. function Layout() {
  10. return import('@/layouts/index.vue')
  11. }
  12. // 固定路由(默认路由)
  13. const constantRoutes: RouteRecordRaw[] = [
  14. {
  15. path: '/login',
  16. name: 'login',
  17. component: () => import('@/views/login.vue'),
  18. meta: {
  19. title: '登录',
  20. },
  21. },
  22. {
  23. path: '/:all(.*)*',
  24. name: 'notFound',
  25. component: () => import('@/views/[...all].vue'),
  26. meta: {
  27. title: '找不到页面',
  28. },
  29. },
  30. ]
  31. // 系统路由
  32. const systemRoutes: RouteRecordRaw[] = [
  33. {
  34. path: '/',
  35. component: () => import('@/layouts/index.vue'),
  36. meta: {
  37. title: () => useSettingsStore().settings.home.title,
  38. breadcrumb: false,
  39. },
  40. children: [
  41. {
  42. path: '',
  43. component: () => import('@/views/index.vue'),
  44. meta: {
  45. title: () => useSettingsStore().settings.home.title,
  46. icon: 'i-ant-design:home-twotone',
  47. breadcrumb: false,
  48. },
  49. },
  50. {
  51. path: 'reload',
  52. name: 'reload',
  53. component: () => import('@/views/reload.vue'),
  54. meta: {
  55. title: '重新加载',
  56. breadcrumb: false,
  57. },
  58. },
  59. ],
  60. },
  61. ]
  62. // 动态路由(异步路由、导航栏路由)
  63. const asyncRoutes: Route.recordMainRaw[] = [
  64. {
  65. meta: {
  66. title: 'Managerment',
  67. icon: 'i-ep:grid',
  68. auth: '',
  69. },
  70. children: [
  71. RoleManagement,
  72. VoiceManagement,
  73. Recomendation,
  74. ],
  75. },
  76. {
  77. meta: {
  78. title: '大模型',
  79. icon: 'i-hugeicons:brain-02',
  80. },
  81. children: [
  82. Model,
  83. ],
  84. },
  85. ]
  86. const constantRoutesByFilesystem = generatedRoutes.filter((item) => {
  87. return item.meta?.enabled !== false && item.meta?.constant === true
  88. })
  89. const asyncRoutesByFilesystem = setupLayouts(generatedRoutes.filter((item) => {
  90. return item.meta?.enabled !== false && item.meta?.constant !== true && item.meta?.layout !== false
  91. }))
  92. export {
  93. asyncRoutes,
  94. asyncRoutesByFilesystem,
  95. constantRoutes,
  96. constantRoutesByFilesystem,
  97. systemRoutes,
  98. }