import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import  {setStore} from './utils/mUtils'
import XML from "./plugin/xml-digital-teaching/lib/index"
import  './plugin/xml-digital-teaching/lib/theme/index.css'


import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';

Vue.use(ElementUI);



Vue.config.productionTip = false


Vue.use(XML)

router.beforeEach((to,from,next)=>{


  
  var apikey = to.query.apikey
  var userId = to.query.userId
  var userType = to.query.userType

  if (apikey){
    setStore('apikey',apikey)
    console.log(apikey)
  }

  if (userId){
    setStore('userId',userId)
    console.log(userId)
  }


  if (userType){
    setStore('userType',userType)
    console.log(userType)
  }

  if (apikey){
    

    delete to.query.apikey
    if (userId){
      delete to.query.userId
    }
    if (userType){
      delete to.query.userType
    }
    
    next({
      path:to.path,
      query:{...to.query}
    })
    return
  }
  
  console.log(to)
  console.log(from)
  next()

})

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')


