import './assets/main.css'
import './styles/global.css'

import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
// 引入用户状态管理，确保在应用启动时初始化
import './store/user'

// 导入 Element Plus
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
// 导入 Element Plus 中文语言包
import zhCn from 'element-plus/es/locale/lang/zh-cn'

// 导入 Toast 通知组件
import Toast from 'vue-toastification'
import 'vue-toastification/dist/index.css'

// Toast 配置选项
const toastOptions = {
  position: "top-right",
  timeout: 3000,
  closeOnClick: true,
  pauseOnFocusLoss: true,
  pauseOnHover: true,
  draggable: true,
  draggablePercent: 0.6,
  showCloseButtonOnHover: false,
  hideProgressBar: false,
  closeButton: "button",
  icon: true,
  rtl: false
}

const app = createApp(App)

// 注册所有 Element Plus 图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

app.use(router)
app.use(Toast, toastOptions)
app.use(ElementPlus, {
  locale: zhCn,
})

app.mount('#app')
