|
@@ -7,6 +7,7 @@ import { notifyInvalidTokenThrottled } from "./axiosNotice";
|
|
|
import { getToken, removeToken } from "../auth/auth";
|
|
|
import axiosRetry from "axios-retry";
|
|
|
import { DEVICE_ID } from "@/constant/constants";
|
|
|
+import { Notification } from "element-ui";
|
|
|
|
|
|
const PLATFORM = "web";
|
|
|
|
|
@@ -70,14 +71,16 @@ _axiosApp.interceptors.response.use(
|
|
|
return response;
|
|
|
},
|
|
|
(error) => {
|
|
|
+ const noErrorMessage = error.config.noErrorMessage;
|
|
|
if (!error.response) {
|
|
|
- // "Network Error" 网络不通,直接返回
|
|
|
-
|
|
|
- Vue.prototype.$notify({
|
|
|
- showClose: true,
|
|
|
- message: "网络连接异常,请检查网络设置。",
|
|
|
- type: "error",
|
|
|
- });
|
|
|
+ if (noErrorMessage) {
|
|
|
+ // "Network Error" 网络不通,直接返回
|
|
|
+ Notification({
|
|
|
+ showClose: true,
|
|
|
+ message: "网络连接异常,请检查网络设置。",
|
|
|
+ type: "error",
|
|
|
+ });
|
|
|
+ }
|
|
|
return Promise.reject(error);
|
|
|
}
|
|
|
// 这里是返回状态码不为200时候的错误处理
|
|
@@ -89,35 +92,43 @@ _axiosApp.interceptors.response.use(
|
|
|
removeToken();
|
|
|
return Promise.reject(error);
|
|
|
} else if (status == 405) {
|
|
|
- Vue.prototype.$notify({
|
|
|
- showClose: true,
|
|
|
- message: "没有权限!",
|
|
|
- type: "error",
|
|
|
- });
|
|
|
+ if (noErrorMessage) {
|
|
|
+ Notification({
|
|
|
+ showClose: true,
|
|
|
+ message: "没有权限!",
|
|
|
+ type: "error",
|
|
|
+ });
|
|
|
+ }
|
|
|
return Promise.reject(error);
|
|
|
} else if (status == 502) {
|
|
|
- Vue.prototype.$notify({
|
|
|
- showClose: true,
|
|
|
- message: "服务器异常(502)!",
|
|
|
- type: "error",
|
|
|
- });
|
|
|
+ if (noErrorMessage) {
|
|
|
+ Notification({
|
|
|
+ showClose: true,
|
|
|
+ message: "服务器异常(502)!",
|
|
|
+ type: "error",
|
|
|
+ });
|
|
|
+ }
|
|
|
return Promise.reject(error);
|
|
|
}
|
|
|
|
|
|
if (status != 200) {
|
|
|
const data = error.response.data;
|
|
|
if (data && data.message) {
|
|
|
- Vue.prototype.$notify({
|
|
|
- showClose: true,
|
|
|
- message: data.message,
|
|
|
- type: "error",
|
|
|
- });
|
|
|
+ if (noErrorMessage) {
|
|
|
+ Notification({
|
|
|
+ showClose: true,
|
|
|
+ message: data.message,
|
|
|
+ type: "error",
|
|
|
+ });
|
|
|
+ }
|
|
|
} else {
|
|
|
- Vue.prototype.$notify({
|
|
|
- showClose: true,
|
|
|
- message: "未定义异常: " + JSON.stringify(data, 2),
|
|
|
- type: "error",
|
|
|
- });
|
|
|
+ if (noErrorMessage) {
|
|
|
+ Notification({
|
|
|
+ showClose: true,
|
|
|
+ message: "未定义异常: " + JSON.stringify(data, 2),
|
|
|
+ type: "error",
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
return Promise.reject(error);
|
|
|
}
|