breadCrumb.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <template>
  2. <div class="breadCrumbPanel">
  3. <div class="contentClass">
  4. <el-breadcrumb separator="/">
  5. <transition-group name="breadcrumb">
  6. <el-breadcrumb-item v-for="(item, index) in list" :key="item.path + item.name">
  7. <router-link v-if="!disabledRoutes.includes(item.name)" @click="console.log(item)" :to="
  8. item.name !== $route.name
  9. ? item.fullPath
  10. ? item.fullPath
  11. : item.path
  12. ? item.path
  13. : '/'
  14. : $route.fullPath
  15. ">
  16. <i class="el-icon-folder-opened" v-if="index > 0 && index === list.length - 1"></i>
  17. {{ item.meta.tabname }}
  18. </router-link>
  19. <span v-else style="line-height: 20px">{{
  20. item.meta.tabname
  21. }}</span>
  22. </el-breadcrumb-item>
  23. </transition-group>
  24. </el-breadcrumb>
  25. </div>
  26. <div class="nameBox">
  27. <div>{{ $store.state.username }}</div>
  28. <div class="el-icon-switch-button exit" @click="exit"></div>
  29. </div>
  30. </div>
  31. </template>
  32. <script>
  33. import { mapState } from "vuex";
  34. export default {
  35. name: "breadCrumb",
  36. data() {
  37. return {
  38. // 相关页面只为占位,页面是空白,无法展示
  39. disabledRoutes: [
  40. "modelLibrary",
  41. "algorithmsLibrary",
  42. "sceneLibrary",
  43. "systemManagement",
  44. "workManagement",
  45. ],
  46. };
  47. },
  48. methods: {
  49. exit() {
  50. this.$confirm("是否确定退出系统?", "提示", {
  51. confirmButtonText: "确定",
  52. cancelButtonText: "取消",
  53. type: "warning",
  54. })
  55. .then(() => {
  56. localStorage.clear();
  57. // let loginUrl = window.location.origin + "/login";
  58. // window.location.href = loginUrl;
  59. this.$router.push({
  60. path: "/login",
  61. });
  62. })
  63. .catch(() => { });
  64. },
  65. },
  66. computed: {
  67. ...mapState([
  68. "projectInfoTabname", "taskInfoTabname", "vehicleConfigurationDetailTabName",
  69. "exportAlgorithmsTabName", "gitAlgorithmsTabName", "gradingRuleDetailTabName",
  70. "scenePacketListTabName",
  71. ]),
  72. list() {
  73. // console.log(this.$route);
  74. let isMainPage = false;
  75. this.$route.matched.filter((item) => {
  76. // 项目详情和任务详情的tabname需要动态获取
  77. if (item.name === "projectInfo") {
  78. item.meta.tabname =
  79. this.projectInfoTabname ||
  80. localStorage.getItem("projectInfoTabname") ||
  81. "项目详情";
  82. }
  83. if (item.name === "taskInfo") {
  84. item.meta.tabname =
  85. this.taskInfoTabname ||
  86. localStorage.getItem("taskInfoTabname") ||
  87. "任务详情";
  88. }
  89. if (item.name === "vehicleConfigurationDetail") {
  90. item.meta.tabname =
  91. this.vehicleConfigurationDetailTabName ||
  92. localStorage.getItem("vehicleConfigurationDetailTabName") ||
  93. "车辆配置详情";
  94. } else if (item.name === "exportAlgorithms") {
  95. item.meta.tabname =
  96. this.exportAlgorithmsTabName ||
  97. localStorage.getItem("exportAlgorithmsTabName") ||
  98. "导入算法";
  99. } else if (item.name === "gitAlgorithms") {
  100. item.meta.tabname =
  101. this.gitAlgorithmsTabName ||
  102. localStorage.getItem("gitAlgorithmsTabName") ||
  103. "仓库算法";
  104. } else if (item.name === "gradingRuleDetail") {
  105. item.meta.tabname =
  106. this.gradingRuleDetailTabName ||
  107. localStorage.getItem("gradingRuleDetailTabName") ||
  108. "评分规则详情";
  109. } else if (item.name === "scenePacketList") {
  110. item.meta.tabname =
  111. this.scenePacketListTabName ||
  112. localStorage.getItem("scenePacketListTabName") ||
  113. "场景测试包";
  114. }
  115. if (item.name === this.$route.name) {
  116. item.fullPath = this.$route.fullPath;
  117. }
  118. if (item.name === "mainPage") {
  119. isMainPage = true;
  120. }
  121. });
  122. if (isMainPage) {
  123. // 如果跳转首页,会有 / 需要去掉
  124. return this.$route.matched.slice(0, 1);
  125. } else {
  126. // 不要第一个显示首页的
  127. return this.$route.matched.slice(1);
  128. }
  129. },
  130. },
  131. };
  132. </script>
  133. <style lang="less" scoped>
  134. .breadCrumbPanel {
  135. position: fixed;
  136. top: 0;
  137. left: 150px;
  138. right: 0;
  139. bottom: 0;
  140. z-index: 666;
  141. height: 50px;
  142. line-height: 48px;
  143. border-bottom: 2px solid #f5f7fa;
  144. background-color: #ffffff;
  145. overflow: hidden;
  146. .contentClass {
  147. // width: 1100px;
  148. // margin: 0 auto;
  149. // flex: 1;
  150. padding-top: 15px;
  151. padding-left: 12px;
  152. // .breadcrumb {
  153. // height: 30px;
  154. // border-radius: 4px;
  155. // margin-bottom: 0px;
  156. // position: relative;
  157. // }
  158. /deep/ .el-breadcrumb__inner a {
  159. color: #333;
  160. font-weight: normal;
  161. user-select: none;
  162. line-height: 20px;
  163. &:hover {
  164. color: @themeColor;
  165. }
  166. }
  167. /deep/ .el-breadcrumb__item:last-child .el-breadcrumb__inner,
  168. .el-breadcrumb__item:last-child .el-breadcrumb__inner a,
  169. .el-breadcrumb__item:last-child .el-breadcrumb__inner a:hover,
  170. .el-breadcrumb__item:last-child .el-breadcrumb__inner:hover {
  171. /*font-weight: 700;*/
  172. color: @themeColor;
  173. user-select: none;
  174. line-height: 20px;
  175. cursor: pointer;
  176. }
  177. /deep/ .el-breadcrumb__separator[class*="el-icon-arrow-right"] {
  178. margin: 0px 3px 0px 1px;
  179. }
  180. }
  181. .nameBox {
  182. position: absolute;
  183. top: 4px;
  184. right: 20px;
  185. z-index: 669;
  186. display: flex;
  187. height: 40px;
  188. div {
  189. height: 40px;
  190. line-height: 40px;
  191. }
  192. .exit {
  193. margin-left: 10px;
  194. font-size: 20px;
  195. cursor: pointer;
  196. }
  197. .exit:hover {
  198. color: @themeColor;
  199. }
  200. }
  201. /* .avatarBox {
  202. position: absolute;
  203. top: 4px;
  204. right: 20px;
  205. z-index: 669;
  206. width: 40px;
  207. height: 40px;
  208. cursor: pointer;
  209. border-radius: 50%;
  210. overflow: hidden;
  211. } */
  212. }
  213. </style>