mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 05:29:26 +08:00
fix: menu icon display issue (#6410)
This commit is contained in:
parent
69c75566e0
commit
45bfc0649f
@ -756,6 +756,19 @@ const MenuDesignerButton: FC<{ testId: string }> = (props) => {
|
||||
});
|
||||
};
|
||||
|
||||
const MenuTitleWithIcon: FC<{ icon: any; title: string }> = (props) => {
|
||||
if (props.icon) {
|
||||
return (
|
||||
<div style={{ display: 'flex', alignItems: 'center' }}>
|
||||
<Icon type={props.icon} />
|
||||
<span>{props.title}</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return props.title;
|
||||
};
|
||||
|
||||
function convertRoutesToLayout(
|
||||
routes: NocoBaseDesktopRoute[],
|
||||
{ designable, parentRoute, isMobile, t, depth = 0 }: any,
|
||||
@ -775,9 +788,11 @@ function convertRoutesToLayout(
|
||||
};
|
||||
|
||||
const result: any[] = routes.map((item) => {
|
||||
const name = depth > 1 ? <MenuTitleWithIcon icon={item.icon} title={t(item.title)} /> : t(item.title); // ProLayout 组件不显示第二级菜单的 icon,所以这里自己实现
|
||||
|
||||
if (item.type === NocoBaseDesktopRouteType.link) {
|
||||
return {
|
||||
name: t(item.title),
|
||||
name,
|
||||
icon: item.icon ? <Icon type={item.icon} /> : null,
|
||||
path: '/',
|
||||
hideInMenu: item.hideInMenu,
|
||||
@ -788,7 +803,7 @@ function convertRoutesToLayout(
|
||||
|
||||
if (item.type === NocoBaseDesktopRouteType.page) {
|
||||
return {
|
||||
name: t(item.title),
|
||||
name,
|
||||
icon: item.icon ? <Icon type={item.icon} /> : null,
|
||||
path: `/admin/${item.schemaUid}`,
|
||||
redirect: `/admin/${item.schemaUid}`,
|
||||
@ -808,7 +823,7 @@ function convertRoutesToLayout(
|
||||
}
|
||||
|
||||
return {
|
||||
name: t(item.title),
|
||||
name,
|
||||
icon: item.icon ? <Icon type={item.icon} /> : null,
|
||||
path: `/admin/${item.id}`,
|
||||
redirect:
|
||||
|
Loading…
x
Reference in New Issue
Block a user