<template>
  <div class="header" ref="headerMenu">
    <div class="headerBox">
      <div class="logo">后台管理系统</div>
      <div class="adminInfo" v-if="adminInfo">
        <el-dropdown @command="UserCommand" :popper-append-to-body="false">
          <span class="userName"
            >{{ adminInfo.username
            }}<i class="el-icon-caret-bottom userIconSty"></i
          ></span>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item command="logout">退出登录</el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
      </div>
    </div>
  </div>
</template>
<script>
import { mapGetters } from "vuex";
import { getToken } from "@/utils/auth";
export default {
  computed: {
    ...mapGetters("adminUser", ["adminInfo"]),
  },
  components: {},
  data() {
    return {};
  },
  created() {},
  methods: {
    UserCommand(command) {
      if (command == "logout") {
        this.logout();
      }
    },
    logout() {
      this.$store.dispatch("adminUser/adminLogout");
    },
  },
};
</script>
<style lang="scss" scoped>
.header {
  width: 100%;
  height: 60px;
  font-size: 22px;
  color: #fff;
  box-sizing: border-box;
  z-index: 600;
  position: fixed;
  top: 0;
  left: 0;
  // background-color: #2365ae;
  background-color: #2e64fa;
}
.headerBox {
  margin: 0 auto;
  height: 60px;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  .logo {
    padding-left: 25px;
    line-height: 60px;
    font-size: 28px;
  }
  .headerMenu {
    // margin-left:100px;
    // width:816px;
    display: flex;
  }
  .el-menu-wrap {
    height: 60px;
    li {
      font-size: 20px;
      border-bottom: 0;
      &.is-active {
        font-weight: bold;
        background-color: rgba(0, 0, 0, 0.2) !important;
      }
    }
  }
  .userName {
    font-size: 18px;
    margin-right: 30px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 24px;
    color: #fff;
    cursor: pointer;
    .userIconSty {
      margin-left: 6px;
    }
  }
}
:deep() .el-dialog__headerbtn .el-dialog__close {
  color: #909399;
}
:deep() .el-dialog__header {
  text-align: left;
}
:deep() .dialog-footer {
  text-align: right;
}
.el-dropdown-menu {
  left: auto !important; /* 取消默认左对齐 */
  right: 0 !important; /* 右对齐 */
}
</style>
