|
|
|
@ -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], // 响应拦截器
|
|
|
|
|
};
|