<template>
  <div class="navbar-container">
    <hamburger id="hamburger-container" :is-active="collapse" class="hamburger-container" @toggleClick="toggleSideBar" />

    <breadcrumb id="breadcrumb-container" class="breadcrumb-container" />

    <div class="right-menu">
      <template v-if="device !== 'mobile'">
        <el-tooltip content="刷新页面" effect="dark" placement="bottom">
          <div class="right-menu-item">
            <i class="page-refresh el-icon-refresh" @click.stop="pageRefresh"></i>
          </div>
        </el-tooltip>

        <el-tooltip content="菜单搜索" effect="dark" placement="bottom">
          <search id="header-search" class="right-menu-item" />
        </el-tooltip>

        <el-tooltip content="错误日志" effect="dark" placement="bottom">
          <error-log class="errLog-container right-menu-item hover-effect" />
        </el-tooltip>

        <el-tooltip content="页面全屏" effect="dark" placement="bottom">
          <screen-full id="screenFull" class="right-menu-item hover-effect" />
        </el-tooltip>

        <el-tooltip content="布局大小" effect="dark" placement="bottom">
          <size-select id="size-select" class="right-menu-item hover-effect" />
        </el-tooltip>

        <!--<el-tooltip content="布局设置" effect="dark" placement="bottom">
          <right-panel id="right-panel" class="right-menu-item hover-effect">
            <settings />
          </right-panel>
        </el-tooltip>-->
      </template>
      <Avatar></Avatar>
    </div>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
import { Avatar, Breadcrumb, ErrorLog, Hamburger, ScreenFull, Search, SizeSelect } from "../index";
import SvgIcon from "../SvgIcon/index";

export default {
  components: {
    SvgIcon,
    Avatar,
    Breadcrumb,
    Hamburger,
    ErrorLog,
    ScreenFull,
    SizeSelect,
    Search,
    /*RightPanel,
      Settings,*/
  },
  computed: {
    ...mapGetters({
      collapse: "settings/collapse",
      device: "settings/device",
      themeBar: "settings/themeBar",
    }),
  },
  methods: {
    toggleSideBar() {
      this.$store.dispatch("settings/toggleSideBar");
    },
    pageRefresh() {
      const view = this.$route;
      this.$store.dispatch("tagsView/delCachedView", view).then(() => {
        const { fullPath } = view;
        this.$nextTick(() => {
          this.$router.replace({
            path: "/redirect" + fullPath,
          });
        });
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.navbar-container {
  height: $base-nav-bar-height;
  padding-right: $base-padding;
  overflow: hidden;
  position: relative;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);

  .hamburger-container {
    line-height: 46px;
    height: 100%;
    float: left;
    cursor: pointer;
    transition: background 0.3s;
    -webkit-tap-highlight-color: transparent;

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

  .breadcrumb-container {
    float: left;
  }

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

  .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 0.3s;

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

      .page-refresh {
        cursor: pointer;
        font-size: 20px;
        vertical-align: middle;
      }
    }

    .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;
        }
      }
    }
  }
}
</style>
