fix: menu icon display issue (#6410)

This commit is contained in:
Zeke Zhang 2025-03-11 08:24:19 +08:00 committed by GitHub
parent 69c75566e0
commit 45bfc0649f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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: