//设置拦截器 拦截
// request interceptor
service.interceptors.request.use(config => {const token = Vue.ls.get(ACCESS_TOKEN);// if (token) {// config.headers["X-Access-Token"] = token; // 让每个请求携带自定义 token 请根据实际情况自行修改// }return config;},error => {return Promise.reject(error);}
);service.interceptors.response.use(response => {return response.data;},error => {// switch (error.response.status) {// case 500:// // authentication expired// Vue.ls.remove(ACCESS_TOKEN);// MessageBox.alert("很抱歉,登录已过期,请重新登录", "登录已过期", {// confirmButtonText: "重新登录"// }).then(() => {// this.$router.push("/login");// window.location.reload();// });// break;// }return Promise.reject(error);}
);