修改了Axios请求实例配置
This commit is contained in:
parent
5651b91131
commit
3b5293a5ed
|
@ -16,8 +16,9 @@ let apiBaseUrl = window._CONFIG['domianURL'] || "/jeecg-boot";
|
||||||
// 创建 axios 实例
|
// 创建 axios 实例
|
||||||
const service = axios.create({
|
const service = axios.create({
|
||||||
//baseURL: '/jeecg-boot',
|
//baseURL: '/jeecg-boot',
|
||||||
baseURL: apiBaseUrl, // api base_url
|
// baseURL: apiBaseUrl, // api base_url
|
||||||
timeout: 9000 // 请求超时时间
|
baseURL: 'http://localhost:8080/jeecg-boot',
|
||||||
|
timeout: 15000 // 请求超时时间
|
||||||
})
|
})
|
||||||
|
|
||||||
const err = (error) => {
|
const err = (error) => {
|
||||||
|
@ -69,7 +70,7 @@ const err = (error) => {
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
case 404:
|
case 404:
|
||||||
Vue.prototype.$Jnotification.error({ message: '系统提示', description:'很抱歉,资源未找到!',duration: 4})
|
Vue.prototype.$Jnotification.error({ message: '系统提示', description:'很抱歉,资源未找到!',duration: 4})
|
||||||
break
|
break
|
||||||
case 504:
|
case 504:
|
||||||
Vue.prototype.$Jnotification.error({ message: '系统提示', description: '网络超时'})
|
Vue.prototype.$Jnotification.error({ message: '系统提示', description: '网络超时'})
|
||||||
|
@ -144,7 +145,16 @@ service.interceptors.request.use(config => {
|
||||||
// response interceptor
|
// response interceptor
|
||||||
service.interceptors.response.use((response) => {
|
service.interceptors.response.use((response) => {
|
||||||
return response.data
|
return response.data
|
||||||
}, err)
|
}, error=> {
|
||||||
|
if(error.code==='ECONNABORTED' && error.message.indexOf('timeout')!==-1){
|
||||||
|
Vue.prototype.$Jnotification.error({message: '系统提示', description: '网络超时'})
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
Vue.prototype.$Jnotification.error({message: '系统提示', description: '未知错误'})
|
||||||
|
}
|
||||||
|
return Promise.reject(error)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
const installer = {
|
const installer = {
|
||||||
vm: {},
|
vm: {},
|
||||||
|
|
Loading…
Reference in New Issue