This commit is contained in:
duanxiaohai 2024-09-30 14:04:33 +08:00
parent fa3dfec58e
commit c9f31e43e0
1 changed files with 3 additions and 5 deletions

View File

@ -30,7 +30,6 @@ axios.interceptors.response.use(
if (error.response) { if (error.response) {
if (error.response.status == 401) { if (error.response.status == 401) {
ElMessage.error("请重新登录!"); ElMessage.error("请重新登录!");
const cookies = document.cookie.split(";"); const cookies = document.cookie.split(";");
for (let i = 0; i < cookies.length; i++) { for (let i = 0; i < cookies.length; i++) {
const cookie = cookies[i]; const cookie = cookies[i];
@ -38,19 +37,18 @@ axios.interceptors.response.use(
const name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie; const name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie;
document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/;"; document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/;";
} }
router.replace({ router.replace({
path: "/guide", path: "/guide",
}); });
} else if (error.response.status == 403) { } else if (error.response.status == 403) {
ElMessage.error("Status:403资源不可用"); ElMessage.error("Status:403资源不可用");
router.replace({ router.replace({
path: "/403", path: "/error/403",
}); });
} else if (error.response.status == 404) { } else if (error.response.status == 404) {
ElMessage.error("Status:404正在请求不存在的服务器记录"); ElMessage.error("Status:404正在请求不存在的服务器记录");
router.replace({ router.replace({
path: "/404", path: "/error/404",
}); });
} else if (error.response.status == 500) { } else if (error.response.status == 500) {
ElMessage.error({ ElMessage.error({
@ -58,7 +56,7 @@ axios.interceptors.response.use(
message: "Status:500服务器发生错误", message: "Status:500服务器发生错误",
}); });
router.replace({ router.replace({
path: "/500", path: "/error/500",
}); });
} else { } else {
ElMessage.error(`Status:${error.response.status},未知错误!`); ElMessage.error(`Status:${error.response.status},未知错误!`);