index.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. :text-color="variables.menuText"
  10. :unique-opened="false"
  11. :active-text-color="variables.menuActiveText"
  12. :collapse-transition="false"
  13. mode="vertical"
  14. >
  15. <sidebar-item v-for="route in routes" :key="route.path" :item="route" />
  16. </el-menu>
  17. </el-scrollbar>
  18. </div>
  19. </template>
  20. <script>
  21. import { mapGetters } from 'vuex'
  22. import Logo from './Logo'
  23. import SidebarItem from './SidebarItem'
  24. import variables from '@/styles/variables.scss'
  25. export default {
  26. components: { SidebarItem, Logo },
  27. computed: {
  28. ...mapGetters(['sidebar', 'l1Path']),
  29. routes() {
  30. var l1 = this.$router.options.routes.concat(global.antRouter).find(item => item.path === this.l1Path)
  31. if (l1 && l1.children) {
  32. return l1.children
  33. } else {
  34. return []
  35. }
  36. },
  37. activeMenu() {
  38. const route = this.$route
  39. const { meta, path, fullUrl } = route
  40. if (meta.activeMenu) {
  41. return meta.activeMenu
  42. }
  43. return path
  44. },
  45. showLogo() {
  46. return this.$store.state.settings.sidebarLogo
  47. },
  48. variables() {
  49. return variables
  50. },
  51. isCollapse() {
  52. return !this.sidebar.opened
  53. }
  54. }
  55. }
  56. </script>