<template>
  <div>
    <el-dropdown trigger="click" @command="handleSetSize">
      <div class="size-icon--style">
        <svg-icon class-name="size-icon" icon-class="size" />
      </div>
      <template #dropdown>
        <el-dropdown-menu>
          <el-dropdown-item v-for="item of sizeOptions" :key="item.value" :disabled="size === item.value" :command="item.value">
            {{ item.label }}
          </el-dropdown-item>
        </el-dropdown-menu>
      </template>
    </el-dropdown>
  </div>
</template>

<script setup>
/*----------------------------------依赖引入-----------------------------------*/
import { ElMessageBox } from "element-plus";
import { useRouter, useRoute } from "vue-router";
import { ref, onMounted, getCurrentInstance } from "vue";
/*----------------------------------接口引入-----------------------------------*/
/*----------------------------------组件引入-----------------------------------*/
/*----------------------------------store引入-----------------------------------*/
import { useAppStore } from "@/store/modules/index";
/*----------------------------------公共方法引入-----------------------------------*/
/*----------------------------------变量声明-----------------------------------*/
const route = useRoute();
const router = useRouter();
const appStore = useAppStore();
const size = computed(() => appStore.size);
const { proxy } = getCurrentInstance();
/*----------------------------------公共变量-----------------------------------*/
const sizeOptions = ref([
  { label: "�ϴ�", value: "large" },
  { label: "Ĭ��", value: "default" },
  { label: "��С", value: "small" },
]);

function handleSetSize(size) {
  proxy.$modal.loading("�������ò��ִ�С�����Ժ�...");
  appStore.setSize(size);
  setTimeout("window.location.reload()", 1000);
}
</script>

<style lang="scss" scoped>
.size-icon--style {
  font-size: 18px;
  line-height: 50px;
  padding-right: 7px;
}
</style>
