feat:权限管理-登出,调整后端返回的是一个map 的String 用意是为了前端可以直接 get 出对应字段的数据来处理

This commit is contained in:
lvjunzhao
2025-02-11 09:10:15 +08:00
parent 187957be60
commit 7d84093dd8

View File

@ -81,24 +81,13 @@ const transform: AxiosTransform = {
case ResultEnum.UNAUTHRAZATION: case ResultEnum.UNAUTHRAZATION:
timeoutMsg = t('登录超时,请重新登录!'); 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(); const userStore = useUserStoreWithOut();
userStore.setToken(undefined); userStore.setToken(undefined);
if (!window.location.hash.includes('login')&&!window.location.pathname.includes('login') if (!window.location.hash.includes('login')&&!window.location.pathname.includes('login')
&&!window.location.hash.includes('tokenLogin')&&!window.location.pathname.includes('tokenLogin')) { &&!window.location.hash.includes('tokenLogin')&&!window.location.pathname.includes('tokenLogin')) {
userStore.logout(true); userStore.logout(true);
} }
if (data) {
if(data.urlToRedirectTo){ if(data.urlToRedirectTo){
//登录页面不跳转 //登录页面不跳转
if(!window.location.hash.includes('login')&&!window.location.pathname.includes('login') if(!window.location.hash.includes('login')&&!window.location.pathname.includes('login')
@ -107,9 +96,16 @@ const transform: AxiosTransform = {
} }
options.errorMessageMode="none"; options.errorMessageMode="none";
}else{ }else{
// data 有logout 信息 存sessionStorage 给login page 弹框显示
if (data.logoutMessage) {
sessionStorage.setItem('logoutInfoData', JSON.stringify({
logoutMessage: data.logoutMessage,
}));
}
const go = useGo(); const go = useGo();
go('/login'); go('/login');
} }
}
break; break;
default: default:
if (msg) { if (msg) {