登录超时重定向问题

This commit is contained in:
TS-QD1 2024-07-30 19:02:37 +08:00
parent 4d7240ea96
commit c8b8f26051

View File

@ -38,6 +38,7 @@ axios.interceptors.request.use(config => {
config.data = { unused: 0 } // 这个是关键点解决get 请求添加不上content_type
}
config.headers['X-USER-ID'] = DevUserId;
config.headers['X-SOURCE'] = 'page';
return config
});
@ -82,6 +83,10 @@ export function get<T>(req: Req<T>) {
req.onSuccess(res);
}).catch(error => {
if (error.response) {
if(error.response.status === 401) {
window.location.href = axios.defaults.baseURL ? axios.defaults.baseURL : '';
return;
}
const data = error.response.data;
req.messageApi.open({
type: 'error',