admin-menu.vue 3.4 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 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 { devMenu } from '@frame/config/menu-config';
  38. import scrollBar from './scrollBar.vue';
  39. export default {
  40. name: 'admin-menu',
  41. props: {},
  42. components: {
  43. scrollBar,
  44. },
  45. data: () => ({
  46. menu: [],
  47. }),
  48. created() {},
  49. computed: {
  50. project_modules() {
  51. return process.env.VUE_APP_MODULE;
  52. },
  53. },
  54. mounted() {
  55. let arr = devMenu.filter(fil => fil.module === this.project_modules);
  56. this.$set(this, `menu`, arr);
  57. },
  58. methods: {
  59. selectMenu(path, modules) {
  60. if (this.project_modules === modules) this.$router.push({ path: path });
  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>