|
|
|
@ -14,12 +14,18 @@ axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8'
|
|
|
|
|
// 创建axios实例
|
|
|
|
|
const service = axios.create({
|
|
|
|
|
// axios中请求配置有baseURL选项,表示请求URL公共部分
|
|
|
|
|
<<<<<<< HEAD
|
|
|
|
|
baseURL: 'http://118.31.7.2:8801',
|
|
|
|
|
=======
|
|
|
|
|
// baseURL: 'http://118.31.7.2:8800',
|
|
|
|
|
baseURL: 'http://localhost:8800',
|
|
|
|
|
>>>>>>> f4500c5f3ef4b43105701541dffcdc560100371a
|
|
|
|
|
// baseURL: 'http://192.168.2.14:8800',
|
|
|
|
|
// baseURL:"http://192.168.2.17:8801",
|
|
|
|
|
// baseURL: process.env.VUE_APP_BASE_API,
|
|
|
|
|
// 超时
|
|
|
|
|
timeout: 200000
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
// request拦截器
|
|
|
|
|
service.interceptors.request.use(config => {
|
|
|
|
@ -69,9 +75,14 @@ service.interceptors.request.use(config => {
|
|
|
|
|
|
|
|
|
|
// 响应拦截器
|
|
|
|
|
service.interceptors.response.use(res => {
|
|
|
|
|
<<<<<<< HEAD
|
|
|
|
|
// console.log(res, 'res');
|
|
|
|
|
=======
|
|
|
|
|
// console.log(res, 'res1');
|
|
|
|
|
debugger
|
|
|
|
|
>>>>>>> f4500c5f3ef4b43105701541dffcdc560100371a
|
|
|
|
|
// 未设置状态码则默认成功状态
|
|
|
|
|
const code = res.data.code || 200
|
|
|
|
|
const code = res.status || 200
|
|
|
|
|
// 获取错误信息
|
|
|
|
|
const msg = errorCode[code] || res.data.msg || errorCode['default']
|
|
|
|
|
// 二进制数据则直接返回
|
|
|
|
@ -106,27 +117,48 @@ service.interceptors.response.use(res => {
|
|
|
|
|
},
|
|
|
|
|
error => {
|
|
|
|
|
let { message } = error
|
|
|
|
|
<<<<<<< HEAD
|
|
|
|
|
if(error.response.data.code == '400'){
|
|
|
|
|
Message({ message: error.response.data.msg, type: 'error' })
|
|
|
|
|
} else if (message == 'Network Error') {
|
|
|
|
|
=======
|
|
|
|
|
// debugger
|
|
|
|
|
if (message == 'Network Error') {
|
|
|
|
|
>>>>>>> f4500c5f3ef4b43105701541dffcdc560100371a
|
|
|
|
|
message = '后端接口连接异常'
|
|
|
|
|
} else if (message.includes('timeout')) {
|
|
|
|
|
message = '系统接口请求超时'
|
|
|
|
|
|
|
|
|
|
<<<<<<< HEAD
|
|
|
|
|
} else if (error.response.status == '401') {
|
|
|
|
|
=======
|
|
|
|
|
} else if (error.response.status=="401") {
|
|
|
|
|
>>>>>>> f4500c5f3ef4b43105701541dffcdc560100371a
|
|
|
|
|
if (!isRelogin.show) {
|
|
|
|
|
isRelogin.show = true
|
|
|
|
|
MessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', { confirmButtonText: '重新登录', cancelButtonText: '取消', type: 'warning' }).then(() => {
|
|
|
|
|
isRelogin.show = false
|
|
|
|
|
<<<<<<< HEAD
|
|
|
|
|
store.dispatch('FedLogOut').then(() => {
|
|
|
|
|
location.href = '/login';
|
|
|
|
|
})
|
|
|
|
|
=======
|
|
|
|
|
document.cookie = 'Admin-Token=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;';
|
|
|
|
|
// store.dispatch('LogOut').then(() => {
|
|
|
|
|
location.href = '/login';
|
|
|
|
|
// })
|
|
|
|
|
>>>>>>> f4500c5f3ef4b43105701541dffcdc560100371a
|
|
|
|
|
}).catch(() => {
|
|
|
|
|
isRelogin.show = false
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
return Promise.reject('无效的会话,或者会话已过期,请重新登录。')
|
|
|
|
|
<<<<<<< HEAD
|
|
|
|
|
}
|
|
|
|
|
=======
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
>>>>>>> f4500c5f3ef4b43105701541dffcdc560100371a
|
|
|
|
|
else if (message.includes('Request failed with status code')) {
|
|
|
|
|
message = '系统接口' + message.substr(message.length - 3) + '1221231异常'
|
|
|
|
|
}else{
|
|
|
|
@ -161,7 +193,7 @@ export function download(url, params, filename, config) {
|
|
|
|
|
console.error(r)
|
|
|
|
|
Message.error('下载文件出现错误,请联系管理员!')
|
|
|
|
|
downloadLoadingInstance.close()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
export default service
|
|
|
|
|