index.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <div>
  3. <div
  4. :class="{ 'has-logo': showLogo, }"
  5. :style="{
  6. backgroundColor:
  7. settings.sideTheme === 'theme-dark' ? '#133f6f' : '#ffffff',
  8. }"
  9. >
  10. <logo v-if="showLogo" :collapse="isCollapse" />
  11. <div class="scro">
  12. <el-scrollbar :class="settings.sideTheme" style="height: 100%" wrap-class="scrollbar-wrapper">
  13. <el-menu
  14. :default-active="activeMenu"
  15. :collapse="isCollapse"
  16. :background-color="
  17. settings.sideTheme === 'theme-dark' ? '#133f6f' : '#ffffff'
  18. "
  19. :text-color="
  20. settings.sideTheme === 'theme-dark' ? '#bfcbd9' : '#182c4e'
  21. "
  22. :unique-opened="true"
  23. :active-text-color="settings.theme"
  24. :collapse-transition="false"
  25. mode="vertical"
  26. >
  27. <sidebar-item
  28. v-for="(route, index) in sidebarRouters"
  29. :key="route.path + index"
  30. :item="route"
  31. :base-path="'/' + route.path"
  32. />
  33. </el-menu>
  34. </el-scrollbar>
  35. </div>
  36. <div class="bottomBox" :style="{ backgroundColor: settings.sideTheme === 'theme-dark' ? '#133f6f' : '#ffffff' }">
  37. <hamburger
  38. id="hamburger-container"
  39. :is-active="sidebar.opened"
  40. class="hamburger-container"
  41. @toggleClick="toggleSideBar"
  42. />
  43. </div>
  44. </div>
  45. </div>
  46. </template>
  47. <script>
  48. import { mapGetters, mapState } from "vuex";
  49. import Logo from "./Logo";
  50. import SidebarItem from "./SidebarItem";
  51. import Hamburger from "@/components/Hamburger";
  52. export default {
  53. components: { SidebarItem, Logo, Hamburger },
  54. computed: {
  55. ...mapState(["settings"]),
  56. ...mapGetters(["sidebarRouters", "sidebar"]),
  57. activeMenu() {
  58. const route = this.$route;
  59. const { meta, path } = route;
  60. // if set path, the sidebar will highlight the path you set
  61. if (meta.activeMenu) {
  62. return meta.activeMenu;
  63. }
  64. return path;
  65. },
  66. showLogo() {
  67. return this.$store.state.settings.sidebarLogo;
  68. },
  69. isCollapse() {
  70. return !this.sidebar.opened;
  71. },
  72. },
  73. mounted(){
  74. console.log(this.sidebarRouters,'sidebarRouters');
  75. },
  76. methods: {
  77. toggleSideBar() {
  78. this.$store.dispatch("app/toggleSideBar");
  79. },
  80. },
  81. };
  82. </script>
  83. <style lang="scss" scoped>
  84. .hamburger {
  85. margin-bottom: -1px;
  86. width: 100%;
  87. height: 100%;
  88. background-color: #133f6f;
  89. }
  90. .scro {
  91. position: relative;
  92. height: 90vh;
  93. width: 100%;
  94. overflow-y: auto !important;
  95. }
  96. .bottomBox {
  97. position: relative;
  98. height: 10vh;
  99. width: 100%;
  100. //margin-top: 10px;
  101. padding-left: 10px;
  102. color: #FFFFFF;
  103. bottom: 1%;
  104. border-top: #ccc;
  105. .hamburger-container {
  106. // text-align: center;
  107. cursor: pointer;
  108. transition: background 0.3s;
  109. -webkit-tap-highlight-color: transparent;
  110. &:hover {
  111. background: rgba(0, 0, 0, 0.025);
  112. }
  113. }
  114. }
  115. </style>