import { createApp } from 'vue'
import { createPinia } from 'pinia'

import App from './App.vue'
import router, { bindAuthToApi } from './router'
import { useAuthStore } from './stores/auth'

import './styles/tailwind.css'
import './styles/tokens.css'

const app = createApp(App)
app.use(createPinia())
app.use(router)
bindAuthToApi()
app.mount('#app')

// 启动后异步校验本地会话（不阻塞首屏渲染）：
// 若 token 仍有效则回填最新用户信息；遇到 401 则登出。
useAuthStore()
  .validateSession()
  .catch(() => {})
