From 961949ff7ec393d75b0059ea697aab87c9dd587d Mon Sep 17 00:00:00 2001 From: luofann Date: Mon, 21 Aug 2023 12:15:00 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dinit=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E8=BF=94=E5=9B=9E401=E6=97=B6=E9=A1=B5=E9=9D=A2=E6=9C=AA?= =?UTF-8?q?=E8=B7=B3=E8=BD=AC=E5=88=B0=E7=99=BB=E5=BD=95=E9=A1=B5=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/pc/src/utils/ajax.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/frontend/pc/src/utils/ajax.js b/frontend/pc/src/utils/ajax.js index a5eb032cb..f1429fe55 100644 --- a/frontend/pc/src/utils/ajax.js +++ b/frontend/pc/src/utils/ajax.js @@ -83,6 +83,13 @@ instance.interceptors.request.use( instance.interceptors.response.use( (response) => { if (response.config.url === 'init/') { + if (response.status === 401) { + const { login_url } = response.data; + const url = `${login_url.split('c_url=')[0]}c_url=${encodeURIComponent(location.href)}`; + response.data.login_url = url; + window.open(url, '_self'); + return; + } if ('IS_ITSM_ADMIN' in response.data.data) { const { DEFAULT_PROJECT, IS_ITSM_ADMIN, all_access, chname, username } = response.data.data; window.DEFAULT_PROJECT = DEFAULT_PROJECT; @@ -92,12 +99,6 @@ instance.interceptors.response.use( window.username = username; return response; } - if (response.status === 401) { - const { login_url } = response.data; - const url = `${login_url.split('c_url=')[0]}c_url=${encodeURIComponent(location.href)}`; - response.data.login_url = url; - window.open(url, '_self'); - } } // status >= 200 && status <= 505 if (response.status !== 499 && 'result' in response.data && !response.data.result && 'message' in response.data) {