<template>
  <div class="header">
    <div class="header-left">
      <img class="header-logo-img" src="../../assets/logo.png" />

      <span>音频标注检索</span>
    </div>
    <div class="header-right">
      <a-space>
        <div class="header-right-profile">
          <a-dropdown trigger="hover" @select="handleSelect">
            <div class="header-right-profile">
              <span><icon-user /></span>
              <span>{{ currentUser }}</span>
            </div>

            <template #content>
              <a-doption value="logout"><icon-export />退出登录</a-doption>
            </template>
          </a-dropdown>
        </div>
      </a-space>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue';
import { useRouter } from 'vue-router';

const router = useRouter();
const currentUser = ref('admin');

const handleSelect = (key) => {
  if (['logout'].includes(key)) {
    router.push('/login');
  }
};
</script>

<style lang="css" scoped>
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;

  height: 60px;
  background-color: var(--color-bg-1);
}

.header-left {
  width: 240px;
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  align-items: center;

  color: var(--color-text-1);
  font-size: 18px;
  font-weight: bold;
}

.header-logo-img {
  width: 36px;
  margin-right: 5px;
}

.header-center {
  flex-grow: 1;

  padding-left: 15px;
  padding-right: 15px;
}

.header-right {
  display: flex;
  justify-content: flex-end;
  padding-right: 15px;
}

.header-right-item {
  color: var(--color-text-2);
  width: 30px;
  height: 30px;
  border-radius: 20px;
  border: solid 1px var(--color-border-2);

  display: flex;
  justify-content: center;
  align-items: center;

  cursor: pointer;
}

.header-right-profile {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}
</style>
