Breadcrumbs.vue 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <template>
  2. <v-breadcrumbs :items="items" />
  3. </template>
  4. <script setup lang="ts">
  5. import { computed } from '@vue/reactivity'
  6. import type { ComputedRef } from '@vue/reactivity'
  7. import type { AnyJson } from '~/types/data'
  8. import { useI18n } from 'vue-i18n'
  9. import UrlUtils from '~/services/utils/urlUtils'
  10. const runtimeConfig = useRuntimeConfig()
  11. const i18n = useI18n()
  12. const router = useRouter()
  13. const items: ComputedRef<Array<AnyJson>> = computed(() => {
  14. const crumbs: Array<AnyJson> = []
  15. const baseUrl =
  16. runtimeConfig.baseUrlAdminLegacy ??
  17. runtimeConfig.public.baseUrlAdminLegacy
  18. crumbs.push({
  19. title: i18n.t('welcome'),
  20. href: UrlUtils.join(baseUrl, '#', 'dashboard'),
  21. })
  22. const pathPart: Array<string> = UrlUtils.split(router.currentRoute.value.path)
  23. let path: string = ''
  24. pathPart.forEach((part) => {
  25. path = UrlUtils.join(path, part)
  26. let match
  27. match = router.resolve(path)
  28. if (match.name) {
  29. crumbs.push({
  30. title: !parseInt(part, 10)
  31. ? i18n.t(part + '_breadcrumbs')
  32. : i18n.t('item'),
  33. exact: true,
  34. to: path,
  35. })
  36. }
  37. })
  38. return crumbs
  39. })
  40. </script>
  41. <style scoped lang="scss">
  42. :deep(a.v-breadcrumbs-item--disabled) {
  43. color: rgb(var(--v-theme-on-neutral)) !important;
  44. opacity: 1 !important;
  45. }
  46. </style>