routes.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import { menuToRoutes, eachTreeData } from 'ele-admin';
  2. import { HOME_PATH, LAYOUT_PATH, REDIRECT_PATH } from '@/config/setting';
  3. import EleLayout from '@/layout/index.vue';
  4. import RedirectLayout from '@/components/RedirectLayout';
  5. import { iframeMixins } from '@/utils/iframe-mixin';
  6. /**
  7. * 静态路由
  8. */
  9. export const routes = [
  10. {
  11. path: '/login',
  12. component: () => import('@/views/login/index.vue'),
  13. meta: { title: '登录' }
  14. },
  15. {
  16. path: '/forget',
  17. component: () => import('@/views/forget/index.vue'),
  18. meta: { title: '忘记密码' }
  19. },
  20. {
  21. path: '/singleLogin',
  22. component: () => import('@/views/singleLogin/index.vue'),
  23. meta: { title: '登录' }
  24. },
  25. {
  26. path: '/print',
  27. component: () => import('@/views/produceOrder/print.vue'),
  28. meta: { title: '工艺流程卡' }
  29. },
  30. {
  31. path: '/printJuren',
  32. component: () => import('@/views/produce/components/juRenPack.vue'),
  33. meta: { title: '打印条码' }
  34. },
  35. {
  36. path: '/printJuRenOne',
  37. component: () => import('@/views/produce/components/juRenPackOne.vue'),
  38. meta: { title: '打印条码' }
  39. }
  40. // 404
  41. // {
  42. // path: '*',
  43. // component: () => import('@/views/exception/404/index.vue')
  44. // }
  45. // {
  46. // path: '/system/role',
  47. // component: () => import('@/views/system/role/index.vue'),
  48. // meta: { title: '编码信息' }
  49. // }
  50. ];
  51. /**
  52. * 添加动态路由
  53. * @param menus 菜单数据
  54. * @param homePath 菜单数据的第一个页面地址
  55. */
  56. export function getMenuRoutes(menus, homePath) {
  57. const routes = [
  58. // 用于刷新的路由
  59. {
  60. path: REDIRECT_PATH + '/:path(.*)',
  61. component: RedirectLayout,
  62. meta: { hideFooter: true }
  63. }
  64. ];
  65. // 路由铺平处理
  66. eachTreeData(
  67. menuToRoutes(menus, getComponent, [], null, null, iframeMixins),
  68. (route) => {
  69. routes.push({ ...route, children: null });
  70. }
  71. );
  72. return {
  73. path: LAYOUT_PATH,
  74. component: EleLayout,
  75. redirect: HOME_PATH ?? homePath,
  76. children: routes
  77. };
  78. }
  79. /**
  80. * 获取路由组件
  81. * @param component 组件名称
  82. */
  83. function getComponent(component) {
  84. if (component) {
  85. return () => import('@/views/' + component);
  86. }
  87. }