|
@@ -1,7 +1,7 @@
|
|
/*
|
|
/*
|
|
* @Author: your name
|
|
* @Author: your name
|
|
* @Date: 2021-09-03 14:28:27
|
|
* @Date: 2021-09-03 14:28:27
|
|
- * @LastEditTime: 2021-11-09 17:05:01
|
|
|
|
|
|
+ * @LastEditTime: 2021-11-15 15:11:51
|
|
* @LastEditors: Please set LastEditors
|
|
* @LastEditors: Please set LastEditors
|
|
* @Description: In User Settings Edit
|
|
* @Description: In User Settings Edit
|
|
* @FilePath: /MedicalWisdomCheckSys/src/app.tsx
|
|
* @FilePath: /MedicalWisdomCheckSys/src/app.tsx
|
|
@@ -11,10 +11,9 @@ import { PageLoading } from '@ant-design/pro-layout';
|
|
import { RunTimeLayoutConfig } from 'umi';
|
|
import { RunTimeLayoutConfig } from 'umi';
|
|
import { history, Link } from 'umi';
|
|
import { history, Link } from 'umi';
|
|
import { notification, Modal } from 'antd';
|
|
import { notification, Modal } from 'antd';
|
|
-
|
|
|
|
|
|
+import 'yet-another-abortcontroller-polyfill'
|
|
import RightContent from '@/components/RightContent';
|
|
import RightContent from '@/components/RightContent';
|
|
-// import Footer from '@/components/Footer';
|
|
|
|
-// import { currentUser as queryCurrentUser } from './services/ant-design-pro/api';
|
|
|
|
|
|
+
|
|
import { BookOutlined, LinkOutlined } from '@ant-design/icons';
|
|
import { BookOutlined, LinkOutlined } from '@ant-design/icons';
|
|
import iconEnum from './menuIcons';
|
|
import iconEnum from './menuIcons';
|
|
import {loginOut} from '@/utils';
|
|
import {loginOut} from '@/utils';
|
|
@@ -23,18 +22,21 @@ import logoIcon from '../public/logo.png';
|
|
import { getMenus } from './services/user';
|
|
import { getMenus } from './services/user';
|
|
import {updateUserInfo} from '@/pages/user/Login/service';
|
|
import {updateUserInfo} from '@/pages/user/Login/service';
|
|
|
|
|
|
|
|
+import type { RequestOptionsInit,Context } from 'umi-request';
|
|
|
|
+
|
|
const isDev = process.env.NODE_ENV === 'development';
|
|
const isDev = process.env.NODE_ENV === 'development';
|
|
|
|
|
|
const loginPath = '/user/login';
|
|
const loginPath = '/user/login';
|
|
|
|
|
|
-let ifStopNextRequest = false;
|
|
|
|
-
|
|
|
|
let hospSign:any='';
|
|
let hospSign:any='';
|
|
|
|
|
|
|
|
+const controller = new AbortController(); // create a controller
|
|
|
|
+const { signal } = controller; // grab a reference to its associated AbortSignal object using the AbortController.signal property
|
|
|
|
+
|
|
|
|
+let ifStopNextRequet:boolean = false;
|
|
|
|
|
|
if(history){
|
|
if(history){
|
|
hospSign = history.location.query?.hospSign;
|
|
hospSign = history.location.query?.hospSign;
|
|
- console.log({hospSign});
|
|
|
|
if(!hospSign){
|
|
if(!hospSign){
|
|
hospSign = localStorage.getItem('hospSign');
|
|
hospSign = localStorage.getItem('hospSign');
|
|
console.log({'localStorage':hospSign});
|
|
console.log({'localStorage':hospSign});
|
|
@@ -131,9 +133,6 @@ export async function getInitialState(): Promise<{
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-type RequestOptionsInit = {
|
|
|
|
- [propsName:string]:any
|
|
|
|
-}
|
|
|
|
|
|
|
|
const authHeaderInterceptor = (url: string, options: RequestOptionsInit) => {
|
|
const authHeaderInterceptor = (url: string, options: RequestOptionsInit) => {
|
|
|
|
|
|
@@ -146,11 +145,6 @@ const authHeaderInterceptor = (url: string, options: RequestOptionsInit) => {
|
|
authHeader.token = token;
|
|
authHeader.token = token;
|
|
}
|
|
}
|
|
|
|
|
|
- // if(ifStopNextRequest){
|
|
|
|
- // //token过期阻止下一步请求
|
|
|
|
- // throw new Error('token过期!');
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
return {
|
|
return {
|
|
url: `${url}`,
|
|
url: `${url}`,
|
|
options: { ...options, interceptors: true, headers: authHeader },
|
|
options: { ...options, interceptors: true, headers: authHeader },
|
|
@@ -182,12 +176,16 @@ const responseInterceptors = async (response: Response, options: RequestOptionsI
|
|
}
|
|
}
|
|
return true;
|
|
return true;
|
|
}else if(errorCode == 499){
|
|
}else if(errorCode == 499){
|
|
- Modal.confirm({
|
|
|
|
- title: '抱歉,登录已过期请重新登录!',
|
|
|
|
- onOk: () => {
|
|
|
|
- loginOut();
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
|
|
+ if(!ifStopNextRequet){
|
|
|
|
+ Modal.confirm({
|
|
|
|
+ title: '抱歉,登录已过期请重新登录!',
|
|
|
|
+ onOk: () => {
|
|
|
|
+ ifStopNextRequet = false;
|
|
|
|
+ loginOut();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ ifStopNextRequet = true;
|
|
}else {
|
|
}else {
|
|
//接口请求信息错误
|
|
//接口请求信息错误
|
|
notification.error({
|
|
notification.error({
|
|
@@ -208,6 +206,11 @@ const responseInterceptors = async (response: Response, options: RequestOptionsI
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
+const demo1Middleware = async (ctx: Context, next: () => void) => {
|
|
|
|
+ await next();
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+
|
|
type RequestConfig = {
|
|
type RequestConfig = {
|
|
[propsName:string]:any
|
|
[propsName:string]:any
|
|
}
|
|
}
|
|
@@ -218,6 +221,7 @@ export const request: RequestConfig = {
|
|
console.log({ error });
|
|
console.log({ error });
|
|
throw error;
|
|
throw error;
|
|
},
|
|
},
|
|
|
|
+ middlewares: [demo1Middleware],
|
|
requestInterceptors: [authHeaderInterceptor],
|
|
requestInterceptors: [authHeaderInterceptor],
|
|
responseInterceptors: [responseInterceptors],
|
|
responseInterceptors: [responseInterceptors],
|
|
};
|
|
};
|
|
@@ -277,7 +281,7 @@ export const layout: RunTimeLayoutConfig = ({ initialState }) => {
|
|
if(initialState){
|
|
if(initialState){
|
|
const { currentUser,isDev} = initialState;
|
|
const { currentUser,isDev} = initialState;
|
|
if(isDev){
|
|
if(isDev){
|
|
- //开发环境或超级账号
|
|
|
|
|
|
+ //开发环境
|
|
return []
|
|
return []
|
|
}
|
|
}
|
|
|
|
|