diff --git a/packages/core/client/src/route-switch/antd/admin-layout/index.tsx b/packages/core/client/src/route-switch/antd/admin-layout/index.tsx index 453b98395b..11140af450 100644 --- a/packages/core/client/src/route-switch/antd/admin-layout/index.tsx +++ b/packages/core/client/src/route-switch/antd/admin-layout/index.tsx @@ -126,18 +126,6 @@ const MenuEditor = (props) => { }, ); - const match = useMatch('/admin/:name'); - - useEffect(() => { - if (match) { - const schema = filterByACL(data?.data, ctx); - const s = findByUid(schema, defaultSelectedUid); - if (s) { - setTitle(s.title); - } - } - }, [data?.data, location.pathname, defaultSelectedUid]); - useEffect(() => { const properties = Object.values(current?.root?.properties || {}).shift()?.['properties'] || data?.data?.properties; if (sideMenuRef.current) { diff --git a/packages/core/client/src/schema-component/antd/menu/Menu.Designer.tsx b/packages/core/client/src/schema-component/antd/menu/Menu.Designer.tsx index 9950aa41d1..72fe690f1e 100644 --- a/packages/core/client/src/schema-component/antd/menu/Menu.Designer.tsx +++ b/packages/core/client/src/schema-component/antd/menu/Menu.Designer.tsx @@ -4,7 +4,7 @@ import { ISchema, Schema, useField, useFieldSchema } from '@formily/react'; import React from 'react'; import { useTranslation } from 'react-i18next'; import { findByUid } from '.'; -import { createDesignable } from '../..'; +import { createDesignable, useCompile } from '../..'; import { GeneralSchemaDesigner, SchemaSettingsDivider, @@ -208,6 +208,8 @@ export const MenuDesigner = () => { const { dn, refresh } = useDesignable(); const { t } = useTranslation(); const menuSchema = findMenuSchema(fieldSchema); + const compile = useCompile(); + const onSelect = compile(menuSchema?.['x-component-props']?.['onSelect']); const items = toItems(menuSchema?.properties); const effects = (form) => { onFieldChange('target', (field: Field) => { @@ -286,6 +288,7 @@ export const MenuDesigner = () => { fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {}; fieldSchema['x-component-props']['icon'] = icon; fieldSchema['x-component-props']['href'] = href; + onSelect?.({ item: { props: { schema: fieldSchema } } }); dn.emit('patch', { schema, }); diff --git a/packages/core/client/src/schema-component/antd/page/Page.tsx b/packages/core/client/src/schema-component/antd/page/Page.tsx index 5c5fe6f609..9ab7965122 100644 --- a/packages/core/client/src/schema-component/antd/page/Page.tsx +++ b/packages/core/client/src/schema-component/antd/page/Page.tsx @@ -24,6 +24,7 @@ import { ErrorFallback } from '../error-fallback'; import FixedBlock from './FixedBlock'; import { PageDesigner, PageTabDesigner } from './PageTabDesigner'; import { useStyles } from './style'; +import { useRequest } from '../../../api-client'; export const Page = (props) => { const { children, ...others } = props; @@ -62,11 +63,24 @@ export const Page = (props) => { const { wrapSSR, hashId, componentCls } = useStyles(); const aclStyles = useAClStyles(); + const pageHeaderTitle = hidePageTitle ? undefined : fieldSchema.title || compile(title); + + useRequest( + { + url: `/uiSchemas:getParentJsonSchema/${fieldSchema['x-uid']}`, + }, + { + ready: !hidePageTitle && !pageHeaderTitle, + onSuccess(data) { + setTitle(data.data.title); + }, + }, + ); + const handleErrors = (error) => { console.error(error); }; - const pageHeaderTitle = hidePageTitle ? undefined : fieldSchema.title || compile(title); return wrapSSR(