|
|
@ -8,7 +8,7 @@ import { currentUser as queryCurrentUser, queryPersonTxByYw } from './services/a
|
|
|
|
import { BookOutlined, LinkOutlined } from '@ant-design/icons';
|
|
|
|
import { BookOutlined, LinkOutlined } from '@ant-design/icons';
|
|
|
|
import { RequestConfig } from 'umi';
|
|
|
|
import { RequestConfig } from 'umi';
|
|
|
|
import { ResponseError } from 'umi-request';
|
|
|
|
import { ResponseError } from 'umi-request';
|
|
|
|
import { notification } from 'antd';
|
|
|
|
import { message, notification } from 'antd';
|
|
|
|
import cookie from 'react-cookies';
|
|
|
|
import cookie from 'react-cookies';
|
|
|
|
|
|
|
|
|
|
|
|
const isDev = process.env.NODE_ENV === 'development';
|
|
|
|
const isDev = process.env.NODE_ENV === 'development';
|
|
|
@ -87,14 +87,34 @@ export const layout: RunTimeLayoutConfig = ({ initialState }) => {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** 全局响应拦截 */
|
|
|
|
|
|
|
|
const responseInterceptor = async (response: any, options: any) => {
|
|
|
|
|
|
|
|
const data = await response.clone().json();
|
|
|
|
|
|
|
|
if (data && data?.status === '0') {
|
|
|
|
|
|
|
|
//location.href = location.pathname + '#/user/login'; // /#/user/login
|
|
|
|
|
|
|
|
history.push('/user/login')
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log('返回了', response);
|
|
|
|
|
|
|
|
console.log('options', options);
|
|
|
|
|
|
|
|
console.log('data', data)
|
|
|
|
|
|
|
|
if(data?.success === false && options?.url === '/dsideal_yy/checkLoginStatus'){
|
|
|
|
|
|
|
|
message.error(data?.info)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return response;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/** request 用于配置全局的网络请求,你可以在这里做拦截器,全局错误处理,鉴权的配置。*/
|
|
|
|
/** request 用于配置全局的网络请求,你可以在这里做拦截器,全局错误处理,鉴权的配置。*/
|
|
|
|
export const request: RequestConfig = {
|
|
|
|
export const request: RequestConfig = {
|
|
|
|
|
|
|
|
|
|
|
|
errorHandler: (error: ResponseError) => {
|
|
|
|
errorHandler: (error: ResponseError) => {
|
|
|
|
/*notification.error({
|
|
|
|
console.log('RequestConfig errorHandler', error)
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
notification.error({
|
|
|
|
description: '您的网络发生异常,无法连接服务器',
|
|
|
|
description: '您的网络发生异常,无法连接服务器',
|
|
|
|
message: '网络异常',
|
|
|
|
message: '网络异常',
|
|
|
|
});*/
|
|
|
|
});*/
|
|
|
|
throw error;
|
|
|
|
throw error;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
//middlewares?: OnionMiddleware[],
|
|
|
|
|
|
|
|
//requestInterceptors: [requestInterceptor], // 请求前拦截器
|
|
|
|
|
|
|
|
responseInterceptors: [responseInterceptor], // 响应拦截器
|
|
|
|
};
|
|
|
|
};
|