admin-menu.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <template>
  2. <div id="admin-menu" style="background-color: rgb(0, 20, 42);">
  3. <scroll-bar>
  4. <div class="logo">
  5. <img src="https://img.alicdn.com/tfs/TB13UQpnYGYBuNjy0FoXXciBFXa-242-134.png" width="40" />
  6. <span class="site-name">ADMIN LITE</span>
  7. </div>
  8. <el-menu
  9. mode="vertical"
  10. :show-timeout="200"
  11. background-color="#00142a"
  12. text-color="hsla(0, 0%, 100%, .65)"
  13. active-text-color="#409EFF"
  14. @select="selectMenu"
  15. >
  16. <span v-for="(item, index) in devMenu" :key="index">
  17. <!-- <span v-if="`${item.role}` === `${user.role}` || !item.role"> -->
  18. <!-- v-if="`${item.role}` === `${user.role}`" -->
  19. <span v-if="!item.children" :to="item.path" :key="item.name">
  20. <el-menu-item :index="item.path">
  21. <i v-if="item.icon" :class="item.icon"></i>
  22. <span v-if="item.name" slot="title">{{ item.name }}</span>
  23. </el-menu-item>
  24. </span>
  25. <el-submenu v-else :index="item.name || item.path" :key="item.name">
  26. <template slot="title">
  27. <i v-if="item && item.icon" :class="item.icon"></i>
  28. <span v-if="item && item.name" slot="title">{{ item.name }}</span>
  29. </template>
  30. <template v-for="(child, childIndex) in item.children">
  31. <div :key="childIndex" v-if="!child.hidden">
  32. <el-menu-item :index="item.path + child.path">
  33. <span v-if="child && child.name" slot="title">{{ child.name }}</span>
  34. </el-menu-item>
  35. </div>
  36. </template>
  37. </el-submenu>
  38. </span>
  39. </el-menu>
  40. </scroll-bar>
  41. </div>
  42. </template>
  43. <script>
  44. import { devMenu } from '../../config/menu-config';
  45. import scrollBar from './scrollBar.vue';
  46. export default {
  47. name: 'admin-menu',
  48. props: {},
  49. components: {
  50. scrollBar,
  51. },
  52. data: () => ({
  53. devMenu,
  54. }),
  55. created() {},
  56. computed: {},
  57. methods: {
  58. selectMenu(index) {
  59. console.log(index);
  60. this.$router.push({ path: index });
  61. },
  62. },
  63. };
  64. </script>
  65. <style lang="less" scoped>
  66. .logo {
  67. display: flex;
  68. justify-content: center;
  69. align-items: center;
  70. height: 4rem;
  71. line-height: 4rem;
  72. background: #002140;
  73. color: #fff;
  74. text-align: center;
  75. font-size: 1.1rem;
  76. font-weight: 600;
  77. overflow: hidden;
  78. }
  79. .site-name {
  80. margin-left: 0.325rem;
  81. }
  82. .sidebar-container {
  83. box-shadow: 0.125rem 0 0.375rem rgba(0, 21, 41, 0.35);
  84. transition: width 0.28s;
  85. width: 12rem !important;
  86. height: 100%;
  87. position: fixed;
  88. top: 0;
  89. bottom: 0;
  90. left: 0;
  91. z-index: 1001;
  92. overflow: hidden;
  93. a {
  94. display: inline-block;
  95. width: 100%;
  96. }
  97. .el-menu {
  98. padding-top: 1rem;
  99. width: 100% !important;
  100. border: none;
  101. }
  102. .el-submenu .el-menu-item {
  103. min-width: 16rem !important;
  104. padding-left: 3rem !important;
  105. background-color: #000c17 !important;
  106. &:hover {
  107. color: #fff !important;
  108. }
  109. }
  110. .el-menu-item,
  111. .el-submenu .el-menu-item {
  112. &.is-active {
  113. background-color: #188fff !important;
  114. color: #fff !important;
  115. }
  116. }
  117. .el-submenu__title i {
  118. font-size: 1rem;
  119. color: rgba(255, 255, 255, 0.65);
  120. }
  121. }
  122. </style>