<template>
  <div class="header-box">
    <div class="center">
      <div class="logo-box">
        <span class="el-dropdown-link">
          <!-- <img src="../../../assets/images/page/login/logoWinsea.png" /> -->
        </span>
      </div>
      <el-menu :default-active="headState" :router="true" mode="horizontal" background-color="#000" text-color="#999" active-text-color="#fff" @select="handleSelect">
        <el-menu-item index="/lessee">租户管理</el-menu-item>
        <el-menu-item index="/accountList">账号管理</el-menu-item>
        <!-- <el-menu-item index="/new">新闻</el-menu-item> -->
        <!-- <el-menu-item index="/help">在线帮助</el-menu-item> -->
      </el-menu>
      <div class="logout" @click="handleCommand">退出登录</div>
    </div>
  </div>
</template>

<script>
export default {
  name: "Navigation",
  data() {
    return {
      headState: "",
      companyName: localStorage.getItem("companyName"),
      companyLogo: localStorage.getItem("companyLogo")
    };
  },
  created() {
    const key = localStorage.getItem("click0");
    if (key === null || key === "null") {
      this.headState = "/lessee";
    } else {
      this.headState = key;
    }
    this.handleSelect(this.headState);
  },
  methods: {
    handleSelect(key) {
      localStorage.setItem("click0", key);
    },
    handleCommand() {
      localStorage.setItem("click0", null);
      this.$store.dispatch("user/logout");
      this.$router.push(`/login?redirect=${this.$route.fullPath}`);
    }
  }
};
</script>

<style scoped lang="scss">
.header-box {
  background-color: #000000;
  width: 100%;
  .center {
    width: 1200px;
    margin: 0 auto;
    padding-right: 0px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    .logo-box {
      height: 60px;
      line-height: 60px;
      img {
        display: inline-block;
        padding-bottom: 2px;
        height: 20px;
        width: 100px;
      }
      p {
        display: inline-block;
        color: #999;
        font-size: 15px;
      }
    }
    .logout {
      color: rgb(153, 153, 153);
    }
    .logout:hover {
      cursor: pointer;
      color: #ffffff;
    }
  }
}
</style>
