ant design 登录权限控制
在models>>login.ts中 logout 方法 增加 localStorage.removeItem('antd-pro-authority')
当用户退出的时候用调用 login/logout
用户登录时获取 用户的authority 保存在localStorage
authority中 setAuthority 方法
localStorage.setItem('antd-pro-authority', JSON.stringify(proAuthority));
logout() {
const { redirect } = getPageQuery();
localStorage.removeItem('antd-pro-authority')
// Note: There may be security issues, please note
if (window.location.pathname !== '/user/login' && !redirect) {
history.replace({
pathname: '/user/login',
search: stringify({
redirect: window.location.href,
}),
});
}
},
},
本文介绍如何使用AntDesign实现登录权限控制。重点在于通过localStorage管理用户的权限标识authority,并在登录及登出时更新此状态。此外,还介绍了如何重定向用户到登录页面。
809

被折叠的 条评论
为什么被折叠?



