叶松
2023-09-21 d308d8cb74897449ba7d64e0486d767b5fc774b9
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<!-- 导航菜单 -->
<template>
  <div class="menu_index">
    <el-menu
      unique-opened
      :default-active="$route.path"
      class="el-menu-vertical-demo"
      background-color="transparent"
      text-color="#EAEAEA"
      @select="changeRouter">
        <template v-for="item in routerList">
          <template v-if="item.children && item.children.length > 1">
            <el-submenu :key="item.name" :index="item.path">
              <template slot="title">
                <span>{{item.meta.title}}</span>
              </template>
              <!-- <template v-for="items in item.children">
                <el-menu-item :index="items.path" :key="items.name">{{items.meta.title}}</el-menu-item>
              </template> -->
 
 
              <template v-for="three in item.children">
                <template v-if="three.children && three.children.length > 1">
                  <el-submenu :key="three.name" :index="three.path">
                    <template slot="title">
                      <span>{{three.meta.title}}</span>
                    </template>
                    <template v-for="items in three.children">
                      <el-menu-item :index="items.path" :key="items.name">{{items.meta.title}}</el-menu-item>
                    </template>
                  </el-submenu>
                </template>
                <template v-else-if="three.children && three.children.length === 1">
                  <el-submenu :key="three.name" :index="three.path">
                    <template slot="title">
                      <span>{{three.meta.title}}</span>
                    </template>
                    <el-menu-item :index="three.children[0].path" :key="three.children[0].name">{{three.children[0].meta.title}}</el-menu-item>
                  </el-submenu>
                  <!-- <el-menu-item :index="three.children[0].path" :key="three.children[0].name">
                    <span slot="title">{{three.children[0].meta.title}}</span>
                  </el-menu-item> -->
                </template>
                <template v-else>
                  <el-menu-item :index="three.path" :key="three.name">
                    <span slot="title">{{three.meta.title}}</span>
                  </el-menu-item>
                </template>
              </template>
 
 
            </el-submenu>
          </template>
 
 
 
 
 
          <template v-else-if="item.children && item.children.length === 1">
            <el-menu-item :index="item.children[0].path" :key="item.children[0].name">
              <span slot="title">{{item.children[0].meta.title}}</span>
            </el-menu-item>
          </template>
          <template v-else>
            <el-menu-item :index="item.path" :key="item.name">
              <span slot="title">{{item.meta.title}}</span>
            </el-menu-item>
          </template>
        </template>
    </el-menu>
  </div>
</template>
 
<script>
export default {
  name: 'LayoutAside',
  data() {
    return {
      routerList: [], // 导航栏数据
    };
  },
  mounted() {
    this.routerList = this.$router.options.routes
  },
  methods: {
    // 切换路由
    changeRouter(path) {
      this.$router.push(path).catch(err => {
        console.log(err,"--");
      })
    }
  },
};
</script>
 
<style lang="scss" scoped>
.menu_index {
  height: 100%;
  overflow-y: auto;
  border-top: 1px solid rgba(57,181,254,0.16);
  
 
  &::-webkit-scrollbar {
    width: 4px;
  }
 
  &::-webkit-scrollbar-thumb {
      border-radius: 10px;
      box-shadow: inset 0 0 5px transparent;
      background: rgba(57, 181, 254, .6);
  }
 
  &::-webkit-scrollbar-track {
      box-shadow: inset 0 0 5px transparent;
      border-radius: 10px;
      background: rgba(57, 181, 254, .5) 5%,;
  }
}
 
/deep/ .el-menu {
  border-right: 0;
}
 
/deep/ .el-submenu .el-menu-item {
  height: 40px;
  line-height: 40px;
}
 
/deep/ .el-menu-item.is-active {
  padding-left: 45px!important;
  position: relative;
  margin-left: 10px;
  color: #3DC8FF;
  border-radius: 3px;
  background: linear-gradient(
  90deg, 
  rgba(57, 181, 254, .5) 5%,
  transparent 95%) !important;
 
    &::before {
      content: '';
      position: absolute;
      top: 50%;
      left: 0;
      transform: translateY(-50%);
      width: 4px;
      height: 100%;
      background: #3DC8FF;
      border-radius: 3px 0 0 3px;
    }
}
 
/deep/ .el-submenu .el-submenu__title:hover {
  color: #3DC8FF;
  background: rgba(57,181,254,0.7) !important;
}
 
/deep/ .el-menu-item:hover {
  color: #3DC8FF;
  background: rgba(57, 181, 254, .5) !important;
}
</style>