breadCrumb.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. // console.log(this.$route.matched);
  61. let isMainPage = false;
  62. this.$route.matched.filter((item) => {
  63. if (item.name === this.$route.name) {
  64. item.fullPath = this.$route.fullPath;
  65. }
  66. if (item.name === "mainPage") {
  67. isMainPage = true;
  68. }
  69. });
  70. if (isMainPage) {
  71. return this.$route.matched.slice(0, 1);
  72. } else {
  73. return this.$route.matched;
  74. }
  75. },
  76. },
  77. };
  78. </script>
  79. <style lang="less" scoped>
  80. .topClass {
  81. position: relative;
  82. height: 50px;
  83. line-height: 48px;
  84. border-bottom: 2px solid #f5f7fa;
  85. overflow: hidden;
  86. .contentClass {
  87. // width: 1100px;
  88. // margin: 0 auto;
  89. // flex: 1;
  90. padding-top: 15px;
  91. padding-left: 12px;
  92. // .breadcrumb {
  93. // height: 30px;
  94. // border-radius: 4px;
  95. // margin-bottom: 0px;
  96. // position: relative;
  97. // }
  98. /deep/ .el-breadcrumb__inner a {
  99. color: #333;
  100. font-weight: normal;
  101. user-select: none;
  102. line-height: 20px;
  103. &:hover {
  104. color: @themeColor;
  105. }
  106. }
  107. /deep/ .el-breadcrumb__item:last-child .el-breadcrumb__inner,
  108. .el-breadcrumb__item:last-child .el-breadcrumb__inner a,
  109. .el-breadcrumb__item:last-child .el-breadcrumb__inner a:hover,
  110. .el-breadcrumb__item:last-child .el-breadcrumb__inner:hover {
  111. /*font-weight: 700;*/
  112. color: @themeColor;
  113. user-select: none;
  114. line-height: 20px;
  115. cursor: pointer;
  116. }
  117. /deep/ .el-breadcrumb__separator[class*="el-icon-arrow-right"] {
  118. margin: 0px 3px 0px 1px;
  119. }
  120. }
  121. .avatarBox {
  122. position: absolute;
  123. top: 4px;
  124. right: 20px;
  125. z-index: 3;
  126. width: 40px;
  127. height: 40px;
  128. cursor: pointer;
  129. border-radius: 50%;
  130. overflow: hidden;
  131. }
  132. }
  133. </style>