<template>
  <el-menu class="navbar" mode="horizontal">
    <hamburger :toggle-click="toggleSideBar" :is-active="sidebar.opened" class="hamburger-container"/>
    <div class="avatar-wrapper" style="position: absolute;right: 0;font-family: 'MiSans Medium',serif">
      <!--      <span style="color: white;font-size: 18px;">登录人员 : {{ name }}-->
      <!--        <el-button type="success" size="mini" class="loginin">Login in</el-button>-->
      <!--      </span>-->
      <!--<span style="color: white">[ &nbsp</span> <a style="color: white" @click="logout">登出</a> <span style="color: white">&nbsp ] &nbsp</span>-->
      <!--      <el-button type="success" size="mini" class="loginoff" @click="logout">Log Off</el-button>-->
      <!--<el-tag style="width: 60px; text-align: center">-->
      <!--<a style="color: white" @click="logout">登出</a>-->
      <!--</el-tag>-->
      <!--<img :src="require('@/assets/img/user.jpg')" class="user-avatar">-->
      <el-dropdown class="avatar-container right-menu-item hover-effect" trigger="click">
        <div class="avatar-wrapper">
          <img :src="require('@/assets/img/user.jpg')" class="user-avatar">
        </div>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item>{{ name }}</el-dropdown-item>
          <!--          <router-link to="/">-->
          <!--            <el-dropdown-item>Dashboard</el-dropdown-item>-->
          <!--          </router-link>-->
          <!--          <a target="_blank" href="https://github.com/PanJiaChen/vue-element-admin/">-->
          <!--            <el-dropdown-item>Github</el-dropdown-item>-->
          <!--          </a>-->
          <!--          <a target="_blank" href="https://panjiachen.github.io/vue-element-admin-site/#/">-->
          <!--            <el-dropdown-item>Docs</el-dropdown-item>-->
          <!--          </a>-->
          <el-dropdown-item divided @click.native="logout">
            <span style="display:block;">Log Out</span>
          </el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div>
    <breadcrumb />
  </el-menu>
</template>

<script>
import { mapGetters } from 'vuex'
import Breadcrumb from '@/components/Breadcrumb'
import Hamburger from '@/components/Hamburger'

export default {
  components: {
    Breadcrumb,
    Hamburger
  },
  computed: {
    ...mapGetters([
      'sidebar',
      'avatar',
      'name'
    ])
  },
  mounted() {
  },
  methods: {
    toggleSideBar() {
      this.$store.dispatch('ToggleSideBar')
    },
    logout() {
      this.$store.dispatch('FedLogOut').then(() => {
        location.reload() // 为了重新实例化vue-router对象 避免bug
      })
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  .navbar {
    height: 80px;
    line-height: 80px;
    border-radius: 0px !important;
    background-color: #354387!important;
    .hamburger-container {
      line-height: 88px;
      height: 80px;
      float: left;
      padding: 0 16px;
    }
    .avatar-container {
      height: 50px;
      display: inline-block;
      position: absolute;
      right: 20px;
      .avatar-wrapper {
        cursor: pointer;
        padding-top: 12px;
        position: relative;
        font-size: 16px;
        .user-avatar {
          width: 40px;
          height: 40px;
          border-radius: 10px;
        }
        .el-icon-caret-bottom {
          position: absolute;
          right: -20px;
          top: 25px;
          font-size: 12px;
        }
      }
    }
    .el-tag{
      float: right;
      margin-top: 8px;
      margin-right: 5px;
    }
    .right-menu {
      float: right;
      height: 100%;
      line-height: 50px;
      &: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;
        .avatar-wrapper {
          margin-top: 5px;
          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;
          }
        }
      }
    }
  }
  .loginin {
    font-family: 'MiSans Demibold',serif;
    margin-left: 19px;
    border: 1px solid #fafcff;
    border-radius: 10px;
    width: 88px;
    height: 28px;
    background-color: #fafcff;
    color: #354387;
    font-size: 16px;
    padding: 3px 15px;
    margin-top: 30px
  }
  .loginoff {
    font-family: 'MiSans Demibold',serif;
    margin-left: 15px;
    border-radius: 10px;
    border: 1px solid #fafcff;
    width: 88px;
    height: 28px;
    background-color: #354387;
    color: #fafcff;
    font-size: 16px;
    padding: 3px 15px;
  }
  .TVshow {
    color: #1aba9d;
    width: 50px;
    height: 50px;
    margin-right: 20px;
    line-height: 40px;
    margin-top: 15px;
    cursor: pointer;
  }
  .TVshow1 {
    color: #1aba9d;
    width: 50px;
    height: 50px;
    margin-right: 80px;
    line-height: 40px;
    margin-top: 15px;
    cursor: pointer;
  }
</style>

