Blame view

src/layout/components/Sidebar/index.vue 1.31 KB
赵千 committed
1
<template>
任超 committed
2
  <div>
赵千 committed
3
    <el-scrollbar wrap-class="scrollbar-wrapper">
任超 committed
4
      <el-menu router :default-active="activeMenu" :background-color="variables.menuBg" :text-color="variables.menuText"
5
        :unique-opened="true" :active-text-color="variables.menuActiveText" :collapse-transition="false" mode="vertical">
赵千 committed
6
        <!-- 权限菜单 -->
7
        <sidebar-item v-for="(route, index) in permission_routes" :key="index" :item="route" :base-path="route.path" />
赵千 committed
8
        <!-- 菜单全部展示 -->
任超 committed
9
        <!-- <sidebar-item v-for="route in asyncRoutes" :key="route.path" :item="route" :base-path="route.path" /> -->
赵千 committed
10 11 12 13 14 15
      </el-menu>
    </el-scrollbar>
  </div>
</template>

<script>
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
  import { mapGetters } from 'vuex'
  import Logo from './Logo'
  import SidebarItem from './SidebarItem'
  import variables from '@/styles/variables.scss'
  import { asyncRoutes } from '@/router'
  export default {
    components: { SidebarItem, Logo },
    computed: {
      ...mapGetters(['permission_routes', 'sidebar']),
      activeMenu () {
        const route = this.$route
        const { meta, path } = route
        if (meta.activeMenu) {
          return meta.activeMenu
        }
        return path
      },
      variables () {
        return variables
      },
      asyncRoutes () {
        return asyncRoutes
赵千 committed
38
      }
任超 committed
39
    }
任超 committed
40
  }
赵千 committed
41
</script>