fix: menu modifications do not take effect in real-time (#5207)

* fix: menu modifications do not take effect in real-time

* fix: bug
This commit is contained in:
Katherine 2024-09-09 19:42:12 +08:00 committed by GitHub
parent db57b21e1a
commit 4399856eae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 4 additions and 6 deletions

View File

@ -272,7 +272,7 @@ export const MenuDesigner = () => {
title: field.title, title: field.title,
icon: field.componentProps.icon, icon: field.componentProps.icon,
}; };
}, [field]); }, [field.title, field.componentProps.icon]);
if (fieldSchema['x-component'] === 'Menu.URL') { if (fieldSchema['x-component'] === 'Menu.URL') {
schema.properties['href'] = urlSchema; schema.properties['href'] = urlSchema;
schema.properties['params'] = paramsSchema; schema.properties['params'] = paramsSchema;
@ -364,7 +364,6 @@ export const MenuDesigner = () => {
title: t('Delete menu item'), title: t('Delete menu item'),
}; };
}, [t]); }, [t]);
return ( return (
<GeneralSchemaDesigner> <GeneralSchemaDesigner>
<SchemaSettingsModalItem <SchemaSettingsModalItem

View File

@ -267,7 +267,6 @@ const HeaderMenu = ({
}, },
[schema, mode, onSelect, setLoading, setDefaultSelectedKeys], [schema, mode, onSelect, setLoading, setDefaultSelectedKeys],
); );
return ( return (
<> <>
<Component /> <Component />
@ -530,14 +529,14 @@ Menu.Item = observer(
removeParentsIfNoChildren={false} removeParentsIfNoChildren={false}
> >
<Icon type={icon} /> <Icon type={icon} />
<span style={menuItemTitleStyle}>{t(field.title)}</span> <span style={menuItemTitleStyle}>{t(schema.title)}</span>
<Designer /> <Designer />
</SortableItem> </SortableItem>
</FieldContext.Provider> </FieldContext.Provider>
</SchemaContext.Provider> </SchemaContext.Provider>
), ),
}; };
}, [field.title, icon, schema, Designer]); }, [schema.title, icon, schema, Designer]);
if (!pushMenuItem) { if (!pushMenuItem) {
error('Menu.Item must be wrapped by GetMenuItemsContext.Provider'); error('Menu.Item must be wrapped by GetMenuItemsContext.Provider');

View File

@ -35,12 +35,12 @@ export const CustomRequestInitializer: React.FC<any> = (props) => {
const customRequestsResource = useCustomRequestsResource(); const customRequestsResource = useCustomRequestsResource();
const itemConfig = useSchemaInitializerItem(); const itemConfig = useSchemaInitializerItem();
const { insert } = useSchemaInitializer(); const { insert } = useSchemaInitializer();
const schema = getNewSchema();
return ( return (
<SchemaInitializerItem <SchemaInitializerItem
{...itemConfig} {...itemConfig}
onClick={async () => { onClick={async () => {
const schema = getNewSchema();
const s = merge(schema || {}, itemConfig.schema || {}); const s = merge(schema || {}, itemConfig.schema || {});
itemConfig?.schemaInitialize?.(s); itemConfig?.schemaInitialize?.(s);
insert(s); insert(s);