index.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Copyright (C) 2012-2021 Zammad Foundation, https://zammad-foundation.org/
  2. import type { RouteRecordRaw } from 'vue-router'
  3. import Login from '@mobile/views/Login.vue'
  4. import Error from '@mobile/views/Error.vue'
  5. import LayoutMain from '@mobile/components/layout/LayoutMain.vue'
  6. import type { ImportGlobEagerDefault } from '@common/types/utils'
  7. const routeModules = import.meta.globEager('./routes/*.ts')
  8. const mainRoutes: Array<RouteRecordRaw> = []
  9. Object.values(routeModules).forEach((module: ImportGlobEagerDefault) => {
  10. const defaultExport = module.default as RouteRecordRaw | Array<RouteRecordRaw>
  11. if (Array.isArray(defaultExport)) {
  12. mainRoutes.push(...defaultExport)
  13. } else {
  14. mainRoutes.push(defaultExport)
  15. }
  16. })
  17. const routes: Array<RouteRecordRaw> = [
  18. {
  19. path: '/login',
  20. name: 'Login',
  21. props: true,
  22. component: Login,
  23. meta: {
  24. title: __('Sign in'),
  25. requiresAuth: false,
  26. requiredPermission: null,
  27. },
  28. },
  29. {
  30. path: '/error',
  31. alias: '/:pathMatch(.*)*',
  32. name: 'Error',
  33. props: true,
  34. component: Error,
  35. meta: {
  36. requiresAuth: false,
  37. requiredPermission: null,
  38. },
  39. },
  40. {
  41. path: '/',
  42. props: true,
  43. component: LayoutMain,
  44. children: mainRoutes,
  45. },
  46. ]
  47. export default routes