Breadcrumbs.vue 1.4 KB

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