import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import axios from 'axios'

Vue.config.productionTip = false

import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import locale from 'element-ui/lib/locale/lang/zh-CN'
Vue.use(ElementUI, { locale });

//拖拽注册
import './utils/directive'


Vue.use(ElementUI, { locale });
Vue.prototype.axios = axios;

router.afterEach((to, from, next) => {
  let stateName = []; //保存 遍历已保存的name
  let dict = {} ;
  const name = to.name;
  const path = to.path;

  if(name){
    dict.name = name;
    dict.path = path;

    let stateRouterMenuMessage = store.state.routerMenuMessage;
    for(let item of stateRouterMenuMessage){
      stateName.push(item.name);
    }
    let isExist = stateName.indexOf(name);
    if(isExist){
      stateRouterMenuMessage.push(dict);
    }
  }
  next();
})


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