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,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: