import type { App } from 'vue'
import FcDesigner from '@form-create/designer'
import formCreate from '@form-create/element-ui'
import install from '@form-create/element-ui/auto-import'
//======================= 自定义组件 =======================
import { UploadFile, UploadImg, UploadImgs } from '@/components/UploadFile'
import { DictSelect } from '@/components/DictSelect'
import UserSelect from '@/views/system/auth/userList/UserSelect.vue'
import { Editor } from '@/components/Editor'

// Element Plus 已在 main.ts 通过 app.use(ElementPlus) 全局注册，此处仅注册 form-create 自定义组件
const components = [UploadImg, UploadImgs, UploadFile, DictSelect, UserSelect, Editor]

// 参考 http://www.form-create.com/v3/element-ui/auto-import.html 文档
export const setupFormCreate = (app: App<Element>) => {
  components.forEach((component) => {
    app.component(component.name!, component)
  })
  formCreate.use(install)
  app.use(formCreate)
  app.use(FcDesigner)
}
