<template>
  <div class="navbar">
    <hamburger
      class="hamburger-container"
      :toggle-click="toggleSideBar"
      :is-active="sidebar.opened"/>

    <breadcrumb class="breadcrumb-container"/>

    <div class="right-menu">
      <ul class="right-menu">
        <li>
          <a @click="handleFull">
            全屏
          </a>
        </li>
        <li>
          <a @click="logout">
            退出登录
          </a>
        </li>
      </ul>
    </div>
  </div>
</template>

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

export default {
  components: {
    Breadcrumb,
    Hamburger,
    // ErrorLog,
    LangSelect
    // ThemePicker
  },
  computed: {
    ...mapGetters([
      'sidebar',
      'name',
      'avatar'
    ])
  },
  methods: {
    toggleSideBar () {
      this.$store.dispatch('toggleSideBar')
    },
    logout () {
      this.$store.dispatch('LogOut').then(() => {
        this.$router.push('/login')
        location.reload()// In order to re-instantiate the vue-router object to avoid bugs
      })
    },
    handleFull () {
      if (!screenfull.enabled) {
        this.$message({
          message: 'you browser can not work',
          type: 'warning'
        })
        return false
      }
      screenfull.toggle()
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
.navbar {
  height: 50px;
  border-radius: 0 !important;
  background: #fff;
  color: #ccc;
  position: relative;
  box-shadow: 0 1px 4px rgba(0, 21, 41, .1);
  z-index: 1;

  .hamburger-container {
    float: left;
    height: 50px;
    padding: 0 10px;
    line-height: 58px;
  }

  .breadcrumb-container {
    float: left;
  }

  .errLog-container {
    display: inline-block;
    vertical-align: top;
  }

  .right-menu {
    display: flex;
    float: right;
    height: 50px;
    align-items: center;
    font-size: 13px;

    a {
      color: $blue;
      display: inline-block;
      padding: 0 10px;

      &:hover {
        color: $activeGreen;
        text-decoration: underline;
      }
    }

    li {
      border-right: 1px solid $blue;

      &:last-child {
        border: none;
      }
    }

    &:focus {
      outline: none;
    }
  }
}
</style>

<style>
.navbar .svg-icon{
  cursor: pointer;
  width: 20px;
  height: 20px;
}
</style>
