const { apiConfig: { timeout, retry, retryDelay } } = config;
if(timeout) axios.defaults.timeout = timeout; //超时时间
if(retry) axios.defaults.retry = retry; //请求次数
if(retryDelay) axios.defaults.retryDelay = retryDelay; //请求间隙
const errConfig = error.config || {};
if(error.code == 'ECONNABORTED' && ~error.message.indexOf('timeout') && errConfig.retry){
errConfig.__retryCount = errConfig.__retryCount || 0;
errConfig.__retryCount += 1;
if(errConfig.__retryCount < errConfig.retry) {
return that.request(errConfig) //再次请求
}
}
this.destroy(url);
if(~error.message.indexOf('timeout')) msg = '系统请求超时,请稍后重试';
tipsMessage(msg);
return false;