<template>
  <el-menu class="navbar" mode="horizontal">
    <hamburger :toggle-click="toggleSideBar" :is-active="sidebar.opened" class="hamburger-container"/>
    <div class="avatar-wrapper" style="float:right">
      <span style="color: black">用户 : {{ name }} &nbsp; Log In &nbsp;</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" @click="logout">Log Off</el-button>&nbsp;&nbsp;
      <!--<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">-->
    </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'
    ])
  },
  methods: {
    toggleSideBar() {
      this.$store.dispatch('ToggleSideBar')
    },
    logout() {
      this.$store.dispatch('FedLogOut').then(() => {
        location.reload() // 为了重新实例化vue-router对象 避免bug
      })
    }
  }
}
</script>
<style>
  .el-breadcrumb__inner a, .el-breadcrumb__inner.is-link {
    color: #fff!important;
  }
</style>
<style rel="stylesheet/scss" lang="scss" scoped>
.navbar {
  height: 50px;
  line-height: 50px;
  border-radius: 0px !important;
  background-color: #f6f7f7 !important; // 上侧栏
  .hamburger-container {
    line-height: 58px;
    height: 50px;
    float: left;
    padding: 0 10px;
  }
  .screenfull {
    position: absolute;
    right: 90px;
    top: 16px;
    color: #525f6b;
  }
  .avatar-container {
    height: 50px;
    display: inline-block;
    position: absolute;
    right: 35px;
    .avatar-wrapper {
      cursor: pointer;
      margin-top: 5px;
      position: relative;
      .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;
  }
}
</style>

