index.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <template>
  2. <el-breadcrumb class="vab-breadcrumb" separator="/">
  3. <el-breadcrumb-item v-for="(item, index) in breadcrumbList" :key="index" :to="handleTo(item.redirect)">
  4. <vab-icon v-if="item.meta && item.meta.icon" :icon="item.meta.icon" />
  5. <span>{{ translate(item.meta.title) }}</span>
  6. </el-breadcrumb-item>
  7. </el-breadcrumb>
  8. </template>
  9. <script lang="ts" setup>
  10. import { translate } from '/@/i18n'
  11. import { useRoutesStore } from '/@/store/modules/routes'
  12. import { handleMatched } from '/@/utils/routes'
  13. defineOptions({
  14. name: 'VabBreadcrumb',
  15. })
  16. const route = useRoute()
  17. const routesStore = useRoutesStore()
  18. const { getBreadcrumbRoutes: breadcrumbRoutes } = storeToRefs(routesStore)
  19. const breadcrumbList = computed(() => {
  20. const matchedRoutes = handleMatched(breadcrumbRoutes.value, route.fullPath).filter((item) => !item.meta.breadcrumbHidden)
  21. if (matchedRoutes.length > 0) return matchedRoutes
  22. else return handleMatched(breadcrumbRoutes.value, route.path).filter((item) => !item.meta.breadcrumbHidden)
  23. })
  24. const handleTo = (path: any) => {
  25. if (path) return { path }
  26. }
  27. </script>
  28. <style lang="scss" scoped>
  29. .vab-breadcrumb {
  30. display: flex;
  31. align-items: center;
  32. justify-content: center;
  33. height: var(--el-nav-height);
  34. :deep() {
  35. .el-breadcrumb__item {
  36. .el-breadcrumb__inner {
  37. font-weight: normal;
  38. }
  39. }
  40. }
  41. }
  42. </style>