import {createApp} from 'vue'
import App from './home.vue'
import router from './router/index'
import ElementPlus from 'element-plus'
import zhCn from 'element-plus/es/locale/lang/zh-cn'
import mitt from 'mitt'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'

import {createPinia} from 'pinia'
const pinia = createPinia()
pinia.use(piniaPluginPersistedstate)

// ======================  样式  ======================
import 'element-plus/dist/index.css'
import '@/assets/styles/index.scss'

// ======================  工具和组件  ======================
import {initRem, fontSize} from '@/utils/rem'
import IconSvg from '@/components/Icon/svgIcon.vue'

// SVG图标注册
import 'virtual:svg-icons-register'

// 初始化rem适配
initRem()

// 创建事件总线
const bus = mitt()

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

// 全局属性注册
app.config.globalProperties.$fontSize = fontSize
app.config.globalProperties.$bus = bus

// 全局组件注册
app.component('icon-svg', IconSvg)
// 插件使用
app.use(router).use(pinia).use(ElementPlus, {locale: zhCn})

// 挂载应用
app.mount('#app')
