import { createApp } from 'vue'
import user from '~/store/user'
import 'default-passive-events'
import 'virtual:windi.css';

// import VConsole from 'vconsole';
// const vConsole = new VConsole();

import App from './App.vue'
import router from './router/index';

router.beforeEach((to, from, next) => {
    console.log(to);
  if (to.meta?.loginRequest) { // 如果路由meta中loginRequest为true，进行拦截
    if (user.token) {
      next()
    } else {
        window.location.href =
          "https://nmlm.bozedu.net/login.html?redirect=" + to.fullPath;
    }
  } else {
    next() // 直接进入页面
  }
})
const app = createApp(App)
app.use(router)

app.mount('#app')

// Toast
import 'vant/es/toast/style';
// Dialog
import 'vant/es/dialog/style';
// Notify
import 'vant/es/notify/style';
// ImagePreview
import 'vant/es/image-preview/style';
