index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <template>
  2. <el-scrollbar class="side-bar-container" :class="{ 'is-collapse': collapse }">
  3. <vab-logo />
  4. <el-menu
  5. :background-color="variables['menu-background']"
  6. :text-color="variables['menu-color']"
  7. :active-text-color="variables['menu-color-active']"
  8. :default-active="activeMenu"
  9. :collapse="collapse"
  10. :collapse-transition="false"
  11. :default-openeds="defaultOpens"
  12. :unique-opened="uniqueOpened"
  13. mode="vertical"
  14. >
  15. <template v-for="route in routes">
  16. <vab-side-bar-item
  17. :key="route.path"
  18. :full-path="route.path"
  19. :item="route"
  20. />
  21. </template>
  22. </el-menu>
  23. </el-scrollbar>
  24. </template>
  25. <script>
  26. import variables from '@/styles/variables.scss'
  27. import { mapGetters } from 'vuex'
  28. import { defaultOopeneds, uniqueOpened } from '@/config'
  29. export default {
  30. name: 'VabSideBar',
  31. data() {
  32. return {
  33. uniqueOpened,
  34. }
  35. },
  36. computed: {
  37. ...mapGetters({
  38. collapse: 'settings/collapse',
  39. routes: 'routes/routes',
  40. }),
  41. defaultOpens() {
  42. if (this.collapse) {
  43. }
  44. return defaultOopeneds
  45. },
  46. activeMenu() {
  47. const route = this.$route
  48. const { meta, path } = route
  49. if (meta.activeMenu) {
  50. return meta.activeMenu
  51. }
  52. return path
  53. },
  54. variables() {
  55. return variables
  56. },
  57. },
  58. }
  59. </script>
  60. <style lang="scss" scoped>
  61. @mixin active {
  62. &:hover {
  63. color: $base-color-white;
  64. background-color: $base-menu-background-active !important;
  65. }
  66. &.is-active {
  67. color: $base-color-white;
  68. background-color: $base-menu-background-active !important;
  69. }
  70. }
  71. .side-bar-container {
  72. position: fixed;
  73. top: 0;
  74. bottom: 0;
  75. left: 0;
  76. z-index: $base-z-index;
  77. width: $base-left-menu-width;
  78. height: 100vh;
  79. overflow: hidden;
  80. background: $base-menu-background;
  81. box-shadow: 2px 0 6px rgba(0, 21, 41, 0.35);
  82. transition: width $base-transition-time;
  83. &.is-collapse {
  84. width: $base-left-menu-width-min;
  85. border-right: 0;
  86. ::v-deep {
  87. .el-menu {
  88. transition: width $base-transition-time;
  89. }
  90. .el-menu--collapse {
  91. border-right: 0;
  92. .el-submenu__icon-arrow {
  93. right: 10px;
  94. margin-top: -3px;
  95. }
  96. .el-menu-item,
  97. .el-submenu {
  98. text-align: center;
  99. }
  100. }
  101. }
  102. }
  103. ::v-deep {
  104. .el-scrollbar__wrap {
  105. overflow-x: hidden;
  106. }
  107. .el-menu {
  108. border: 0;
  109. .vab-fas-icon {
  110. padding-right: 3px;
  111. font-size: $base-font-size-default;
  112. display: inline-block;
  113. width: 14px;
  114. }
  115. .vab-remix-icon {
  116. padding-right: 3px;
  117. font-size: $base-font-size-default + 2;
  118. }
  119. }
  120. .el-menu-item,
  121. .el-submenu__title {
  122. height: $base-menu-item-height;
  123. line-height: $base-menu-item-height;
  124. vertical-align: middle;
  125. }
  126. .el-menu-item {
  127. @include active;
  128. }
  129. }
  130. }
  131. </style>