// core
import { PcSearch, PcTable } from "@sud-web/vue-ui"
import { createApp } from "vue"
import App from "@/App.vue"
import { loadDirectives } from "@/directives"
// load
import { loadPlugins } from "@/plugins"
import router from "@/router"
import store from "@/store"
import { installI18n } from "./lang"
import "element-plus/theme-chalk/src/index.scss"
import "@sud-web/vue-ui/style.css"

import "@/router/permission"
// css
import "normalize.css"

import "@/styles/index.scss"
import "virtual:uno.css"

// 非生产环境动态引入vconsole看打印
if (import.meta.env.MODE !== "production") {
  // eslint-disable-next-line antfu/no-top-level-await
  const { default: VConsole } = await import("vconsole")
  // eslint-disable-next-line no-new
  new VConsole()
}

const app = createApp(App)
// 安装 Vue I18n
installI18n(app)
// 注册 @sud-web/vue-ui 的公共组件（内部按需注册依赖的 Element Plus 组件）
app.use(PcTable)
app.use(PcSearch)
/** 加载插件 */
loadPlugins(app)

/** 加载自定义指令 */
loadDirectives(app)

app.use(store).use(router)
router.isReady().then(() => {
  app.mount("#app")
})
