diff --git a/src/util/AjaxUtils.ts b/src/util/AjaxUtils.ts index 07e2418..2486d58 100644 --- a/src/util/AjaxUtils.ts +++ b/src/util/AjaxUtils.ts @@ -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(req: Req) { 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',