/**
 * 应用入口文件
 * @file main.js
 * @description Vue应用初始化和配置
 */
import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import { createPinia } from 'pinia'
import Antd from 'ant-design-vue'
import 'ant-design-vue/dist/reset.css'
import { themeConfig } from './styles/theme.js'
import './styles/global.css'
import './styles/responsive.css'
import { useUserStore, useSettingsStore } from './stores'

// 导入图标组件
import * as Icons from '@ant-design/icons-vue'

const app = createApp(App)
const pinia = createPinia()

// 注册所有图标组件
Object.keys(Icons).forEach(key => {
  app.component(key, Icons[key])
})

app.use(pinia)
app.use(router)
app.use(Antd, {
  theme: themeConfig
})

// 在应用挂载前初始化用户登录状态和设置
const userStore = useUserStore()
const settingsStore = useSettingsStore()

// 检查登录状态
userStore.checkLoginStatus()

// 加载用户设置
settingsStore.loadSettings()

app.mount('#app')