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

import { createPinia } from 'pinia'
import { useUserStore } from './store'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'

import ElementPlus from 'element-plus'
import zhCn from 'element-plus/es/locale/lang/zh-cn'
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import 'virtual:windi.css'
import '@fortawesome/fontawesome-free/css/all.css'

const pinia = createPinia()
const piniaPlugin = ({store}) => {
    store.$subscribe(() => {})
    store.$onAction(({name, args, after, onError}) => {})
}
pinia.use(piniaPluginPersistedstate)
pinia.use(piniaPlugin)

const app = createApp(App)
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}
app.use(pinia)

let userStore = useUserStore()
const addRouter = () => userStore.addMainRoute()
addRouter()

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