|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
axios.interceptors.request.use(
|
|
|
|
|
axios.defaults.timeout = 1000*10;
|
|
|
|
|
axios.interceptors.request.use(
|
|
|
|
|
function (config) {
|
|
|
|
|
if (config.url.indexOf('.html') === -1 && config.url.indexOf('getToken') === -1) {
|
|
|
|
|
if (store.state.token.accessToken) {
|
|
|
|
@ -11,9 +12,8 @@
|
|
|
|
|
return config;
|
|
|
|
|
},
|
|
|
|
|
function (error) {
|
|
|
|
|
console.error('axios.interceptors.request.error:');
|
|
|
|
|
console.error(error);
|
|
|
|
|
loading.hide();
|
|
|
|
|
console.error(error);
|
|
|
|
|
return Promise.reject(error);
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
@ -21,7 +21,9 @@ axios.interceptors.response.use(function (response) {
|
|
|
|
|
loading.hide();
|
|
|
|
|
return response;
|
|
|
|
|
}, function (error) {
|
|
|
|
|
loading.hide();
|
|
|
|
|
console.error(error);
|
|
|
|
|
if (error.response) {
|
|
|
|
|
if (error.response.status === 401 && error.config.url.indexOf('refreshToken') === -1) {
|
|
|
|
|
var url = apiHost + '/UserCenter/api/v1/token/refreshToken';
|
|
|
|
|
var data = '"' + store.state.token.refreshToken + '"';
|
|
|
|
@ -42,6 +44,11 @@ axios.interceptors.response.use(function (response) {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
loading.hide();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (error.message.indexOf('timeout') !== -1) {
|
|
|
|
|
Swal.fire('请求超时,请返回重试');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return Promise.reject(error);
|
|
|
|
|
});
|