Blame view

merchant-web-master/src/layout/components/Sidebar/index.vue 2.58 KB
3f535f30   杨鑫   '初始'
1
2
3
4
5
6
7
8
9
10
11
12
13
14
  <template>
    <div :class="{ 'has-logo': showLogo }">
  <!--    <logo v-if="isCollapse" :collapse="isCollapse" />
      <logo v-else :collapse="isCollapse" /> -->
      <el-scrollbar wrap-class="scrollbar-wrapper">
        <el-menu
          :default-active="activeMenu"
          :collapse="isCollapse"
          :background-color="variables.menuBg"
          :text-color="variables.menuText"
          :unique-opened="false"
          :active-text-color="variables.menuActiveText"
          :collapse-transition="false"
          mode="vertical"
1991126c   杨鑫   '最新'
15
          style="padding: 10px 0;"
3f535f30   杨鑫   '初始'
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
        >
          <sidebar-item
            v-for="(route,index) in routers"
            :key="index"
            class="tabLink"
            :item="route"
            :base-path="route.path"
          />
        </el-menu>
      </el-scrollbar>
    </div>
  </template>
  
  <script>
  import { mapGetters } from 'vuex'
  import Logo from './Logo'
  import SidebarItem from './SidebarItem'
  import variables from '@/styles/variables.scss'
  // import { adminBuild } from '@/api/user'
  // import { getUserId, setBtns } from '@/utils/auth'
  
  export default {
    components: { SidebarItem, Logo },
    data() {
      return {
        // routes: []
      }
    },
    computed: {
      ...mapGetters([
        'sidebar',
        'routers'
      ]),
      // routes() {
      //   return this.$router.options.routes;
      // },
      activeMenu() {
        const route = this.$route
        const { meta, path } = route
        // if set path, the sidebar will highlight the path you set
        if (meta.activeMenu) {
          return meta.activeMenu
        }
        return path
      },
      showLogo() {
        return this.$store.state.settings.sidebarLogo
      },
      variables() {
        return variables
      },
      isCollapse() {
        return !this.sidebar.opened
      }
    },
    // created() {
    //   adminBuild({ businessUserId: getUserId() }).then(
    //     res => {
    //       this.routes = res.data
    //       // localStorage.setItem("permissionList", JSON.stringify(res.data));
    //     }
    //   )
    // },
    methods: {
      // touchSidbar(arr) {
      //   debugger
      //   console.log(arr)
      //   let res = []
      //   this.routes.forEach(element => {
      //     const t = element
      //     if (element.path === arr) {
      //       console.log(111213)
      //       res = element
      //     } else {
      //       t.children.forEach(e => {
      //         if (e.path === arr) {
      //           res = e
      //         }
      //       })
      //     }
      //   })
      //   setBtns(JSON.stringify(res.buttons))
      //   console.log(res)
      // }
    }
  }
  </script>
  <style scoped>
    ::v-deep .el-scrollbar__thumb {
               background-color: #DEEBE2;
  
      }
  
  
  </style>