Breadcrumbs.vue 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. const match = router.resolve(path)
  26. if (match.name) {
  27. crumbs.push({
  28. title: i18n.t(match.name + '_breadcrumbs'),
  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>