index.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <template>
  2. <div :class="{'has-logo':showLogo}">
  3. <logo v-if="showLogo"
  4. :collapse="false" />
  5. <el-scrollbar wrap-class="scrollbar-wrapper">
  6. <el-menu :default-active="activeMenu"
  7. :collapse='false'
  8. :background-color="variables.menuBg"
  9. :text-color="variables.menuText"
  10. :unique-opened="true"
  11. :active-text-color="variables.menuActiveText"
  12. :collapse-transition="true"
  13. mode="vertical">
  14. <sidebar-item v-for="(route,index) in permission_routes"
  15. :key="index"
  16. :item="route"
  17. :base-path="route.path" />
  18. </el-menu>
  19. </el-scrollbar>
  20. </div>
  21. </template>
  22. <script>
  23. import { mapGetters } from 'vuex'
  24. import Logo from './Logo'
  25. import SidebarItem from './SidebarItem'
  26. import variables from '@/styles/variables.scss'
  27. export default {
  28. components: { SidebarItem, Logo },
  29. // mounted () {
  30. // },
  31. computed: {
  32. ...mapGetters([
  33. 'sidebar',
  34. 'permission_routes'
  35. ]),
  36. // routes () {
  37. // return this.$router.options.routes
  38. // },
  39. activeMenu () {
  40. const route = this.$route
  41. const { meta, path } = route
  42. // if set path, the sidebar will highlight the path you set
  43. // 设置高亮的位置
  44. if (meta.activeMenu) {
  45. return meta.activeMenu
  46. }
  47. // console.log(meta, path)
  48. return path
  49. },
  50. showLogo () {
  51. return this.$store.state.settings.sidebarLogo
  52. },
  53. variables () {
  54. return variables
  55. },
  56. isCollapse () {
  57. return false
  58. }
  59. }
  60. }
  61. </script>
  62. <style lang="scss" scoped>
  63. .el-menu-item {
  64. &:nth-last-child(1) {
  65. padding-bottom: 20px;
  66. }
  67. }
  68. </style>