index.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <template>
  2. <el-menu :default-active="activeIndex" class="el-menu-vertical-demo" collapse="true" @mouseleave="hideMenu"
  3. v-show="showMenu"
  4. text-color="#85878B" active-text-color="rgba(28, 153, 255, 1)" background-color="transparent">
  5. <template v-for="(item, index) in secondLevelTitle" :key="index">
  6. <el-sub-menu :index="index" v-if="item.children">
  7. <template #title>
  8. <!-- <router-link :to="item.path">-->
  9. <el-icon :class="item.icon">
  10. </el-icon>
  11. <!-- </router-link>-->
  12. </template>
  13. <el-menu-item-group v-for="(menu, idx) in item.children" :index="idx" :key="idx">
  14. <router-link :to="menu.path">
  15. <el-menu-item>{{ menu.titleName }}</el-menu-item>
  16. </router-link>
  17. </el-menu-item-group>
  18. </el-sub-menu>
  19. <el-menu-item v-else>
  20. <el-tooltip class="item" effect="light" :content="item.titleName" placement="right">
  21. <router-link :to="item.path">
  22. <i :class="item.icon"></i>
  23. </router-link>
  24. </el-tooltip>
  25. </el-menu-item>
  26. </template>
  27. <li class="el-sub-menu bottom-[60px] left-0 !absolute">
  28. <div class="w-[55px] h-[55px] flex items-center justify-center">
  29. <!-- :fill="stickMenu? '#1296db': '#515151'" -->
  30. <svg t="1669786260824" v-if="stickMenu" @click="funStickChange" class="icon cursor-pointer"
  31. viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="24315" width="24"
  32. height="24">
  33. <path
  34. d="M672 32a64 64 0 0 1 64 64v81.856a64 64 0 0 1-43.776 60.736L640 256l32 288 108.544 21.696A64 64 0 0 1 832 628.48V736a64 64 0 0 1-64 64h-224v192a32 32 0 0 1-64 0v-192H256a64 64 0 0 1-64-64v-107.52a64 64 0 0 1 51.456-62.784L352 544l32-288-52.224-17.408A64 64 0 0 1 288 177.856V96a64 64 0 0 1 64-64h320z"
  35. p-id="24316" fill="#85878b"></path>
  36. </svg>
  37. <svg t="1669786308333" v-else @click="funStickChange" class="icon cursor-pointer" viewBox="0 0 1024 1024"
  38. version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="24499" width="24" height="24">
  39. <path
  40. d="M712.704 48.32l222.4 222.4a64 64 0 0 1 0 90.496l-56.224 56.224a64 64 0 0 1-73.856 12l-48.16-24.064-178.816 223.488 60.32 90.464a64 64 0 0 1-8 80.736l-74.112 74.112a64 64 0 0 1-90.496 0l-140.704-140.704-130.016 130.048a31.616 31.616 0 0 1-44.704-44.704l130.016-130.048-171.104-171.104a64 64 0 0 1 0-90.496l74.112-74.112a64 64 0 0 1 80.736-8l90.464 60.32 223.488-178.816-24.064-48.16a64 64 0 0 1 12-73.856l56.224-56.224a64 64 0 0 1 90.496 0z"
  41. p-id="24500" fill="#85878b"></path>
  42. </svg>
  43. </div>
  44. </li>
  45. </el-menu>
  46. </template>
  47. <script>
  48. export default {
  49. name: 'menuNav',//状态监视
  50. props: {
  51. showMenu: {
  52. default: 'false',
  53. required: true,
  54. },
  55. secondLevelTitle: {
  56. type: Array,
  57. required: true,
  58. }
  59. },
  60. data() {
  61. return {
  62. stickMenu: false,
  63. activeIndex:'1',
  64. }
  65. },
  66. created() {
  67. let flge= JSON.parse(window.localStorage.getItem('menuState'));
  68. if(flge!=null){
  69. this.stickMenu=flge;
  70. this.$emit('stickMenu', this.stickMenu);
  71. }else {
  72. this.stickMenu=false;
  73. }
  74. },
  75. methods: {
  76. hideMenu() {
  77. if (!this.stickMenu) {
  78. this.$emit('hideMenuNav');
  79. }
  80. },
  81. funStickChange() {
  82. this.stickMenu = !this.stickMenu
  83. window.localStorage.setItem('menuState',JSON.stringify(this.stickMenu));
  84. this.$emit('stickMenu', this.stickMenu)
  85. this.$store.state.isLeft = this.stickMenu
  86. }
  87. },
  88. computed: {}
  89. }
  90. </script>
  91. <style lang="less" scoped>
  92. .el-menu-vertical-demo:not(.el-menu--collapse) {
  93. width: 150px;
  94. height: 100%;
  95. }
  96. .el-menu--collapse {
  97. text-align: center;
  98. width: 55px !important;
  99. }
  100. .el-menu {
  101. position: fixed;
  102. height: 100%;
  103. background: linear-gradient(278deg, #002767, transparent);
  104. -o-border-image: linear-gradient(180deg, transparent, #1a7ccd, #1a7ccd, transparent) 2 1;
  105. border-image: linear-gradient(180deg, transparent, #1a7ccd, #1a7ccd, transparent) 2 1;
  106. border-color: #002767;
  107. backdrop-filter: blur(5px);
  108. z-index: 2001;
  109. overflow: revert !important;
  110. .el-sub-menu a i {
  111. font-size: 19px;
  112. }
  113. .is-opened {
  114. a > i {
  115. color: #999999 !important;
  116. }
  117. }
  118. }
  119. </style>