import { createApp } from 'vue'
import ElementPlus from 'element-plus'
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import { createPinia } from 'pinia'
import App from './App.vue'
import router from './router'
import './style.css'
import './styles/transitions.css'

const app = createApp(App)

const usedIcons = ['Monitor', 'Document', 'TrendCharts', 'WarningFilled', 'Connection', 'User', 'Bell', 'Menu', 'Setting', 'Expand', 'Fold', 'UploadFilled']
for (const key of usedIcons) {
  const component = (ElementPlusIconsVue as any)[key]
  if (component) app.component(key, component)
}

app.use(ElementPlus, { locale: zhCn })
app.use(createPinia())
app.use(router)

// 应用挂载后立即清理可能残留的弹窗遮罩
app.mount('#app')
setTimeout(() => {
  document.querySelectorAll('.el-overlay').forEach(el => el.remove())
}, 200)
