index.vue 2.05 KB
Newer Older
花裤衩's avatar
花裤衩 committed
1
<template>
yanzhongrong's avatar
yanzhongrong committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
  <div :class="{ 'has-logo': showLogo }">
    <el-menu
      :default-active="activeMenu"
      :unique-opened="false"
      :collapse-transition="false"
      mode="horizontal"
      :background-color="variables.menuBg"
      :text-color="variables.menuText"
      :active-text-color="variables.menuActiveText"
      class="frame-menu"
    >
      <sidebar-item
        v-for="route in routes"
        :key="route.path"
        :item="route"
        :base-path="route.path"
        ref="list"
      />
    </el-menu>
花裤衩's avatar
花裤衩 committed
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import Logo from './Logo'
import SidebarItem from './SidebarItem'
import variables from '@/styles/variables.scss'

export default {
  components: { SidebarItem, Logo },
  computed: {
    ...mapGetters([
      'sidebar'
    ]),
Pan's avatar
Pan committed
36 37 38
    routes() {
      return this.$router.options.routes
    },
花裤衩's avatar
花裤衩 committed
39
    activeMenu() {
yanzhongrong's avatar
yanzhongrong committed
40 41
      const route = this.$route;
      const { meta, path } = route;
花裤衩's avatar
花裤衩 committed
42 43
      // if set path, the sidebar will highlight the path you set
      if (meta.activeMenu) {
yanzhongrong's avatar
yanzhongrong committed
44
        return meta.activeMenu;
花裤衩's avatar
花裤衩 committed
45
      }
yanzhongrong's avatar
yanzhongrong committed
46
      return path;
花裤衩's avatar
花裤衩 committed
47 48 49 50 51 52 53 54 55 56
    },
    showLogo() {
      return this.$store.state.settings.sidebarLogo
    },
    variables() {
      return variables
    },
  }
}
</script>
yanzhongrong's avatar
yanzhongrong committed
57 58
<style lang="scss" scoped>
.frame-menu {
yanzhongrong's avatar
yanzhongrong committed
59
  padding-left: 30px;
yanzhongrong's avatar
yanzhongrong committed
60
  border: none;
neogcg's avatar
neogcg committed
61 62
  height: 56px;
  width: 100% !important;
yanzhongrong's avatar
yanzhongrong committed
63 64 65
  white-space: nowrap;
  &.el-menu--horizontal {
    border-bottom: none !important;
yanzhongrong's avatar
yanzhongrong committed
66
    display: flex;
yanzhongrong's avatar
yanzhongrong committed
67
    > .menu-wrapper {
yanzhongrong's avatar
yanzhongrong committed
68
      // display: inline-block;
yanzhongrong's avatar
yanzhongrong committed
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
      > a {
        // display: inline-block;
        > .el-menu-item {
          display: inline-block;
          margin: 0;
          border-bottom: 2px solid transparent;
          padding: 0 5px;
        }
      }
      > .el-submenu {
        display: inline-block;
        .el-submenu__title {
          border-bottom: 2px solid transparent;
        }
        .el-submenu__icon-arrow {
          position: static;
          vertical-align: middle;
          margin-left: 8px;
          margin-top: -3px;
        }
      }
    }
  }
}
</style>