Commit 6e5f03eb authored by jiangzijing's avatar jiangzijing

feat:token失效跳转登录页面

parent fe0ca110
......@@ -21,7 +21,7 @@ const useMyRequest = <TData, TParams>(
defaultParams?: TParams[];
onBefore?: (params: TParams[]) => void;
onSuccess?: (data: TData, params: TParams[]) => void;
onError?: (e: Error, params: TParams[]) => void;
onError?: (e: any, params: TParams[]) => void;
onFinally?: (params: TParams[], data?: TData, e?: Error) => void;
loadingDelay?: number;
pollingInterval?: number;
......@@ -51,9 +51,16 @@ const useMyRequest = <TData, TParams>(
const request = useRequest(api, {
...defaultOptions,
onSuccess: () => {},
onError: (data) => {
onSuccess: () => { },
onError: (data: any) => {
Message.error(data.message);
if (data.errorCode === '100003') {
setTimeout(() => {
localStorage.removeItem('token_key');
if (window.location.href && !window.location.href.includes("/login-page"))
window.location.href = '/v2/pages/login-page'
}, 4000);
}
},
...options,
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment