import Vue from 'vue'
import App from './App'
import router from './router'
import ElementUI, { Message } from 'element-ui'
import VueAxios from 'vue-axios'
import axios from 'axios'
import store from './store/store'
import 'element-ui/lib/theme-chalk/index.css'
import '../static/css/index.styl'
import '../static/font/iconfont.css'
import gicinput from 'common/gicinput'
import gictextarea from 'common/gictextarea'
import vueGicHeader from '@gic-test/vue-gic-header'
import vueGicCard from '@gic-test/vue-gic-card'
import vueGicStore from '@gic-test/vue-gic-store'
import vueGicPeople from '@gic-test/vue-gic-people'
import vueGicUploadImage from '@gic-test/vue-gic-upload-image'
import * as custom from 'common/filters/custom'
Vue.config.productionTip = false
import G2 from '@antv/g2';

Vue.use(G2);
Vue.use(ElementUI);
Vue.use(VueAxios,axios);
Vue.axios.defaults.withCredentials = true;
Vue.use(vueGicHeader);
Vue.use(vueGicPeople);

Vue.use(vueGicStore);
Vue.use(vueGicCard);
Vue.component('gic-textarea',gictextarea);
Vue.component('gic-input', gicinput);
import vueGicAsideMenu from '@gic-test/vue-gic-aside-menu'
import vueGicFooter from '@gic-test/vue-gic-footer'
Vue.use(vueGicAsideMenu)
Vue.use(vueGicFooter)
Vue.use(vueGicUploadImage)

Vue.axios.interceptors.request.use(
  config => {
    return config;
  },
  err => {
    return Promise.reject(err);
  });
Vue.axios.interceptors.response.use(
  response => {
    const CODE = response.data.errorCode;
    switch(CODE) {
      case 401:
        window.location.href = `${window.origin}/gic-web/#/`;
        break;
    }
    return response;
  },
  error => {
    Message({
      message: error.response.data.response.message,
      type: 'error',
      duration: 3000
    });
    return Promise.reject(error);
  });
Object.keys(custom).forEach(key => {
  Vue.filter(key,custom[key]);
});
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>'
})
