From c8b8f260511c7c721a0666e368c98c4649de7baf Mon Sep 17 00:00:00 2001 From: TS-QD1 Date: Tue, 30 Jul 2024 19:02:37 +0800 Subject: [PATCH] =?UTF-8?q?=E7=99=BB=E5=BD=95=E8=B6=85=E6=97=B6=E9=87=8D?= =?UTF-8?q?=E5=AE=9A=E5=90=91=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/util/AjaxUtils.ts | 5 +++++ 1 file changed, 5 insertions(+) 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',