import { createApp } from 'vue'
import App from './App.vue'
import directives from './directive' // 指令
import router from '@/router' // router引入
// import 'default-passive-events'// 添加事件管理者'passive'，来阻止'touchstart'事件，让页面更加流畅。 解决chrome下的warning问题
// 状态管理引入
import { createPinia } from 'pinia'
// import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
import piniaPluginPersist from 'pinia-plugin-persist'
import { registerStore } from '@/store'

import 'tailwindcss/tailwind.css'
import ElementPlus from 'element-plus'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import 'element-plus/dist/index.css'
import zhCn from 'element-plus/es/locale/lang/zh-cn'
import '@/assets/style/common.less'

import 'virtual:svg-icons-register' // 注册svg
import svgIcon from '@/components/svgIcon/index.vue'
import tableList from '@/components/tableList/index.vue'

const instance = createApp(App)
const pinia = createPinia() // 状态管理
pinia.use(piniaPluginPersist)
instance.use(pinia) // 挂载
registerStore() // 注册store
instance.use(directives)

for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  instance.component(key, component)
} // 批量注册element icon

instance.component('SvgIcon', svgIcon)
instance.component('TableList', tableList)

instance
  .use(router)
  .use(ElementPlus, {
    locale: zhCn,
    button: {
      autoInsertSpace: true
    }
  })
  .mount('#app')
