// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import ElementUI from 'element-ui'

import './assets/styles/reset.css'
import './assets/styles/common.css'
import 'animate.css'
// import 'element-ui/lib/theme-chalk/index.css'
// import qs from 'qs'
import store from './store'
import Axios from 'axios'
import * as filters from './filters'
// 引入echarts
// import echarts from 'echarts'
import VCharts from 'v-charts'
import plugins from './plugin'

import VueRx from 'vue-rx'

Vue.use(VueRx)

Vue.use(ElementUI)
Vue.use(VCharts)

Axios.defaults.withCredentials = true // 让ajax携带cookie
const AUTH_TOKEN = 'doX8dJusNpe3Tb77mzRhz2JgdCU'
Axios.defaults.headers.common['token'] = AUTH_TOKEN

Axios.interceptors.request.use(
  config => {
    if (config.method === 'post') {
      // config.data = qs.stringify(config.data)
      config.headers['Content-Type'] = 'application/json'
    }
    return config
  },
  error => {
    return Promise.reject(error)
  }
)

Object.keys(plugins).forEach(key => {
  const plugin = plugins[key]
  Vue.use(plugin)
})

Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})

Vue.config.productionTip = false
Vue.prototype.axios = Axios
// Vue.prototype.$echarts = echarts

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>'
})
