<template>
  <el-header class="btn-bar">
    <slot></slot>
    <el-button v-if="$attrs.uploadJson" type="text" @click="emits('uploadJson')">
      <template #icon>
        <SvgIcon iconClass="upload" />
      </template>
      导入JSON
    </el-button>
    <el-button v-if="$attrs.clearable" type="text" @click="emits('clearable')">
      <template #icon>
        <SvgIcon iconClass="clearable" />
      </template>
      清空
    </el-button>
    <el-button v-if="$attrs.preview" type="text" @click="emits('preview')">
      <template #icon>
        <SvgIcon iconClass="preview" />
      </template>
      预览
    </el-button>
    <el-button v-if="$attrs.generateJson" type="text" @click="emits('generateJson')">
      <template #icon>
        <SvgIcon iconClass="generate-json" />
      </template>
      生成JSON
    </el-button>
    <el-button v-if="$attrs.generateCode" type="text" @click="emits('generateCode')">
      <template #icon>
        <SvgIcon iconClass="generate-code" />
      </template>
      生成代码
    </el-button>
  </el-header>
</template>

<script lang="ts" setup>
import SvgIcon from '../../components/SvgIcon.vue'

const emits = defineEmits(['uploadJson', 'clearable', 'preview', 'generateJson', 'generateCode'])
</script>

<style lang="scss" scoped>
:deep(.el-icon) {
  width: 2em;
}
</style>
