<template>
  <el-row>
    <el-col :span="8">
      <div class="menu-header">
        <img
          src="D:\code\Restaurant-management-system\uni-frontend\vue-beta\src\assets\image\logo.png"
          alt="Logo"
          class="logo"
        />
        <span class="divider">|</span>
        <span class="title">商户线上经营平台</span>
      </div>
    </el-col>
    <el-col :span="8"> </el-col>
    <el-col :span="8">
      <div class="user-section">
        <el-avatar
          :size="40"
          src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png"
          alt="用户头像"
        >
        </el-avatar>
        <el-dropdown>
          <span class="user"
            >{{ user.name }}<el-icon class="el-icon--right"><arrow-down /></el-icon
          ></span>
          <template #dropdown>
            <el-dropdown-menu>
              <el-dropdown-item command="a">账号管理</el-dropdown-item>
              <el-dropdown-item command="b">资质认证</el-dropdown-item>
              <el-dropdown-item command="c">退出账号</el-dropdown-item>
              <!-- <el-dropdown-item command="d" disabled>Action 4</el-dropdown-item>
              <el-dropdown-item command="e" divided>Action 5</el-dropdown-item> -->
            </el-dropdown-menu>
          </template>
        </el-dropdown>
        <span class="divider">|</span>
        <el-icon @click="handleClick" class="notification-icon" :size="20">
          <Bell />
        </el-icon>
      </div>
    </el-col>
  </el-row>
</template>

<script setup lang="ts">
import { ref } from 'vue'
const user = ref({ name: 'admin' })

const emit = defineEmits(['collapse-change', 'button-click', 'input-change'])

const handleClick = () => {
  // 派发事件，不传参数
  emit('button-click')
}
</script>

<style scoped>
.menu-header,
.user-section {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  height: 60px;
}

.user-section {
  justify-content: flex-end;
}

.logo {
  height: 40px;
  width: auto;
  object-fit: contain;
}

.divider {
  font-size: 24px;
  font-weight: bold;
  color: #909399;
  margin: 0 8px;
}

.title {
  font-size: 18px;
  font-weight: bold;
  color: #303133;
  letter-spacing: 1px;
}

.user {
  font-size: 14px;
  color: #606266;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 4px;
  transition: all 0.3s ease;
  outline: unset;
}

.notification-icon {
  color: #909399;
  cursor: pointer;
  transition: color 0.3s;
}

.notification-icon:hover {
  color: #409eff;
}

/* 响应式优化 */
@media (max-width: 768px) {
  .title {
    font-size: 16px;
  }

  .logo {
    height: 32px;
  }

  .divider {
    font-size: 20px;
  }
}
</style>
