<template>
  <div class="navbar">
    <div class="line"></div>
    <hamburger
      id="hamburger-container"
      :is-active="sidebar.opened"
      class="hamburger-container"
      @toggleClick="toggleSideBar"
    />

    <top-nav id="topmenu-container" class="topmenu-container" v-if="topNav" />

    <div class="right-menu">
      <!-- 通知 -->
      <!-- <div class="right-menu-item" @click="handleBell">
        <el-badge :value="uradMess" class="item">
          <img src="@/assets/bell.png" alt="" class="quit" height="25" />
        </el-badge>
      </div> -->

      <!-- 设置 -->
      <el-dropdown class="right-menu-item" trigger="click" size="default">
        <img src="@/assets/set.png" alt="" class="quit" height="25" />
        <el-dropdown-menu slot="dropdown">
          <router-link to="/personalCenter">
            <el-dropdown-item>
              <i class="el-icon-user-solid" />账户信息
            </el-dropdown-item>
          </router-link>
          <el-dropdown-item>
            <screenfull id="screenfull" class="right-menu-item" />
          </el-dropdown-item>
          <el-dropdown-item divided @click.native="logout">
            <i class="el-icon-s-promotion" /><span>退出登录</span>
          </el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
      <div class="right-line"></div>
      <div class="ava-img">
        <img src="@/assets/touxiang.png" alt="" />
        <span>{{ $store.state.user.username }}</span>
      </div>
    </div>
    <notice-dialog />
  </div>
</template>

<script>
import bus from "@/views/bus";
import { mapGetters } from "vuex";
import TopNav from "@/components/TopNav";
import Hamburger from "@/components/Hamburger";
import Screenfull from "@/components/Screenfull";
import Search from "@/components/HeaderSearch";
import SizeSelect from "@/components/SizeSelect";
import noticeDialog from "@/views/dashboard/components/noticeDialog";
export default {
  components: {
    Hamburger,
    TopNav,
    Screenfull,
    SizeSelect,
    Search,
    noticeDialog
  },
  computed: {
    ...mapGetters(["sidebar", "avatar", "unreadMess"]),
    topNav: {
      get() {
        return this.$store.state.settings.topNav;
      }
    },
    uradMess: {
      get() {
        return this.$store.state.user.unreadMess;
      }
    }
  },
  data() {
    return {
      value: 0
    };
  },
  created() {},
  methods: {
    toggleSideBar() {
      this.$store.dispatch("app/toggleSideBar");
    },

    async logout() {
      await this.$store.dispatch("user/logout");
      this.$router.push(`/login`);
    },
    handleBell() {
      bus.$emit("dialogNoticeVisible", true);
      // this.$router.push({
      //   path: "/mission/missionmy",
      //   query: { item: "bell" }
      // });
    }
  }
};
</script>

<style lang="scss" scoped>
$bg_color: #3c64dc;

.navbar {
  height: 50px;
  box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
  overflow: hidden;
  position: relative;
  background: #fff;
  .line {
    float: left;
    width: 1px;
    height: 30px;
    border-left: 1px solid #a0a0a0;
    margin-top: 10px;
  }
  .hamburger-container {
    line-height: 50px;
    height: 100%;
    float: left;
    cursor: pointer;
    transition: background 0.3s;
    -webkit-tap-highlight-color: transparent;

    &:hover {
      background: rgba(0, 0, 0, 0.025);
    }
  }
  .topmenu-container {
    position: absolute;
    left: 50px;
  }

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

  .right-menu {
    float: right;
    height: 100%;
    line-height: 50px;
    overflow: hidden;
    vertical-align: middle;
    &:focus {
      outline: none;
    }

    .right-menu-item {
      display: inline-block;
      padding: 0 0 0 22px;
      height: 100%;
      vertical-align: text-bottom;
    }
  }
}
.quit {
  font-size: 26px;
  cursor: pointer;
  vertical-align: middle;
}
.right-line {
  display: inline-block;
  margin: 0 20px 5px 25px;
  width: 1px;
  height: 30px;
  border-left: 1px solid #a0a0a0;
}
.ava-img {
  display: inline-block;
  vertical-align: top;
  margin-right: 25px;

  img {
    width: 30px;
    vertical-align: middle;
    margin-right: 5px;
  }
  span {
    font-size: 14px;
    vertical-align: middle;
  }
}
::v-deep .el-badge__content.is-fixed {
  top: 18px;
  right: 10px;
}
.el-dropdown-menu__item i {
  margin-right: 10px;
}
</style>
