navigationBar.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <template>
  2. <div id="navigationBar" :style="navStatus ? 'width:64px' : ''">
  3. <el-menu
  4. :default-active="navActive"
  5. class="el-menu-vertical-demo"
  6. :collapse="navStatus"
  7. :unique-opened="true"
  8. router
  9. :collapse-transition="false"
  10. >
  11. <div :class="navStatus ? 'logoTopS' : 'logoTop'">
  12. <img v-if="navStatus" src="@/assets/images/logo@2xS.png" alt="" />
  13. <img v-else src="@/assets/images/logo@2x.png" alt="" />
  14. </div>
  15. <template v-for="(item, index) in routesInfo">
  16. <el-submenu
  17. v-if="!item.hidden && item.meta.noCache"
  18. :index="item.path"
  19. :key="index"
  20. >
  21. <template slot="title">
  22. <i :class="item.meta.icon"></i>
  23. <span>{{ item.meta.title }}</span>
  24. </template>
  25. <template v-for="(items, indexs) in item.children">
  26. <el-menu-item
  27. v-if="!items.hidden"
  28. :key="indexs"
  29. :index="items.path"
  30. >{{ items.meta.title }}</el-menu-item
  31. >
  32. </template>
  33. </el-submenu>
  34. <el-menu-item
  35. v-if="!item.hidden && !item.meta.noCache"
  36. :index="item.path"
  37. :key="index"
  38. >
  39. <i :class="item.meta.icon"></i>
  40. <span slot="title">{{ item.meta.title }}</span>
  41. </el-menu-item>
  42. </template>
  43. </el-menu>
  44. </div>
  45. </template>
  46. <script>
  47. export default {
  48. data() {
  49. return {};
  50. },
  51. computed: {
  52. //当前导航栏展示状态
  53. navStatus() {
  54. return this.$store.state.navStatus;
  55. },
  56. //导航栏菜单
  57. routesInfo: function () {
  58. return this.$router.options.routes;
  59. },
  60. //当前激活菜单的index
  61. navActive() {
  62. return this.$store.state.navActive;
  63. },
  64. },
  65. };
  66. </script>
  67. <style lang="less" scoped>
  68. #navigationBar {
  69. position: fixed;
  70. top: 0px;
  71. left: 0;
  72. bottom: 0;
  73. width: 226px;
  74. background: #f7f9fe;
  75. transition: all 0.3s;
  76. overflow-x: hidden !important;
  77. box-shadow: 10px 0px 9px 1px rgba(28, 41, 90, 0.05);
  78. z-index: 999;
  79. .logoTop {
  80. height: 80px;
  81. display: flex;
  82. align-items: center;
  83. justify-content: center;
  84. img {
  85. width: 140px;
  86. height: 40px;
  87. }
  88. }
  89. .logoTopS {
  90. height: 80px;
  91. display: flex;
  92. align-items: center;
  93. justify-content: center;
  94. img {
  95. width: 40px;
  96. height: 40px;
  97. }
  98. }
  99. .el-menu-vertical-demo:not(.el-menu--collapse) {
  100. width: 226px;
  101. min-height: 100%;
  102. border: none;
  103. background-color: #f7f9fe;
  104. }
  105. .el-menu--collapse {
  106. width: 64px;
  107. min-height: 100%;
  108. border: none;
  109. background-color: #f7f9fe;
  110. }
  111. .el-menu-item {
  112. background-color: #f7f9fe;
  113. }
  114. .el-menu-item:hover {
  115. background-color: #e3edfe !important;
  116. }
  117. .el-menu-item.is-active {
  118. background-color: #e3edfe !important;
  119. }
  120. .el-submenu /deep/ .el-submenu__title:hover {
  121. background-color: #e3edfe !important;
  122. }
  123. }
  124. #navigationBar::-webkit-scrollbar {
  125. display: none;
  126. }
  127. </style>