zhengpengju 3 years ago
parent 9b01d7b7bc
commit cb32d00818

@ -55,7 +55,7 @@
"@ant-design/pro-descriptions": "^1.6.8",
"@ant-design/pro-form": "^1.18.3",
"@ant-design/pro-layout": "^6.15.3",
"@ant-design/pro-table": "^2.30.8",
"@ant-design/pro-table": "^2.67.0",
"@antv/data-set": "^0.11.0",
"@antv/l7": "^2.3.7",
"@antv/l7-maps": "^2.3.7",
@ -65,7 +65,7 @@
"@umijs/route-utils": "^1.0.36",
"ahooks": "^3.0.5",
"ahooks-v2": "^2.10.15",
"antd": "^4.14.0",
"antd": "^4.19.2",
"base-64": "^1.0.0",
"bizcharts": "^3.5.3-beta.0",
"bizcharts-plugin-slider": "^2.1.1-beta.1",

@ -87,14 +87,30 @@ 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);
return response;
};
/** request 用于配置全局的网络请求,你可以在这里做拦截器,全局错误处理,鉴权的配置。*/
export const request: RequestConfig = {
errorHandler: (error: ResponseError) => {
/*notification.error({
console.log('RequestConfig errorHandler', error)
/*
notification.error({
description: '您的网络发生异常,无法连接服务器',
message: '网络异常',
});*/
throw error;
},
//middlewares?: OnionMiddleware[],
//requestInterceptors: [requestInterceptor], // 请求前拦截器
responseInterceptors: [responseInterceptor], // 响应拦截器
};
Loading…
Cancel
Save