mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-07-02 03:02:19 +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(
|
function convertRoutesToLayout(
|
||||||
routes: NocoBaseDesktopRoute[],
|
routes: NocoBaseDesktopRoute[],
|
||||||
{ designable, parentRoute, isMobile, t, depth = 0 }: any,
|
{ designable, parentRoute, isMobile, t, depth = 0 }: any,
|
||||||
@ -775,9 +788,11 @@ function convertRoutesToLayout(
|
|||||||
};
|
};
|
||||||
|
|
||||||
const result: any[] = routes.map((item) => {
|
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) {
|
if (item.type === NocoBaseDesktopRouteType.link) {
|
||||||
return {
|
return {
|
||||||
name: t(item.title),
|
name,
|
||||||
icon: item.icon ? <Icon type={item.icon} /> : null,
|
icon: item.icon ? <Icon type={item.icon} /> : null,
|
||||||
path: '/',
|
path: '/',
|
||||||
hideInMenu: item.hideInMenu,
|
hideInMenu: item.hideInMenu,
|
||||||
@ -788,7 +803,7 @@ function convertRoutesToLayout(
|
|||||||
|
|
||||||
if (item.type === NocoBaseDesktopRouteType.page) {
|
if (item.type === NocoBaseDesktopRouteType.page) {
|
||||||
return {
|
return {
|
||||||
name: t(item.title),
|
name,
|
||||||
icon: item.icon ? <Icon type={item.icon} /> : null,
|
icon: item.icon ? <Icon type={item.icon} /> : null,
|
||||||
path: `/admin/${item.schemaUid}`,
|
path: `/admin/${item.schemaUid}`,
|
||||||
redirect: `/admin/${item.schemaUid}`,
|
redirect: `/admin/${item.schemaUid}`,
|
||||||
@ -808,7 +823,7 @@ function convertRoutesToLayout(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: t(item.title),
|
name,
|
||||||
icon: item.icon ? <Icon type={item.icon} /> : null,
|
icon: item.icon ? <Icon type={item.icon} /> : null,
|
||||||
path: `/admin/${item.id}`,
|
path: `/admin/${item.id}`,
|
||||||
redirect:
|
redirect:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user