Breadcrumbs.vue 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <template>
  2. <v-breadcrumbs
  3. :items="items"
  4. />
  5. </template>
  6. <script setup lang="ts">
  7. import {computed, ComputedRef} from "@vue/reactivity";
  8. import {AnyJson} from "~/types/data";
  9. import {useI18n} from "vue-i18n";
  10. import UrlUtils from "~/services/utils/urlUtils";
  11. const runtimeConfig = useRuntimeConfig()
  12. const i18n = useI18n()
  13. const router = useRouter()
  14. const items: ComputedRef<Array<AnyJson>> = computed(() => {
  15. const crumbs:Array<AnyJson> = []
  16. crumbs.push({
  17. title: i18n.t('welcome'),
  18. href: runtimeConfig.baseUrlAdminLegacy
  19. })
  20. const pathPart: Array<string> = UrlUtils.split(router.currentRoute.value.path)
  21. let path: string = ''
  22. pathPart.forEach((part) => {
  23. path = `${path}/${part}`
  24. const match = router.resolve(path)
  25. if (match.name !== null) {
  26. crumbs.push({
  27. title: !parseInt(part, 10) ? i18n.t(part + '_breadcrumbs') : i18n.t('item'),
  28. exact: true,
  29. to: path
  30. })
  31. }
  32. })
  33. return crumbs
  34. })
  35. </script>
  36. <style scoped lang="scss">
  37. :deep(a.v-breadcrumbs-item--disabled) {
  38. color: rgb(var(--v-theme-on-neutral)) !important;
  39. opacity: 1 !important;
  40. }
  41. </style>