<!--
 * @Descripttion: 
 * @version: 
 * @Author: ysh
 * @Date: 2023-06-07 14:09:47
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2023-06-20 10:54:20
-->
<template>
  <div class="map-container">
    <div class="header">
      <div class="header-left">
        <div class="header-log"></div>
        <div class="header-title">影像智能解译平台</div>
      </div>
      <div class="header-nav">
        <el-dropdown @command="handleCommand" class="right-menu-item hover-effect" trigger="click">
          <div class="avatar-wrapper">
            欢迎您，<span>{{ userName }}</span>
            <el-icon><caret-bottom /></el-icon>
          </div>
          <template #dropdown>
            <el-dropdown-menu>
              <el-dropdown-item divided command="logout">
                <span>退出登录</span>
              </el-dropdown-item>
            </el-dropdown-menu>
          </template>
        </el-dropdown>
      </div>
    </div>
    <div class="main">
      <Maps></Maps>
    </div>
  </div>
</template>

<script setup lang="ts">
import Maps from './maps.vue';
import useUserStore from '@/store/modules/user';
import { ElMessageBox } from 'element-plus'
const userStore = useUserStore();

const userName = userStore.name;
function handleCommand(command) {
  switch (command) {
    case "logout":
      logout();
      break;
    default:
      break;
  }
}
function logout() {
  ElMessageBox.confirm('确定注销并退出系统吗？', '提示', {
    confirmButtonText: '确定',
    cancelButtonText: '取消',
    type: 'warning'
  }).then(() => {
    userStore.logOut().then(() => {
      location.href = '/index';
    })
  }).catch(() => { });
}
</script>

<style scoped lang="scss">
.map-container {
  width: 100%;
  height: 100vh;
  background-color: #151515;

  .header {
    width: 100%;
    padding: 0px 20px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;

    .header-left {
      display: flex;
      .header-log {
        margin-top: 5px;
        padding-left: 10px;
        margin-right: 10px;
        width: 50px;
        height: 50px;
        background: url("../../assets/images/map/smart-logo.png") no-repeat;
        background-size: 100% 100%;
      }

      .header-title {
        padding-left: 10px;
        height: 100%;
        text-align: center;
        line-height: 60px;
        font-size: 18px;
        color: #ffffff;
        font-weight: bold;
        letter-spacing: 3px;
      }
    }


    .header-nav {
      max-width: 300px;
      min-width: 200px;
      color: #fff;
    }
  }

  :deep(.el-dropdown) {
    color: #fff;
  }

  .main {
    width: 100%;
    height: calc(100vh - 60px);
    background-color: #fff;
  }

  .avatar-container {
    margin-right: 40px;

    .avatar-wrapper {
      margin-top: 5px;
      position: relative;
      color: #fff;

      .user-avatar {
        cursor: pointer;
        width: 40px;
        height: 40px;
        border-radius: 10px;
      }

      i {
        cursor: pointer;
        position: absolute;
        right: -20px;
        top: 25px;
        font-size: 12px;
      }
    }
  }
}
</style>