admin-menu.vue 3.4 KB

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