From 60b994c226668c5d57821c8768497564ed0fa493 Mon Sep 17 00:00:00 2001 From: lvjunzhao <967725@dms.yudean.com> Date: Mon, 10 Feb 2025 16:32:28 +0800 Subject: [PATCH 1/2] =?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=E5=89=8D=E5=8F=B0=E6=89=93=E5=8D=B0?= =?UTF-8?q?=E7=99=BB=E5=87=BA=E7=9A=84=E5=8E=9F=E5=9B=A0=EF=BC=88=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E7=94=A8=E6=88=B7=E5=9B=A0=E6=9D=83=E9=99=90=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E8=80=8C=E7=99=BB=E5=87=BA)=EF=BC=8C=E7=94=B1?= =?UTF-8?q?=E4=BA=8E=E8=B7=B3=E8=BD=AClogin=20page=20=E7=9A=84=E5=8E=9F?= =?UTF-8?q?=E5=9B=A0=EF=BC=8Chttp=E7=9A=84=E5=BC=B9=E6=A1=86=E4=BC=9A?= =?UTF-8?q?=E8=A2=AB=E8=B7=B3=E8=BD=AC=E7=A7=BB=E9=99=A4=EF=BC=8C=E6=89=80?= =?UTF-8?q?=E6=9C=89=E5=88=A9=E7=94=A8session=E4=BC=A0=E5=88=B0login=20pag?= =?UTF-8?q?e=20=E6=8A=93=E5=87=BA=E6=9D=A5=E5=BC=B9=E6=A1=86=E5=87=BA?= =?UTF-8?q?=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/http/axios/index.ts | 13 +++++++++++++ src/views/sys/login/Login.vue | 13 ++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/utils/http/axios/index.ts b/src/utils/http/axios/index.ts index 9a53489..8e572da 100644 --- a/src/utils/http/axios/index.ts +++ b/src/utils/http/axios/index.ts @@ -80,6 +80,19 @@ const transform: AxiosTransform = { switch (code) { 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') diff --git a/src/views/sys/login/Login.vue b/src/views/sys/login/Login.vue index 7c01d9c..42d7f38 100644 --- a/src/views/sys/login/Login.vue +++ b/src/views/sys/login/Login.vue @@ -42,9 +42,20 @@ import logopng from '/@/assets/images/logo-dark.png'; import logobg from '/@/assets/images/login-left.gif'; import { getLogoInfo } from '/@/api/system/login'; - import { ref } from 'vue'; + import { ref, onMounted } from 'vue'; import { LogoConfig } from '/#/config'; + import { useMessage } from '/@/hooks/web/useMessage'; + const { createErrorModal } = useMessage(); + + onMounted(() => { + let logoutInfoData = JSON.parse(sessionStorage.getItem('logoutInfoData') as string); + if (logoutInfoData) { + createErrorModal({ title: t('错误提示'), content: logoutInfoData.logoutMessage }); + sessionStorage.removeItem('logoutInfoData'); + } + }) + const appStore = useAppStore(); defineProps({ sessionTimeout: { 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 2/2] =?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: