admin-menu.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. :unique-opened="true"
  15. >
  16. <span v-for="(item, index) in menu" :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" @click="selectMenu(item.path, item.module)">
  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" @click="selectMenu(item.path + child.path, item.module)">
  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 * as menus from '@frame/config/menu-config';
  45. import scrollBar from './scrollBar.vue';
  46. import _ from 'lodash';
  47. export default {
  48. name: 'admin-menu',
  49. props: {},
  50. components: {
  51. scrollBar,
  52. },
  53. data: () => ({
  54. menu: [],
  55. }),
  56. created() {},
  57. computed: {
  58. project_modules() {
  59. return process.env.VUE_APP_MODULE;
  60. },
  61. },
  62. mounted() {
  63. let arr = _.get(menus, this.project_modules, []);
  64. this.$set(this, `menu`, arr);
  65. },
  66. methods: {
  67. selectMenu(path, modules) {
  68. if (this.project_modules === modules) this.$router.push({ path: path });
  69. },
  70. },
  71. };
  72. </script>
  73. <style lang="less" scoped>
  74. .logo {
  75. display: flex;
  76. justify-content: center;
  77. align-items: center;
  78. height: 4rem;
  79. line-height: 4rem;
  80. background: #002140;
  81. color: #fff;
  82. text-align: center;
  83. font-size: 1.1rem;
  84. font-weight: 600;
  85. overflow: hidden;
  86. }
  87. .site-name {
  88. margin-left: 0.325rem;
  89. }
  90. .sidebar-container {
  91. box-shadow: 0.125rem 0 0.375rem rgba(0, 21, 41, 0.35);
  92. transition: width 0.28s;
  93. width: 12rem !important;
  94. height: 100%;
  95. position: fixed;
  96. top: 0;
  97. bottom: 0;
  98. left: 0;
  99. z-index: 1001;
  100. overflow: hidden;
  101. a {
  102. display: inline-block;
  103. width: 100%;
  104. }
  105. .el-menu {
  106. padding-top: 1rem;
  107. width: 100% !important;
  108. border: none;
  109. }
  110. .el-submenu .el-menu-item {
  111. min-width: 16rem !important;
  112. padding-left: 3rem !important;
  113. background-color: #000c17 !important;
  114. &:hover {
  115. color: #fff !important;
  116. }
  117. }
  118. .el-menu-item,
  119. .el-submenu .el-menu-item {
  120. &.is-active {
  121. background-color: #188fff !important;
  122. color: #fff !important;
  123. }
  124. }
  125. .el-submenu__title i {
  126. font-size: 1rem;
  127. color: rgba(255, 255, 255, 0.65);
  128. }
  129. }
  130. </style>