Breadcrumbs.vue 1.2 KB

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