<template>
  <div class="navbar">
    <svg-icon icon-class="navLogo" class="nav-logo" />
    <!-- <hamburger :is-active="sidebar.opened" class="hamburger-container" @toggleClick="toggleSideBar" /> -->
    <div class="breadcrumb-container">
      <div v-if="$route.path !== '/dashboard'" class="breadcrumb-box">
        <breadcrumb />
      </div>
    </div>

    <div class="right-menu">
      <!-- <span class="name">{{ userInfo.nickname }}</span> -->
      <el-dropdown class="avatar-container" trigger="click">
        <div class="avatar-wrapper">
          <!-- <img :src="avatar+'?imageView2/1/w/80/h/80'" class="user-avatar"> -->
          <svg-icon icon-class="navUser" style="width: 40px; height: 40;" />
          <!-- <i class="el-icon-caret-bottom" /> -->
        </div>
        <el-dropdown-menu slot="dropdown" class="user-dropdown">
          <el-dropdown-item @click.native="logout">
            <span style="display:block;">退出</span>
          </el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'

// import Hamburger from '@/components/Hamburger'

export default {
  components: {
    // Hamburger
  },
  computed: {
    ...mapGetters([
      'sidebar',
      'avatar',
      'userInfo'
    ])
  },
  methods: {
    toggleSideBar() {
      this.$store.dispatch('app/toggleSideBar')
    },
    async logout() {
      await this.$store.dispatch('user/logout')
      // this.$router.push(`/login?redirect=${this.$route.fullPath}`)
      this.$router.push(`/login`)
    }
  }
}
</script>

<style lang="scss" scoped>
.navbar {
  border-radius: 8px;
  height: 60px;
  margin-top: 10px;
  overflow: hidden;
  position: relative;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;

  justify-content: right;
  -ms-flex-wrap: wrap;
  flex-wrap: wrap;
  box-shadow: 0px 0px 5px #ccc;
  .nav-logo {
    display: none;
    width: 136px;
    height: 42px;
    line-height: 60px;
    margin-left: 40px;
  }

  .breadcrumb-container {
    flex-grow: 1;
  }

  .right-menu {
    flex-grow: 0;
    height: 100%;
    // line-height: 50px;
    // margin-top: 30px;
    .name {
      font-size: 16px;
      color: #e0e0e0;
      margin-right: 20px;
    }
    &:focus {
      outline: none;
    }

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

      &.hover-effect {
        cursor: pointer;
        transition: background .3s;

        &:hover {
          background: rgba(0, 0, 0, .025)
        }
      }
    }

    .avatar-container {
      margin-right: 30px;
      cursor: pointer;
      .avatar-wrapper {
        margin-top: 10px;
        position: relative;

        .user-avatar {
          cursor: pointer;
          width: 40px;
          height: 40px;
          border-radius: 10px;
        }

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