|
@@ -21,7 +21,7 @@ const BASE_URL =
|
|
: import.meta.env.VITE_APP_BASE;
|
|
: import.meta.env.VITE_APP_BASE;
|
|
// 对面暴露的基础请求路径
|
|
// 对面暴露的基础请求路径
|
|
axios.BASE_URL = BASE_URL;
|
|
axios.BASE_URL = BASE_URL;
|
|
-
|
|
|
|
|
|
+let showAlert = true;
|
|
/**
|
|
/**
|
|
* 请求拦截
|
|
* 请求拦截
|
|
*/
|
|
*/
|
|
@@ -100,20 +100,24 @@ axios.interceptors.response.use(
|
|
if (error.response) {
|
|
if (error.response) {
|
|
// eslint-disable-next-line no-debugger
|
|
// eslint-disable-next-line no-debugger
|
|
if (error.response.status === 408) {
|
|
if (error.response.status === 408) {
|
|
- // 超时自动刷新
|
|
|
|
- ElMessageBox.confirm(
|
|
|
|
- "当前用户已被登出或无权限访问当前资源,请尝试重新登录后再操作。",
|
|
|
|
- "无权限访问",
|
|
|
|
- {
|
|
|
|
- type: "error",
|
|
|
|
- closeOnClickModal: false,
|
|
|
|
- center: true,
|
|
|
|
- confirmButtonText: "重新登录",
|
|
|
|
|
|
+ if (showAlert){
|
|
|
|
+ // 超时自动刷新
|
|
|
|
+ ElMessageBox.confirm(
|
|
|
|
+ "当前用户已被登出或无权限访问当前资源,请尝试重新登录后再操作。",
|
|
|
|
+ "无权限访问",
|
|
|
|
+ {
|
|
|
|
+ type: "error",
|
|
|
|
+ closeOnClickModal: false,
|
|
|
|
+ center: true,
|
|
|
|
+ confirmButtonText: "重新登录",
|
|
|
|
+ }
|
|
|
|
+ ).then(() => {
|
|
|
|
+ clearLoginInfo();
|
|
|
|
+ router.replace({ path: "/login" });
|
|
|
|
+ });
|
|
|
|
+ // 将标识变量设置为 false,表示已经弹出了提示
|
|
|
|
+ showAlert = false;
|
|
}
|
|
}
|
|
- ).then(() => {
|
|
|
|
- clearLoginInfo();
|
|
|
|
- router.replace({ path: "/login" });
|
|
|
|
- });
|
|
|
|
} else if (error.response.status === 401) {
|
|
} else if (error.response.status === 401) {
|
|
// 需要重新登录
|
|
// 需要重新登录
|
|
ElNotification.error({
|
|
ElNotification.error({
|