<script setup lang="ts">
import { ref } from 'vue';
import { ElMessage } from 'element-plus';

import { useAppStore } from '@/store/modules/app';

const appStore = useAppStore();

const sizeOptions = ref([
  { label: '默认字号', value: 'default' },
  { label: '大字号', value: 'large' }
]);

function handleSizeChange(size: string) {
  appStore.changeSize(size);
  ElMessage.success('切换字号大小成功');
}
</script>

<template>
  <el-dropdown trigger="click" @command="handleSizeChange">
    <div class="cursor-pointerw-[40px] h-[50px] leading-[50px] text-center" style="display: flex; display: -webkit-flex; align-items: center;-webkit-align-items: center;">
      <img src="@/assets/MenuIcon/top_zh.png" alt="">
    </div>
    <template #dropdown>
      <el-dropdown-menu>
        <el-dropdown-item
          v-for="item of sizeOptions"
          :key="item.value"
          :disabled="appStore.size == item.value"
          :command="item.value"
        >
          {{ item.label }}
        </el-dropdown-item>
      </el-dropdown-menu>
    </template>
  </el-dropdown>
</template>
