index.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <template>
  2. <el-container :class="{'has-logo':showLogo}">
  3. <el-header style="padding: 0; height: auto;"> <logo v-if="showLogo" :collapse="isCollapse" /></el-header>
  4. <el-main style="padding: 0;">
  5. <el-scrollbar wrap-class="scrollbar-wrapper">
  6. <el-menu
  7. :default-active="activeMenu"
  8. :collapse="isCollapse"
  9. :background-color="variables.menuBg"
  10. :text-color="variables.menuText"
  11. :unique-opened="false"
  12. :active-text-color="variables.menuActiveText"
  13. :collapse-transition="false"
  14. mode="vertical"
  15. >
  16. <sidebar-item v-for="route in routes" :key="route.path" :item="route" :base-path="route.path" />
  17. </el-menu>
  18. </el-scrollbar>
  19. </el-main>
  20. <el-footer class="Efooter" style="padding:2% 0 10% 0; min-height: 5%;">
  21. <el-divider style="color: #EEF0F5; margin: 0px;" />
  22. <hamburger :is-active="sidebar.opened" class="hamburger-containers" @toggleClick="toggleSideBar" />
  23. </el-footer>
  24. </el-container>
  25. </template>
  26. <script>
  27. import { mapGetters } from 'vuex'
  28. import Logo from './Logo'
  29. import SidebarItem from './SidebarItem'
  30. import variables from '@/styles/variables.scss'
  31. import { logoutUrl } from '@/apiConfig/requestIP.js'
  32. import Hamburger from '@/components/Hamburger'
  33. export default {
  34. components: { SidebarItem, Logo, Hamburger },
  35. computed: {
  36. ...mapGetters([
  37. 'sidebar',
  38. 'routes'
  39. ]),
  40. // routes() {
  41. // return this.$router.options.routes
  42. // },
  43. activeMenu() {
  44. const route = this.$route
  45. const { meta, path } = route
  46. // if set path, the sidebar will highlight the path you set
  47. if (meta.activeMenu) {
  48. return meta.activeMenu
  49. }
  50. return path
  51. },
  52. showLogo() {
  53. return this.$store.state.settings.sidebarLogo
  54. },
  55. variables() {
  56. return variables
  57. },
  58. isCollapse() {
  59. return !this.sidebar.opened
  60. }
  61. },
  62. methods: {
  63. toggleSideBar() {
  64. this.$store.dispatch('app/toggleSideBar')
  65. },
  66. Logout() {
  67. location.href = logoutUrl
  68. }
  69. }
  70. }
  71. </script>
  72. <style>
  73. .hamburger-containers {
  74. line-height: 46px;
  75. height: 100%;
  76. float: right;
  77. cursor: pointer;
  78. -webkit-tap-highlight-color:transparent;
  79. padding: 0px 20px !important;
  80. color: red !important;
  81. background: #FFF !important;
  82. }
  83. .Efooter .el-divider--horizontal {
  84. display: block;
  85. height: 1px;
  86. width: 100%;
  87. margin: 0;
  88. }
  89. </style>
  90. <style lang="stylus">
  91. .btn span {
  92. display: flex;
  93. align-items: center;
  94. justify-content: center;
  95. }
  96. .el-submenu__title i {
  97. color: #333B4A;
  98. }
  99. </style>