index.vue 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <script lang="ts" setup>
  2. import { useRoutesStore } from '@/store/modules/routes'
  3. import { translate } from '@/i18n'
  4. import { handleMatched } from '@/utils/routes'
  5. import { VabRoute } from '/#/router'
  6. const route: VabRoute = useRoute()
  7. const routesStore = useRoutesStore()
  8. const { getRoutes: routes } = storeToRefs(routesStore)
  9. const breadcrumbList = computed(() =>
  10. handleMatched(routes.value, route.path).filter(
  11. (item: any) => !item.meta.breadcrumbHidden
  12. )
  13. )
  14. const handleTo = (path: string | undefined = '') => {
  15. return { path }
  16. }
  17. </script>
  18. <template>
  19. <el-breadcrumb class="vab-breadcrumb" separator=">">
  20. <el-breadcrumb-item
  21. v-for="(item, index) in breadcrumbList"
  22. :key="index"
  23. :to="handleTo(item.redirect)"
  24. >
  25. <vab-icon
  26. v-if="item.meta.icon"
  27. :icon="item.meta.icon"
  28. :is-custom-svg="item.meta.isCustomSvg"
  29. />
  30. <span v-if="item.meta.title">{{ translate(item.meta.title) }}</span>
  31. </el-breadcrumb-item>
  32. </el-breadcrumb>
  33. </template>
  34. <style lang="scss" scoped>
  35. .vab-breadcrumb {
  36. height: $base-nav-height;
  37. font-size: $base-font-size-default;
  38. line-height: $base-nav-height;
  39. :deep() {
  40. .el-breadcrumb__item {
  41. .el-breadcrumb__inner {
  42. font-weight: normal;
  43. color: #515a6e;
  44. i,
  45. svg {
  46. margin-right: 3px;
  47. }
  48. }
  49. &:last-child {
  50. .el-breadcrumb__inner {
  51. a {
  52. color: #999;
  53. }
  54. }
  55. }
  56. }
  57. }
  58. }
  59. </style>