index.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <template>
  2. <div :class="{'has-logo':showLogo}" :style="{ backgroundColor: settings.sideTheme === 'theme-dark' ? variables.menuBackground : variables.menuLightBackground }">
  3. <logo v-if="showLogo" :collapse="isCollapse" />
  4. <el-scrollbar :class="settings.sideTheme" wrap-class="scrollbar-wrapper">
  5. <el-menu
  6. :default-active="activeMenu"
  7. :collapse="isCollapse"
  8. :background-color="settings.sideTheme === 'theme-dark' ? variables.menuBackground : variables.menuLightBackground"
  9. :text-color="settings.sideTheme === 'theme-dark' ? variables.menuColor : variables.menuLightColor"
  10. :unique-opened="true"
  11. :active-text-color="settings.theme"
  12. :collapse-transition="false"
  13. mode="vertical"
  14. class="custom-menu"
  15. >
  16. <sidebar-item
  17. v-for="(route, index) in sidebarRouters"
  18. :key="route.path + index"
  19. :item="route"
  20. :base-path="route.path"
  21. />
  22. </el-menu>
  23. </el-scrollbar>
  24. </div>
  25. </template>
  26. <script>
  27. import { mapGetters, mapState } from "vuex";
  28. import Logo from "./Logo";
  29. import SidebarItem from "./SidebarItem";
  30. import variables from "@/assets/styles/variables.scss";
  31. export default {
  32. components: { SidebarItem, Logo },
  33. computed: {
  34. ...mapState(["settings"]),
  35. ...mapGetters(["sidebarRouters", "sidebar"]),
  36. activeMenu() {
  37. const route = this.$route;
  38. const { meta, path } = route;
  39. // if set path, the sidebar will highlight the path you set
  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>
  57. <style lang="scss" scoped>
  58. .custom-menu ::v-deep .el-menu-item{
  59. width: 90%;
  60. margin: auto;
  61. }
  62. //.custom-menu ::v-deep .el-menu-item:hover{
  63. // background: linear-gradient(270deg, rgba(29, 141, 245, 0.2) 0%, rgba(29, 141, 245, 0.2) 100%)!important;
  64. // width: 90%;
  65. // margin: auto;
  66. // border-radius: 6px;
  67. //}
  68. .custom-menu ::v-deep .el-menu-item.is-active {
  69. //background-color: #006CFF!important;
  70. color: #F2B680 !important;
  71. width: 90%;
  72. margin: auto;
  73. border-radius: 6px;
  74. }
  75. //.custom-menu ::v-deep .el-menu-item.is-active{
  76. // background: linear-gradient(270deg, #006CFF 0%, #006CFF 100%)!important;
  77. //
  78. //}
  79. </style>