<script lang="ts" setup>
import { VbenAvatar } from '@vben-core/shadcn-ui';
interface Props {
  avatar?: string;
}


async function copyDescription() {
  const doc = document.getElementById('description');
  console.log('copyDescription');
  console.log(doc?.innerText);
  navigator.clipboard.writeText(doc?.innerText || '');
  alert('复制成功');
}
defineOptions({
  name: 'WorkbenchHeader',
});

withDefaults(defineProps<Props>(), {
  avatar: '',
});
</script>
<template>
  <div class="card-box p-4 py-6 lg:flex">
    <VbenAvatar :src="avatar" class="size-20" />
    <div
      v-if="$slots.title || $slots.description"
      class="flex flex-col justify-center md:ml-6 md:mt-0"
    >
      <h1 v-if="$slots.title" class="text-md font-semibold md:text-xl">
        <slot name="title"></slot>
      </h1>
      <span v-if="$slots.description" class="text-foreground/80 mt-1" @click='copyDescription' id="description">
        <slot name="description"></slot>
      </span>
    </div>
    <div class="mt-4 flex flex-1 justify-end md:mt-0">
      <div class="flex flex-col justify-center text-right">
        <span class="text-foreground/80"> LEVEL </span>
        <span class="text-2xl text-center" v-if="$slots.level">
          <slot name="level"> </slot>
        </span>
      </div>
      <div class="flex flex-col justify-center text-right md:ml-12">
        <span class="text-foreground/80 text-center"> ⚡ </span>
        <span class="text-2xl text-center" v-if="$slots.energy">
          <slot name="energy"> </slot>
        </span>
      </div>

      <div class="mx-12 flex flex-col justify-center text-right md:mx-12">
        <span class="text-foreground/80 text-center"> ⭐ </span>
        <span class="text-2xl text-center" v-if="$slots.star">
          <slot name="star"> </slot>
        </span>
      </div>
      <div class="mr-4 flex flex-col justify-center text-right md:mr-10">
        <span class="text-foreground/80 text-center"> 💎 </span>
        <span class="text-2xl text-center" v-if="$slots.diamond">
          <slot name="diamond"> </slot>
        </span>
      </div>
    </div>
  </div>
</template>
