Breadcrumbs.vue 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 items: ComputedRef<Array<AnyJson>> = computed(() => {
  14. const crumbs: Array<AnyJson> = []
  15. const baseUrl =
  16. runtimeConfig.baseUrlAdminLegacy ?? runtimeConfig.public.baseUrlAdminLegacy
  17. crumbs.push({
  18. title: i18n.t('welcome'),
  19. href: UrlUtils.join(baseUrl, '#', 'dashboard'),
  20. })
  21. const pathPart: Array<string> = UrlUtils.split(router.currentRoute.value.path)
  22. let path: string = ''
  23. pathPart.forEach((part) => {
  24. path = UrlUtils.join(path, part)
  25. let match
  26. match = router.resolve(path)
  27. if (match.name) {
  28. crumbs.push({
  29. title: !parseInt(part, 10)
  30. ? i18n.t(part + '_breadcrumbs')
  31. : i18n.t('item'),
  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>