答案 0 :(得分:2)
如果要在侧边栏菜单中隐藏资源,可以省略资源的列表道具。
<Resource name="posts" />
答案 1 :(得分:0)
如文档中所述,您可以使用Menu
道具将Admin
组件提供给menu
组件。看到
https://marmelab.com/react-admin/Admin.html#menu
请注意,此道具将很快弃用,而不是appLayout
,但您仍会在自定义布局中使用此自定义菜单。
// in src/Menu.js
import React from 'react';
import { connect } from 'react-redux';
import { MenuItemLink, getResources } from 'react-admin';
import { withRouter } from 'react-router-dom';
import Responsive from '../layout/Responsive';
const Menu = ({ resources, onMenuClick, logout }) => (
<div>
{resources
.filter(resource => resource.name !== 'excluded-resource')
.map(resource => (
<MenuItemLink to={`/${resource.name}`} primaryText={resource.name} onClick={onMenuClick} />
))
}
<Responsive
small={logout}
medium={null} // Pass null to render nothing on larger devices
/>
</div>
);
const mapStateToProps = state => ({
// Rerieve all known resources
resources: getResources(state),
});
export default withRouter(connect(mapStateToProps)(Menu));
答案 2 :(得分:0)
我发现了另一种“ hacky”方式 您可以在CSS中添加以下内容,以从菜单中隐藏资源
.MuiDrawer-root a[href^='#/resource-to-exclude'] {
display: none;
}