<template>
  <div class="header-container">
    <div class="left-section">
      <span :class="collapseBtnClass" class="collapse-icon" @click="collapse"></span>
    </div>
    <div class="logout-container">
      <span class="logout-btn" @click="logout">退出</span>
    </div>
  </div>
</template>

<script>
export default {
  name: "Header",
  props: {
    collapseBtnClass: String,
    collapse: Boolean,
  },
  methods: {
    logout() {
      // 执行登出操作
      this.$store.dispatch("logout"); // 调用 Vuex 登出逻辑
      this.$router.push("/login"); // 跳转到登录页面
    },
  }
}
</script>

<style scoped lang="scss">
.header-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  line-height: 50px;
  padding: 0 20px;
  border-bottom: 1px solid #ddd;
}

.left-section {
  flex: 1;
}

.collapse-icon {
  cursor: pointer;
  font-size: 20px;
}

.logout-container {
  display: flex;
  align-items: center;
}

.logout-btn {
  cursor: pointer;
  font-size: 16px;
  color: #409EFF;
  padding: 5px 10px;
  border-radius: 4px;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.logout-btn:hover {
  background-color: #409EFF;
  color: #fff;
}
</style>
