Blame view

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