Breadcrumbs.vue 1.3 KB

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