index.vue 1.58 KB
<template>
  <div>
    <div class="logo">{{ title }}</div>
    <el-scrollbar wrap-class="scrollbar-wrapper">
      <el-menu router :default-active="activeMenu" :background-color="variables.menuBg" :text-color="variables.menuText"
        :unique-opened="true" :active-text-color="variables.menuActiveText" :collapse-transition="false"
        mode="vertical">
        <!-- 权限菜单 -->
        <!-- <sidebar-item v-for="route in permission_routes" :key="route.path" :item="route" :base-path="route.path" /> -->
        <!-- 菜单全部展示 -->
        <sidebar-item v-for="route in asyncRoutes" :key="route.path" :item="route" :base-path="route.path" />
      </el-menu>
    </el-scrollbar>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import Logo from './Logo'
import defaultSettings from '@/settings'
import SidebarItem from './SidebarItem'
import variables from '@/styles/variables.scss'
import { asyncRoutes } from '@/router'
export default {
  components: { SidebarItem, Logo },
  data () {
    return {
      title: defaultSettings.title
    }
  },
  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
    }
  }
}
</script>
<style scoped lang="scss">
.logo {
  width: 100%;
  height: 80px;
  color: #ffffff;
  font-size: 20px;
  display: flex;
  align-items: center;
  padding-left: 20px;
}
</style>