breadCrumb.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <template>
  2. <div class="topClass">
  3. <div class="contentClass">
  4. <el-breadcrumb separator="/">
  5. <transition-group name="breadcrumb">
  6. <el-breadcrumb-item
  7. v-for="(item, index) in list"
  8. :key="item.path + item.name"
  9. >
  10. <router-link
  11. v-if="!disabledRoutes.includes(item.name)"
  12. @click="console.log(item)"
  13. :to="
  14. item.name !== $route.name
  15. ? item.fullPath
  16. ? item.fullPath
  17. : item.path
  18. ? item.path
  19. : '/'
  20. : $route.fullPath
  21. "
  22. >
  23. <i
  24. class="el-icon-folder-opened"
  25. v-if="index > 1"
  26. ></i>
  27. {{ item.meta.tabname }}
  28. </router-link>
  29. <span v-else style="line-height: 20px">{{
  30. item.meta.tabname
  31. }}</span>
  32. </el-breadcrumb-item>
  33. </transition-group>
  34. </el-breadcrumb>
  35. </div>
  36. <div class="avatarBox">
  37. <!-- <i class="el-icon-switch-button"></i> -->
  38. <img :src="imgSrc" width="100%" height="100%" />
  39. </div>
  40. </div>
  41. </template>
  42. <script>
  43. export default {
  44. name: "breadCrumb",
  45. data() {
  46. return {
  47. disabledRoutes: [
  48. "modelLibrary",
  49. "algorithmsLibrary",
  50. "sceneLibrary",
  51. "systemManagement",
  52. "workManagement",
  53. ], // 相关页面只为占位,页面是空白,无法展示
  54. imgSrc: require("@/assets/common/image/photoF.png"),
  55. };
  56. },
  57. methods: {},
  58. computed: {
  59. list() {
  60. let isMainPage = false;
  61. this.$route.matched.filter((item) => {
  62. if (item.name === this.$route.name) {
  63. item.fullPath = this.$route.fullPath;
  64. }
  65. if (item.name === "mainPage") {
  66. isMainPage = true;
  67. }
  68. });
  69. if (isMainPage) {
  70. return this.$route.matched.slice(0, 1);
  71. } else {
  72. return this.$route.matched;
  73. }
  74. },
  75. },
  76. };
  77. </script>
  78. <style lang="less" scoped>
  79. .topClass {
  80. position: relative;
  81. height: 50px;
  82. line-height: 48px;
  83. border-bottom: 2px solid #f5f7fa;
  84. overflow: hidden;
  85. .contentClass {
  86. // width: 1100px;
  87. // margin: 0 auto;
  88. // flex: 1;
  89. padding-top: 15px;
  90. padding-left: 12px;
  91. // .breadcrumb {
  92. // height: 30px;
  93. // border-radius: 4px;
  94. // margin-bottom: 0px;
  95. // position: relative;
  96. // }
  97. /deep/ .el-breadcrumb__inner a {
  98. color: #333;
  99. font-weight: normal;
  100. user-select: none;
  101. line-height: 20px;
  102. &:hover {
  103. color: @themeColor;
  104. }
  105. }
  106. /deep/ .el-breadcrumb__item:last-child .el-breadcrumb__inner,
  107. .el-breadcrumb__item:last-child .el-breadcrumb__inner a,
  108. .el-breadcrumb__item:last-child .el-breadcrumb__inner a:hover,
  109. .el-breadcrumb__item:last-child .el-breadcrumb__inner:hover {
  110. /*font-weight: 700;*/
  111. color: @themeColor;
  112. user-select: none;
  113. line-height: 20px;
  114. cursor: pointer;
  115. }
  116. /deep/ .el-breadcrumb__separator[class*="el-icon-arrow-right"] {
  117. margin: 0px 3px 0px 1px;
  118. }
  119. }
  120. .avatarBox {
  121. position: absolute;
  122. top: 4px;
  123. right: 20px;
  124. z-index: 3;
  125. width: 40px;
  126. height: 40px;
  127. cursor: pointer;
  128. border-radius: 50%;
  129. overflow: hidden;
  130. }
  131. }
  132. </style>