// 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 "babel-polyfill";
import Vue from "vue";
import router from "./router";
import {
  sync
} from "vuex-router-sync";
import zrender from 'zrender'; 
import ElementUi from "element-ui";
import axios from './axios'
import Viewer from 'v-viewer'
import 'viewerjs/dist/viewer.css'
import Vuex from "vuex";
import store from './store'
import jQuery from "jquery";
import "./assets/js/jquery-ui.min.js";
import * as filters from "./filters";
// import 'element-ui/lib/theme-chalk/index.css'
import "./assets/css/element-#00C1DE/index.css";
import "./assets/css/iconfont/iconfont.css";
import "./assets/iconfont/iconfont.css";
import App from "./App";
import "./assets/css/element_amend.css";
import '../node_modules/bootstrap/dist/css/bootstrap.min.css';
import '../node_modules/bootstrap/dist/js/bootstrap.min.js';
import '@/permission' // permission control
Vue.config.productionTip = false;
// axios.defaults.withCredentials = true
Vue.prototype.$zrender = zrender;
Vue.use(Viewer);
Viewer.setDefaults({
  Options: { "inline": true, "button": true, "navbar": true, "title": true, "toolbar": true, "tooltip": true, "movable": true, "zoomable": true, "rotatable": true, "scalable": true, "transition": true, "fullscreen": false, "keyboard": true, "url": "data-source" }
});
Vue.use(ElementUi);
Vue.use(Vuex);
sync(store, router);

// register global utility filters.
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key]);
});

// // 添加请求拦截器
// Axios.interceptors.request.use(config => {
//   // 在发送请求之前做些什么
//   //判断是否存在token，如果存在将每个页面header都添加token
//   if (store.state.token){
//   config.headers.common['Authentication-Token'] = store.state.token
//   }
   
//   return config;
//   }, error => {
//   // 对请求错误做些什么
//   return Promise.reject(error);
//   });
   
//   // http response 拦截器
//   Axios.interceptors.response.use(
//   response => {
   
//   return response;
//   },
//   error => {
   
//   if (error.response) {
//   switch (error.response.status) {
//   case 401:
//   this.$store.commit('del_token');
//   router.replace({
//   path: '/login',
//   query: {redirect: router.currentRoute.fullPath}//登录成功后跳入浏览的当前页面
//   })
//   }
//   }
//   return Promise.reject(error.response.data)
//   });
window.jQuery = jQuery;
/* eslint-disable no-new */
new Vue({
  el: "#app",
  router,
  store,
  template: "<App/>",
  components: {
    App
  }
});
