// auto-import.ts
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import type { PluginOption } from 'vite'

export default function createAutoImport(): PluginOption[] {
  return [
    AutoImport({
      // 自动导入 Vue、Vue Router、Pinia 的 API
      imports: ['vue', 'vue-router', 'pinia'],
      // 同时保留 Element Plus 的解析器
      resolvers: [ElementPlusResolver()],
      // 生成类型声明文件
      dts: true
    }),
    Components({
      resolvers: [ElementPlusResolver()]
    })
  ]
}
