<script setup>
import { ref } from 'vue';
import { user } from '~/store/index';
const APP_TITLE = ref(document.title)
function handleCommand(command) {
  switch (command) {
    case 'loginOut':
      if (sessionStorage.getItem('userInfo')) {
          sessionStorage.removeItem('userInfo');
        window.open(window.GLOBAL_CONFIG.origin, '_self');
        // loginShow = true;
      }
      break;
    case 'home':
      window.open(window.GLOBAL_CONFIG.origin, '_self');
  }
}
</script>

<template>
  <div class="header w-full h-50px leading-50px line px-4 text-xl text-white tracking-wider">
    <div>
      <img src="/images/header/logo.png" style="width: 162px;margin-top: 5px;" alt="">
    </div>
    <div>
      <span class="icon-message"></span>
      <el-dropdown @command="handleCommand">
        <div>
          <div class="shot pr hand">
            <img :src="user.user_avatar" alt="" :key="user?.user_avatar">
            <span class="dot"></span>
          </div>
          <h3 class="shot-name">{{user.user_realname}}</h3>
        </div>

        <template #dropdown>
          <el-dropdown-menu>
            <el-dropdown-item command="home">首页</el-dropdown-item>
            <el-dropdown-item command="loginOut">退出登录</el-dropdown-item>
          </el-dropdown-menu>
        </template>
      </el-dropdown>

    </div>
  </div>
</template>
<style lang="scss">
.header {
  display: flex;
  justify-content: space-between;
  background: #00a3ff;
  .icon-message {
    margin-right: 20px;
    display: inline-block;
    vertical-align: middle;
    width: 16px;
    height: 20px;
    background: url("/images/header/icon-message.png") center no-repeat;
  }
}
.shot {
  margin-top: 2px;
  position: relative;
  cursor: pointer;
  display: inline-block;
  vertical-align: middle;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #fff;
  overflow: hidden;
  img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
  }

  .dot {
    position: absolute;
    right: 1px;
    bottom: 1px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #3ebb92;
    border: 2px solid #f1fef6;
  }
}
.shot-name {
  margin-left: 10px;
  display: inline-block;
  vertical-align: middle;
  font-size: 14px;
  color: #fff;
  line-height: 50px;
}
</style>

