20d65ec2e596cc01bd90827e604963a17e8b9d9e.svn-base 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <template>
  2. <div :class="{'has-logo':showLogo}">
  3. <logo v-if="showLogo" :collapse="isCollapse" />
  4. <el-scrollbar wrap-class="scrollbar-wrapper">
  5. <el-menu
  6. :default-active="activeMenu"
  7. :collapse="isCollapse"
  8. :background-color="variables.menuBg"
  9. :unique-opened="false"
  10. :collapse-transition="false"
  11. mode="vertical"
  12. >
  13. <sidebar-item v-for="route in permission_routes" :key="route.path" :item="route" :base-path="route.path" />
  14. </el-menu>
  15. </el-scrollbar>
  16. </div>
  17. </template>
  18. <script>
  19. import { mapGetters } from 'vuex'
  20. import Logo from './Logo'
  21. import SidebarItem from './SidebarItem'
  22. import variables from '@/styles/variables.scss'
  23. export default {
  24. components: { SidebarItem, Logo },
  25. computed: {
  26. ...mapGetters([
  27. 'permission_routes',
  28. 'sidebar'
  29. ]),
  30. activeMenu() {
  31. const route = this.$route
  32. const { meta, path } = route
  33. // if set path, the sidebar will highlight the path you set
  34. if (meta.activeMenu) {
  35. return meta.activeMenu
  36. }
  37. return path
  38. },
  39. showLogo() {
  40. return this.$store.state.settings.sidebarLogo
  41. },
  42. variables() {
  43. return variables
  44. },
  45. isCollapse() {
  46. return !this.sidebar.opened
  47. }
  48. }
  49. }
  50. </script>