fix: 修改请求报错提示

This commit is contained in:
lilinyuan
2024-03-29 15:34:34 +08:00
parent 19822a539c
commit a5a2e099a2

View File

@@ -1,6 +1,6 @@
import axios from "axios";
import { AxiosCanceler } from "./axiosCanceler";
import { ElMessage, ElMessageBox } from "element-plus";
import { ElMessageBox, ElNotification } from "element-plus";
import { getToken, removeToken } from "./auth";
axios.defaults.headers['Content-Type']='application/json'
@@ -48,21 +48,37 @@ serveice.interceptors.response.use(response=>{
case 402:
break;
case 403:
ElMessage.warning('禁止访问')
ElNotification({
title: '系统提示',
message: '禁止访问',
type: 'warning'
})
removeToken()
window.location = '/forbidden'
break;
case 404:
ElMessage.warning('不存在的地址')
ElNotification({
title: '系统提示',
message: '不存在的地址',
type: 'error'
})
break;
case 405:
ElMessage.warning('传输格式错误,请检查')
ElNotification({
title: '系统提示',
message: '传输格式错误,请检查',
type: 'error'
})
break;
case 500:
if (response.data){
return response.data
}else {
ElMessage.error('系统未知错误')
ElNotification({
title: '系统提示',
message: '系统未知错误',
type: 'error'
})
break;
}
}