未登录用户不可访问后台管理、给角色分配三级菜单失效问题

This commit is contained in:
谢思 2022-11-29 17:16:16 +08:00
parent c5ee88a23c
commit 1c97c59adc
2 changed files with 26 additions and 2 deletions

View File

@ -139,6 +139,16 @@ const GatheringList = Loadable({
})
const Managements = (propsF) => {
useEffect(()=>{
const {current_user, history} = propsF;
if(current_user && current_user.login){
if(!current_user.admin){
history.push('/403')
}
}else{
propsF.showLoginDialog();
}
},[])
return (
<div className="newMain clearfix managementMain">

View File

@ -31,6 +31,8 @@ export default Form.create()(({form}) => {
const [selectedMenuFa, setSelectedMenuFa] = useState(undefined);
//
let oneTree = [];
//
let twoTree = [];
const helper = useCallback(
(label, name, rules, widget, initialValue) => (
@ -216,7 +218,9 @@ export default Form.create()(({form}) => {
listMenu(roleId).then(response=>{
if(response && response.message=='success'){
//
const keys = response.data.map(item=>{return oneTree.indexOf(item.key.toString()) === -1 ? item.key.toString() : null});
const keys = response.data.map(item=>{
return (oneTree.indexOf(item.key.toString()) !== -1 || twoTree.indexOf(item.key.toString()) !== -1) ? null : item.key.toString()
});
setSelectedMenu(keys);
setRoleId(roleId);
setMenuModal(true);
@ -239,7 +243,17 @@ export default Form.create()(({form}) => {
useEffect(()=>{
treeList().then(response=>{
if(response && response.message=='success'){
oneTree = response.data.map(item=>{return item.key.toString()});
// antd tree checkedKeys
response.data.map(item=>{
oneTree.push(item.key.toString())
if(item.children && item.children.length){
item.children.map(i =>{
if(i.children && i.children.length){
twoTree.push(i.key.toString());
}
})
}
})
setMenuTreeData(response.data);
}
}).finally(()=>{