import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'

import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import api from './utils/request'
import { utils } from '@/utils/utils'
import zhCn from 'element-plus/es/locale/lang/zh-cn'

// 创建应用实例
const app = createApp(App)

// 全局注册 Element Plus 图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

// 设置全局属性
app.config.globalProperties.$http = api // axios
app.config.globalProperties.$utils = utils // 公共方法

// 使用 store 和 router
app.use(store).use(router).use(ElementPlus, { locale: zhCn })

// 挂载到 DOM
app.mount('#app')
