index.vue 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <template>
  2. <div
  3. v-if="sidebarRouters && sidebarRouters.length>0"
  4. :class="{'has-logo':showLogo}"
  5. :style="{ backgroundColor: settings.sideTheme === 'theme-dark' ? variables.menuBg : variables.menuLightBg }"
  6. >
  7. <!-- <logo v-if="showLogo" :collapse="isCollapse" /> -->
  8. <el-scrollbar :class="settings.sideTheme" wrap-class="scrollbar-wrapper">
  9. <el-menu
  10. :default-active="activeMenu"
  11. :collapse="isCollapse"
  12. :background-color="settings.sideTheme === 'theme-dark' ? variables.menuBg : variables.menuLightBg"
  13. :text-color="settings.sideTheme === 'theme-dark' ? variables.menuText : 'rgba(0,0,0,.65)'"
  14. :unique-opened="true"
  15. :active-text-color="settings.theme"
  16. :collapse-transition="false"
  17. mode="vertical"
  18. >
  19. <sidebar-item v-for="(route, index) in sidebarRouters" :key="route.path + index" :item="route"
  20. :base-path="route.path"/>
  21. </el-menu>
  22. </el-scrollbar>
  23. </div>
  24. </template>
  25. <script>
  26. import { mapGetters, mapState } from 'vuex'
  27. import Logo from './Logo'
  28. import SidebarItem from './SidebarItem'
  29. import variables from '@/assets/styles/variables.scss'
  30. export default {
  31. components: { SidebarItem, Logo },
  32. computed: {
  33. ...mapState(['settings']),
  34. ...mapGetters(['sidebarRouters', 'sidebar']),
  35. activeMenu() {
  36. const route = this.$route
  37. const { meta, path } = route
  38. // if set path, the sidebar will highlight the path you set
  39. if (meta.activeMenu) {
  40. return meta.activeMenu
  41. }
  42. return path
  43. },
  44. showLogo() {
  45. return this.$store.state.settings.sidebarLogo
  46. },
  47. variables() {
  48. return variables
  49. },
  50. isCollapse() {
  51. return !this.sidebar.opened
  52. }
  53. },
  54. data() {
  55. return {
  56. fal: false
  57. }
  58. },
  59. watch: {
  60. $route: function(route) {
  61. }
  62. },
  63. methods: {
  64. activeMenuList(data, activeMenu) {
  65. data.forEach((item) => {
  66. if (item.path == activeMenu) {
  67. this.fal = true
  68. }
  69. if (item.children && item.children.length > 0) {
  70. this.activeMenuList(item.children, activeMenu)
  71. }
  72. })
  73. }
  74. }
  75. }
  76. </script>
  77. <style scoped>
  78. /deep/ .is-active .el-submenu__title {
  79. color: #ffffff !important;
  80. background-color: rgb(71, 198, 162) !important;
  81. }
  82. </style>