wr1207
2023-04-17 32e4bad2cff2793052effcd2d59cdd8923702b22
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<template>
  <el-aside id="aside" style="overflow-x: hidden;overflow-y: hidden">
    <el-scrollbar class="scrollbar-wrapper" style="height:100%;">
      <div>
      <div style="height:60px;color:#8fa6bf;text-indent:20px;border-bottom:1px solid #192a3f;padding-top:10px;">
        <p style="line-height:60px;" v-if="!isCollapse">{{site_title}}</p>
        <el-image  v-else src="./static/images/vue.png" style="width:30px; height:30px;margin-top:15px;"></el-image>
      </div>
      <el-menu class="el-menu-vertical-demo" router :default-active="activie_index" :unique-opened="true" :background-color="aside.aside_background_color"  text-color="#8fa6bf"  :active-text-color="aside.aside_active_text_color"  :collapse="isCollapse">
        <template v-for="(item,i) in menu">
          <el-submenu v-if="item.children && item.children.length" :index="item.path" :key="item.name">
            <template slot="title"><i :class="item.icon"></i><span>{{item.title}}</span></template>
            <!-- 二级菜单 -->
            <template v-for="itemChild in item.children">
              <el-submenu v-if="itemChild.children && itemChild.children.length" :index="itemChild.path" :key="itemChild.name">
                  <template slot="title"><i :class="itemChild.icon"></i><span>{{itemChild.title}}</span></template>
                  <!-- 三级菜单 -->
                  <el-menu-item v-for="itemChild_Child in itemChild.children" :index="itemChild_Child.path" :key="itemChild_Child.name">
                  <i :class="itemChild_Child.icon"></i><span slot="title">{{itemChild_Child.title}}</span></el-menu-item>
              </el-submenu>
              <el-menu-item v-else :index="itemChild.path" :key="itemChild.name+i"><i :class="itemChild.icon"></i><span slot="title">{{itemChild.title}}</span></el-menu-item>
            </template>
          </el-submenu>
          <el-menu-item v-else :index="item.path" :key="item.name+i"><i :class="item.icon"></i><span slot="title">{{item.title}}</span></el-menu-item>
        </template>
      </el-menu>
      </div>
    </el-scrollbar>
  </el-aside>
</template>
<script>
import{ mapGetters } from 'vuex'
export default {
  name:'Side',
  computed: {
    ...mapGetters(['menu','sidebar','site_title']),
    isCollapse() {
      return !this.sidebar.opened
    }
  },
  data() {
    return {
      activie_index: this.$route.path,
      aside: {
        aside_background_color: '#121e2d',
        aside_active_text_color: '#FFF',
      },
    }
  },
  watch:{
    $route(){
      this.activie_index = this.$route.path
    }
  },
};
</script>
<style lang="scss" scoped>
.horizontal-collapse-transition { transition: 0s width ease-in-out, 0s padding-left ease-in-out, 0s padding-right ease-in-out;}  
.el-menu {border-right: 0 !important;}
#aside::-webkit-scrollbar {display: none;}
#aside {height: 100vh; overflow-x: hidden;overflow-y: scroll;}
::v-deep.el-menu {
    background-color: transparent;
    .el-menu-item {
      color: #8fa6bf;
      height: 42px;
      line-height: 42px;
      i {
        color: #8fa6bf;
      }
    }
    .el-submenu__title {
      color: #8fa6bf;
      height: 45px;
      line-height: 45px;
      i {
        color: #8fa6bf;
      }
    }
}
.is-active{
  background-color: #0576b9!important;
  i {
        color: #FFF;
  }
}
</style>