Navbar.vue 4.17 KB
<template>
  <div class="navbar-con">
    <div class="navbar">
      <div class="sidebarLeft">
        <sidebarLeft />
      </div>
      <div class="sidebarRight d-center">
        <sidebarRight />
        <div class="right-menu">
          <div class="dataView pointer" @click="handleDataView">大屏展示</div>
          <el-dropdown class="avatar-container right-menu-item hover-effect" trigger="hover" @command="handleCommand">
            <div class="avatar-wrapper">
              <span style="padding-right:10px">{{ name }}</span>
              <img :src="avatar + '?imageView2/1/w/80/h/80'" class="user-avatar" />
            </div>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item command="a">个人中心</el-dropdown-item>
              <el-dropdown-item command="b">退出</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import defaultSettings from '@/settings'
import sidebarLeft from './Sidebar/sidebarLeft'
import sidebarRight from './Sidebar/sidebarRight'
import { mapGetters } from 'vuex'
export default {
  components: {
    sidebarLeft,
    sidebarRight
  },
  computed: {
    ...mapGetters(['sidebar', 'avatar', 'name'])
  },
  data () {
    return {
      title: defaultSettings.title
    }
  },
  methods: {
    handleDataView () {
      const { href } = this.$router.resolve('/dataView');
      window.open(href, '_blank');
    },
    themeChange (val) {
      this.$store.dispatch('app/updateTheme', val)
    },
    handleCommand (command) {
      if (command == 'a') {
      }
    }
  }
}
</script>
<style lang="scss" scoped>
/deep/.el-menu--horizontal {
  display: flex;
  align-items: center;
}

.menubg {
  line-height: 30px;
  color: #FFFFFF;
  margin-right: 5px;
  background: linear-gradient(180deg, #0A2580 0%, #2542C9 100%);
}

/deep/.el-menu-item {
  @extend .menubg;
}

/deep/.el-submenu {
  @extend .menubg;
}

/deep/.el-submenu__title {
  line-height: 30px !important;
  height: 42px !important;
}

/deep/.el-submenu__title span {
  font-size: 14px;
}

// 导航选中背景色
.xuanzhong {
  background: linear-gradient(180deg, #73551D 0%, #C09C43 100%);
  font-weight: 700;
  color: #FFFFFF !important;
}

/deep/.el-menu-item:hover {
  @extend .xuanzhong;
}

/deep/.el-submenu__title:hover {
  @extend .xuanzhong;
}

/deep/.el-menu--horizontal .el-menu-item:not(.is-disabled):focus {
  @extend .xuanzhong;
}

/deep/.el-menu-item.is-active {
  @extend .xuanzhong;
}


.navbar {
  height: $headerHeight;
  overflow: hidden;
  position: relative;
  background: linear-gradient(180deg, #0D3DC9 0%, #3476E1 100%);
  display: flex;
  align-items: center;
  padding: 0 20px;
  justify-content: space-between;

  .right-menu {
    float: right;
    height: 100%;
    line-height: 50px;
    display: flex;
    align-items: center;

    .shutdown {
      font-size: 20px;
      margin-left: 15px;
      cursor: pointer;
    }

    .organization-item {
      margin-right: 40px;
      margin-top: -40px !important;
    }

    .item {
      margin-right: 40px;
      margin-top: -20px;
      line-height: 18.4px;
      cursor: pointer;
      position: relative;

      .item-box {
        position: absolute;
        top: -5px;
        left: 3px;
        width: 100%;
        min-width: 25px;
        height: 25px;
        cursor: pointer;
        z-index: 100;
      }
    }

    &:focus {
      outline: none;
    }

    .right-menu-item {
      display: inline-block;
      height: 100%;
      font-size: 18px;
      color: #fff;
      vertical-align: text-bottom;

      &.hover-effect {
        cursor: pointer;
        transition: background 0.3s;
        display: flex;
        align-items: center;

        &:hover {
          background: rgba(0, 0, 0, 0.025);
        }
      }
    }

    .avatar-wrapper {
      position: relative;
      display: flex;
      height: 40px;
      align-items: center;

      .user-avatar {
        cursor: pointer;
        width: 35px;
        height: 35px;
        border-radius: 50%;
      }

      .el-icon-caret-bottom {
        cursor: pointer;
        position: absolute;
        right: -15px;
        top: 17px;
        font-size: 12px;
      }
    }
  }
}
</style>