From 7d84093dd8f605c48002205f021f8d2244a97318 Mon Sep 17 00:00:00 2001 From: lvjunzhao <967725@dms.yudean.com> Date: Tue, 11 Feb 2025 09:10:15 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E6=9D=83=E9=99=90=E7=AE=A1=E7=90=86-?= =?UTF-8?q?=E7=99=BB=E5=87=BA=EF=BC=8C=E8=B0=83=E6=95=B4=E5=90=8E=E7=AB=AF?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E7=9A=84=E6=98=AF=E4=B8=80=E4=B8=AAmap=20?= =?UTF-8?q?=E7=9A=84String=20=E7=94=A8=E6=84=8F=E6=98=AF=E4=B8=BA=E4=BA=86?= =?UTF-8?q?=E5=89=8D=E7=AB=AF=E5=8F=AF=E4=BB=A5=E7=9B=B4=E6=8E=A5=20get=20?= =?UTF-8?q?=E5=87=BA=E5=AF=B9=E5=BA=94=E5=AD=97=E6=AE=B5=E7=9A=84=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=9D=A5=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/http/axios/index.ts | 38 ++++++++++++++++------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/src/utils/http/axios/index.ts b/src/utils/http/axios/index.ts index 8e572da..6db56d6 100644 --- a/src/utils/http/axios/index.ts +++ b/src/utils/http/axios/index.ts @@ -81,34 +81,30 @@ const transform: AxiosTransform = { case ResultEnum.UNAUTHRAZATION: timeoutMsg = t('登录超时,请重新登录!'); - if (data) { - let split = data.split('||'); - if (split.length > 1) { - let logoutMessage = split[1]; - // 跨页面配置 异常显示提醒 - sessionStorage.setItem('logoutInfoData', JSON.stringify({ - logoutType: split[0], - logoutMessage: logoutMessage, - })); - } - } - const userStore = useUserStoreWithOut(); userStore.setToken(undefined); if (!window.location.hash.includes('login')&&!window.location.pathname.includes('login') &&!window.location.hash.includes('tokenLogin')&&!window.location.pathname.includes('tokenLogin')) { userStore.logout(true); } - if(data.urlToRedirectTo){ - //登录页面不跳转 - if(!window.location.hash.includes('login')&&!window.location.pathname.includes('login') - &&!window.location.hash.includes('tokenLogin')&&!window.location.pathname.includes('tokenLogin')){ - window.location.href=data.urlToRedirectTo; + if (data) { + if(data.urlToRedirectTo){ + //登录页面不跳转 + if(!window.location.hash.includes('login')&&!window.location.pathname.includes('login') + &&!window.location.hash.includes('tokenLogin')&&!window.location.pathname.includes('tokenLogin')){ + window.location.href=data.urlToRedirectTo; + } + options.errorMessageMode="none"; + }else{ + // data 有logout 信息 ,存sessionStorage 给login page 弹框显示 + if (data.logoutMessage) { + sessionStorage.setItem('logoutInfoData', JSON.stringify({ + logoutMessage: data.logoutMessage, + })); + } + const go = useGo(); + go('/login'); } - options.errorMessageMode="none"; - }else{ - const go = useGo(); - go('/login'); } break; default: