Breadcrumbs.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <template>
  2. <v-breadcrumbs
  3. :items="items"
  4. />
  5. </template>
  6. <script setup lang="ts">
  7. import {computed} from "@vue/reactivity";
  8. import type {ComputedRef} from "@vue/reactivity";
  9. import type {AnyJson} from "~/types/data";
  10. import {useI18n} from "vue-i18n";
  11. import UrlUtils from "~/services/utils/urlUtils";
  12. const runtimeConfig = useRuntimeConfig()
  13. const i18n = useI18n()
  14. const router = useRouter()
  15. const items: ComputedRef<Array<AnyJson>> = computed(() => {
  16. const crumbs:Array<AnyJson> = []
  17. crumbs.push({
  18. title: i18n.t('welcome'),
  19. href: UrlUtils.join(runtimeConfig.baseUrlAdminLegacy, '#', '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) ? i18n.t(part + '_breadcrumbs') : 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>