From 9acb908981b7565afee563ff12978e3dc3a96e5f Mon Sep 17 00:00:00 2001 From: katherinehhh Date: Fri, 29 Mar 2024 10:32:47 +0800 Subject: [PATCH] fix: templateBlockProvider support association field append --- .../core/client/src/block-provider/BlockProvider.tsx | 4 +++- .../client/src/block-provider/DetailsBlockProvider.tsx | 9 ++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/core/client/src/block-provider/BlockProvider.tsx b/packages/core/client/src/block-provider/BlockProvider.tsx index 11040c5f0..48cfe0732 100644 --- a/packages/core/client/src/block-provider/BlockProvider.tsx +++ b/packages/core/client/src/block-provider/BlockProvider.tsx @@ -30,6 +30,7 @@ import { DataBlockCollector } from '../filter-provider/FilterProvider'; import { RecordProvider, useRecordIndex } from '../record-provider'; import { useAssociationNames } from './hooks'; import { useDataBlockSourceId } from './hooks/useDataBlockSourceId'; +import { useTemplateBlockContext } from './TemplateBlockProvider'; /** * @deprecated @@ -228,6 +229,7 @@ export const BlockProvider = (props: { }) => { const { name, dataSource, association, useParams, parentRecord } = props; const sourceId = useCompatDataBlockSourceId(props); + const { templateFinshed } = useTemplateBlockContext(); // 新版(1.0)已弃用 useParams,这里之所以继续保留是为了兼容旧版的 UISchema const paramsFromHook = useParams?.(); @@ -239,7 +241,7 @@ export const BlockProvider = (props: { return { ...props.params, appends, ...paramsFromHook }; } return { ...props.params, ...paramsFromHook }; - }, [appends, paramsFromHook, props.params]); + }, [appends, paramsFromHook, props.params, templateFinshed]); const blockValue = useMemo(() => ({ name }), [name]); return ( diff --git a/packages/core/client/src/block-provider/DetailsBlockProvider.tsx b/packages/core/client/src/block-provider/DetailsBlockProvider.tsx index a0abf1c1b..83c27bf29 100644 --- a/packages/core/client/src/block-provider/DetailsBlockProvider.tsx +++ b/packages/core/client/src/block-provider/DetailsBlockProvider.tsx @@ -8,6 +8,7 @@ import { RecordProvider } from '../record-provider'; import { BlockProvider, useBlockRequestContext } from './BlockProvider'; import { useParsedFilter } from './hooks'; import { withDynamicSchemaProps } from '../application/hoc/withDynamicSchemaProps'; +import { TemplateBlockProvider } from './TemplateBlockProvider'; export const DetailsBlockContext = createContext({}); DetailsBlockContext.displayName = 'DetailsBlockContext'; @@ -64,9 +65,11 @@ const InternalDetailsBlockProvider = (props) => { export const DetailsBlockProvider = withDynamicSchemaProps((props) => { return ( - - - + + + + + ); });