import './assets/main.css'

import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import Particles from "@tsparticles/vue3";
import { loadFull } from "tsparticles";
import { Quasar, Notify, QExpansionItem } from 'quasar'
import '@quasar/extras/material-icons/material-icons.css'
import 'quasar/dist/quasar.css'
import { createPinia } from 'pinia'
import axios from 'axios'
import VueAxios from 'vue-axios'
import {useUserInfo} from "@/composables/useUserInfo.ts";

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

app.use(pinia)
app.use(router)
app.use(Quasar, {
  plugins: {
    Notify
  },
  components: {
    QExpansionItem
  }
})
app.use(VueAxios, axios)
app.use(Particles, {
  init: async engine => {
    await loadFull(engine);
  },
})

axios.interceptors.response.use(
  res => res,
  err => {
    if (err.response?.status === 401) {
      const info = useUserInfo();
      info.clearUserInfo();
      router.replace({name: 'login'});
    }
    return Promise.reject(err);
  }
);

app.mount('#app')
