feat:权限管理-登出,调整后端返回的是一个map 的String 用意是为了前端可以直接 get 出对应字段的数据来处理
This commit is contained in:
@ -81,34 +81,30 @@ 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.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')){
|
if(!window.location.hash.includes('login')&&!window.location.pathname.includes('login')
|
||||||
window.location.href=data.urlToRedirectTo;
|
&&!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;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user