|
@@ -1,7 +1,7 @@
|
|
|
/*
|
|
|
* @Author: your name
|
|
|
* @Date: 2021-09-03 14:28:27
|
|
|
- * @LastEditTime: 2021-10-27 13:55:18
|
|
|
+ * @LastEditTime: 2021-10-27 17:18:48
|
|
|
* @LastEditors: Please set LastEditors
|
|
|
* @Description: In User Settings Edit
|
|
|
* @FilePath: /MedicalWisdomCheckSys/src/app.tsx
|
|
@@ -27,8 +27,11 @@ const isDev = process.env.NODE_ENV === 'development';
|
|
|
|
|
|
const loginPath = '/user/login';
|
|
|
|
|
|
+let ifStopNextRequest = false;
|
|
|
+
|
|
|
let hospSign:any='';
|
|
|
|
|
|
+
|
|
|
if(history){
|
|
|
hospSign = history.location.query?.hospSign;
|
|
|
if(!hospSign){
|
|
@@ -140,6 +143,12 @@ const authHeaderInterceptor = (url: string, options: RequestOptionsInit) => {
|
|
|
const {token}:API.CurrentUserData = JSON.parse(userData);
|
|
|
authHeader.token = token;
|
|
|
}
|
|
|
+
|
|
|
+ if(ifStopNextRequest){
|
|
|
+ //token过期阻止下一步请求
|
|
|
+ throw new Error('token过期!');
|
|
|
+ }
|
|
|
+
|
|
|
return {
|
|
|
url: `${url}`,
|
|
|
options: { ...options, interceptors: true, headers: authHeader },
|
|
@@ -160,6 +169,7 @@ const responseInterceptors = async (response: Response, options: RequestOptionsI
|
|
|
const { status: dataStatus,errorCode,errorMessage,data} = _response;
|
|
|
if(dataStatus == 200){
|
|
|
//接口请求成功
|
|
|
+ ifStopNextRequest=false;
|
|
|
if(requestMethod=='POST'&&url != "/api/pfm/login"){
|
|
|
notification.success({
|
|
|
message:'操作成功!'
|
|
@@ -171,6 +181,7 @@ const responseInterceptors = async (response: Response, options: RequestOptionsI
|
|
|
}
|
|
|
return true;
|
|
|
}else if(errorCode == 499){
|
|
|
+ ifStopNextRequest = true;
|
|
|
Modal.confirm({
|
|
|
title: '抱歉,登录已过期请重新登录!',
|
|
|
onOk: () => {
|
|
@@ -194,8 +205,6 @@ const responseInterceptors = async (response: Response, options: RequestOptionsI
|
|
|
}catch(error){
|
|
|
console.log({error});
|
|
|
}
|
|
|
-
|
|
|
- return response;
|
|
|
};
|
|
|
|
|
|
|