Breadcrumbs.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. crumbs.push({
  16. title: i18n.t('welcome'),
  17. href: UrlUtils.join(runtimeConfig.baseUrlAdminLegacy, '#', 'dashboard'),
  18. })
  19. const pathPart: Array<string> = UrlUtils.split(router.currentRoute.value.path)
  20. let path: string = ''
  21. pathPart.forEach((part) => {
  22. path = UrlUtils.join(path, part)
  23. let match
  24. match = router.resolve(path)
  25. if (match.name) {
  26. crumbs.push({
  27. title: !parseInt(part, 10)
  28. ? i18n.t(part + '_breadcrumbs')
  29. : i18n.t('item'),
  30. exact: true,
  31. to: path,
  32. })
  33. }
  34. })
  35. return crumbs
  36. })
  37. </script>
  38. <style scoped lang="scss">
  39. :deep(a.v-breadcrumbs-item--disabled) {
  40. color: rgb(var(--v-theme-on-neutral)) !important;
  41. opacity: 1 !important;
  42. }
  43. </style>