|
|
@@ -46,32 +46,15 @@ axios.interceptors.response.use(
|
|
|
message: error.response.data.message || "Status:500,服务器发生错误!"
|
|
|
});
|
|
|
} else if (error.response.status == 400) {
|
|
|
- ElNotification.error({
|
|
|
- title: "请求错误",
|
|
|
- message: error.response.data || "Code:400,未知错误!"
|
|
|
- });
|
|
|
- } else if (error.response.status == 401) {
|
|
|
- if (!MessageBox_401_show) {
|
|
|
- MessageBox_401_show = true
|
|
|
- ElMessageBox.confirm("当前用户已被登出或无权限访问当前资源,请尝试重新登录后再操作。", "无权限访问", {
|
|
|
- type: "error",
|
|
|
- showClose: false,
|
|
|
- closeOnPressEscape: false,
|
|
|
- closeOnClickModal: false,
|
|
|
- center: true,
|
|
|
- confirmButtonText: "重新登录",
|
|
|
- showCancelButton: false,
|
|
|
- beforeClose: (action, instance, done) => {
|
|
|
- MessageBox_401_show = false
|
|
|
- done()
|
|
|
- }
|
|
|
- }).then(() => {
|
|
|
- tool.cookie.remove("TOKEN");
|
|
|
- tool.data.remove("USER_INFO");
|
|
|
- router.replace({ path: "/login" })
|
|
|
- }).catch(() => { })
|
|
|
+ if (error.response.data == "找不到当前登录的信息") messageBox_401();
|
|
|
+ else {
|
|
|
+ ElNotification.error({
|
|
|
+ title: "请求错误",
|
|
|
+ message: error.response.data || "Code:400,未知错误!"
|
|
|
+ });
|
|
|
}
|
|
|
- } else {
|
|
|
+ } else if (error.response.status == 401) messageBox_401();
|
|
|
+ else {
|
|
|
ElNotification.error({
|
|
|
title: "请求错误",
|
|
|
message: error.response.data.message || `Status:${error.response.status},未知错误!`
|
|
|
@@ -127,28 +110,8 @@ var http = {
|
|
|
...config,
|
|
|
params: params
|
|
|
}).then((response) => {
|
|
|
- if (response.data.code && response.data.code == 30112) {
|
|
|
- if (!MessageBox_401_show) {
|
|
|
- MessageBox_401_show = true
|
|
|
- ElMessageBox.confirm("当前用户已被登出或无权限访问当前资源,请尝试重新登录后再操作。", "无权限访问", {
|
|
|
- type: "error",
|
|
|
- showClose: false,
|
|
|
- closeOnPressEscape: false,
|
|
|
- closeOnClickModal: false,
|
|
|
- center: true,
|
|
|
- confirmButtonText: "重新登录",
|
|
|
- showCancelButton: false,
|
|
|
- beforeClose: (action, instance, done) => {
|
|
|
- MessageBox_401_show = false
|
|
|
- done()
|
|
|
- }
|
|
|
- }).then(() => {
|
|
|
- tool.cookie.remove("TOKEN");
|
|
|
- tool.data.remove("USER_INFO");
|
|
|
- router.replace({ path: "/login" })
|
|
|
- }).catch(() => { })
|
|
|
- }
|
|
|
- } else resolve(response.data)
|
|
|
+ if (response.data.code && response.data.code == 30112) messageBox_401();
|
|
|
+ else resolve(response.data);
|
|
|
}).catch((error) => {
|
|
|
reject(error);
|
|
|
})
|
|
|
@@ -240,4 +203,27 @@ var http = {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+function messageBox_401() {
|
|
|
+ if (!MessageBox_401_show) {
|
|
|
+ MessageBox_401_show = true
|
|
|
+ ElMessageBox.confirm("当前用户已被登出或无权限访问当前资源,请尝试重新登录后再操作。", "无权限访问", {
|
|
|
+ type: "error",
|
|
|
+ showClose: false,
|
|
|
+ closeOnPressEscape: false,
|
|
|
+ closeOnClickModal: false,
|
|
|
+ center: true,
|
|
|
+ confirmButtonText: "重新登录",
|
|
|
+ showCancelButton: false,
|
|
|
+ beforeClose: (action, instance, done) => {
|
|
|
+ MessageBox_401_show = false;
|
|
|
+ done();
|
|
|
+ }
|
|
|
+ }).then(() => {
|
|
|
+ tool.cookie.remove("TOKEN");
|
|
|
+ tool.data.remove("USER_INFO");
|
|
|
+ router.replace({ path: "/login" });
|
|
|
+ }).catch(() => { });
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
export default http;
|