fix(client): compile menu title
This commit is contained in:
parent
5cacee4e7f
commit
5e079d38f2
@ -72,6 +72,7 @@ import { createPortal } from 'react-dom';
|
|||||||
import { Resource } from '../../resource';
|
import { Resource } from '../../resource';
|
||||||
import { useClient } from '../../constate';
|
import { useClient } from '../../constate';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { useCompile } from '../../hooks/useCompile';
|
||||||
|
|
||||||
export interface MenuContextProps {
|
export interface MenuContextProps {
|
||||||
schema?: Schema;
|
schema?: Schema;
|
||||||
@ -273,6 +274,8 @@ Menu.Divider = observer(AntdMenu.Divider);
|
|||||||
Menu.Item = observer((props: any) => {
|
Menu.Item = observer((props: any) => {
|
||||||
const { icon } = props;
|
const { icon } = props;
|
||||||
const { schema, DesignableBar } = useDesignable();
|
const { schema, DesignableBar } = useDesignable();
|
||||||
|
const compile = useCompile();
|
||||||
|
const title = compile(schema.title);
|
||||||
return (
|
return (
|
||||||
<AntdMenu.Item
|
<AntdMenu.Item
|
||||||
{...props}
|
{...props}
|
||||||
@ -283,7 +286,7 @@ Menu.Item = observer((props: any) => {
|
|||||||
<SortableItem
|
<SortableItem
|
||||||
id={schema.name}
|
id={schema.name}
|
||||||
data={{
|
data={{
|
||||||
title: schema.title,
|
title,
|
||||||
path: getSchemaPath(schema),
|
path: getSchemaPath(schema),
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@ -292,7 +295,7 @@ Menu.Item = observer((props: any) => {
|
|||||||
<IconPicker type={icon} />
|
<IconPicker type={icon} />
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
{schema.title}
|
{title}
|
||||||
<DesignableBar />
|
<DesignableBar />
|
||||||
</SortableItem>
|
</SortableItem>
|
||||||
</AntdMenu.Item>
|
</AntdMenu.Item>
|
||||||
@ -302,6 +305,8 @@ Menu.Item = observer((props: any) => {
|
|||||||
Menu.Link = observer((props: any) => {
|
Menu.Link = observer((props: any) => {
|
||||||
const { icon } = props;
|
const { icon } = props;
|
||||||
const { schema, DesignableBar } = useDesignable();
|
const { schema, DesignableBar } = useDesignable();
|
||||||
|
const compile = useCompile();
|
||||||
|
const title = compile(schema.title);
|
||||||
return (
|
return (
|
||||||
<AntdMenu.Item
|
<AntdMenu.Item
|
||||||
{...props}
|
{...props}
|
||||||
@ -312,7 +317,7 @@ Menu.Link = observer((props: any) => {
|
|||||||
<SortableItem
|
<SortableItem
|
||||||
id={schema.name}
|
id={schema.name}
|
||||||
data={{
|
data={{
|
||||||
title: schema.title,
|
title,
|
||||||
path: getSchemaPath(schema),
|
path: getSchemaPath(schema),
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@ -321,7 +326,7 @@ Menu.Link = observer((props: any) => {
|
|||||||
<IconPicker type={icon} />
|
<IconPicker type={icon} />
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
{schema.title}
|
{title}
|
||||||
<DesignableBar />
|
<DesignableBar />
|
||||||
</SortableItem>
|
</SortableItem>
|
||||||
{/* <Link to={props.to || schema.name}>{schema.title}</Link> */}
|
{/* <Link to={props.to || schema.name}>{schema.title}</Link> */}
|
||||||
@ -333,6 +338,8 @@ Menu.Link = observer((props: any) => {
|
|||||||
Menu.URL = observer((props: any) => {
|
Menu.URL = observer((props: any) => {
|
||||||
const { icon } = props;
|
const { icon } = props;
|
||||||
const { schema, DesignableBar } = useDesignable();
|
const { schema, DesignableBar } = useDesignable();
|
||||||
|
const compile = useCompile();
|
||||||
|
const title = compile(schema.title);
|
||||||
return (
|
return (
|
||||||
<AntdMenu.Item
|
<AntdMenu.Item
|
||||||
{...props}
|
{...props}
|
||||||
@ -346,7 +353,7 @@ Menu.URL = observer((props: any) => {
|
|||||||
<SortableItem
|
<SortableItem
|
||||||
id={schema.name}
|
id={schema.name}
|
||||||
data={{
|
data={{
|
||||||
title: schema.title,
|
title,
|
||||||
path: getSchemaPath(schema),
|
path: getSchemaPath(schema),
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@ -355,7 +362,7 @@ Menu.URL = observer((props: any) => {
|
|||||||
<IconPicker type={icon} />
|
<IconPicker type={icon} />
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
{schema.title}
|
{title}
|
||||||
<DesignableBar />
|
<DesignableBar />
|
||||||
</SortableItem>
|
</SortableItem>
|
||||||
<DesignableBar />
|
<DesignableBar />
|
||||||
@ -369,6 +376,8 @@ Menu.Action = observer((props: any) => {
|
|||||||
const field = useField();
|
const field = useField();
|
||||||
const [visible, setVisible] = useState(false);
|
const [visible, setVisible] = useState(false);
|
||||||
const { run } = useAction();
|
const { run } = useAction();
|
||||||
|
const compile = useCompile();
|
||||||
|
const title = compile(schema.title);
|
||||||
return (
|
return (
|
||||||
<VisibleContext.Provider value={[visible, setVisible]}>
|
<VisibleContext.Provider value={[visible, setVisible]}>
|
||||||
<AntdMenu.Item
|
<AntdMenu.Item
|
||||||
@ -384,11 +393,11 @@ Menu.Action = observer((props: any) => {
|
|||||||
<SortableItem
|
<SortableItem
|
||||||
id={schema.name}
|
id={schema.name}
|
||||||
data={{
|
data={{
|
||||||
title: schema.title,
|
title,
|
||||||
path: getSchemaPath(schema),
|
path: getSchemaPath(schema),
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{schema.title}
|
{title}
|
||||||
<DesignableBar />
|
<DesignableBar />
|
||||||
</SortableItem>
|
</SortableItem>
|
||||||
</AntdMenu.Item>
|
</AntdMenu.Item>
|
||||||
@ -402,6 +411,8 @@ Menu.SubMenu = observer((props: any) => {
|
|||||||
const { icon } = props;
|
const { icon } = props;
|
||||||
const { schema, DesignableBar } = useDesignable();
|
const { schema, DesignableBar } = useDesignable();
|
||||||
const mode = useContext(MenuModeContext);
|
const mode = useContext(MenuModeContext);
|
||||||
|
const compile = useCompile();
|
||||||
|
const title = compile(schema.title);
|
||||||
return mode === 'mix' ? (
|
return mode === 'mix' ? (
|
||||||
<Menu.Item {...props} />
|
<Menu.Item {...props} />
|
||||||
) : (
|
) : (
|
||||||
@ -413,7 +424,7 @@ Menu.SubMenu = observer((props: any) => {
|
|||||||
<SortableItem
|
<SortableItem
|
||||||
id={schema.name}
|
id={schema.name}
|
||||||
data={{
|
data={{
|
||||||
title: schema.title,
|
title,
|
||||||
path: getSchemaPath(schema),
|
path: getSchemaPath(schema),
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@ -422,7 +433,7 @@ Menu.SubMenu = observer((props: any) => {
|
|||||||
<IconPicker type={icon} />
|
<IconPicker type={icon} />
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
{schema.title}
|
{title}
|
||||||
<DesignableBar />
|
<DesignableBar />
|
||||||
</SortableItem>
|
</SortableItem>
|
||||||
// <>
|
// <>
|
||||||
|
Loading…
Reference in New Issue
Block a user