diff --git a/packages/core/client/src/schema-component/antd/filter/FilterAction.tsx b/packages/core/client/src/schema-component/antd/filter/FilterAction.tsx index 906220ee8b..0cba26e021 100644 --- a/packages/core/client/src/schema-component/antd/filter/FilterAction.tsx +++ b/packages/core/client/src/schema-component/antd/filter/FilterAction.tsx @@ -21,6 +21,7 @@ import { useProps } from '../../hooks/useProps'; import { Action, ActionProps } from '../action'; import { DatePickerProvider } from '../date-picker/DatePicker'; import { StablePopover } from '../popover'; +import { useCompile } from '../../'; export const FilterActionContext = createContext(null); FilterActionContext.displayName = 'FilterActionContext'; @@ -50,6 +51,8 @@ export const FilterAction = withDynamicSchemaProps( const [visible, setVisible] = useState(false); const { designable, dn } = useDesignable(); const fieldSchema = useFieldSchema(); + const compile = useCompile(); + const form = useMemo
(() => props.form || createForm(), []); // 新版 UISchema(1.0 之后)中已经废弃了 useProps,这里之所以继续保留是为了兼容旧版的 UISchema @@ -58,7 +61,6 @@ export const FilterAction = withDynamicSchemaProps( const onOpenChange = useCallback((visible: boolean): void => { setVisible(visible); }, []); - return ( { await form.reset(); onReset?.(form.values); - field.title = t('Filter'); + field.title = compile(fieldSchema.title) || t('Filter'); setVisible(false); }} > diff --git a/packages/core/client/src/schema-component/antd/filter/useFilterActionProps.ts b/packages/core/client/src/schema-component/antd/filter/useFilterActionProps.ts index e193e2a2df..516369084c 100644 --- a/packages/core/client/src/schema-component/antd/filter/useFilterActionProps.ts +++ b/packages/core/client/src/schema-component/antd/filter/useFilterActionProps.ts @@ -16,7 +16,7 @@ import { useBlockRequestContext } from '../../../block-provider'; import { useCollectionManager_deprecated, useCollection_deprecated } from '../../../collection-manager'; import { mergeFilter } from '../../../filter-provider/utils'; import { useDataLoadingMode } from '../../../modules/blocks/data-blocks/details-multi/setDataLoadingModeSettingsItem'; - +import { useCompile } from '../../'; export const useGetFilterOptions = () => { const { getCollectionFields } = useCollectionManager_deprecated(); const getFilterFieldOptions = useGetFilterFieldOptions(); @@ -182,6 +182,8 @@ export const useFilterFieldProps = ({ options, service, params }) => { const { t } = useTranslation(); const field = useField(); const dataLoadingMode = useDataLoadingMode(); + const fieldSchema = useFieldSchema(); + const compile = useCompile(); return { options, @@ -205,7 +207,7 @@ export const useFilterFieldProps = ({ options, service, params }) => { if (items?.length) { field.title = t('{{count}} filter items', { count: items?.length || 0 }); } else { - field.title = t('Filter'); + field.title = compile(fieldSchema.title) || t('Filter'); } }, onReset() { @@ -222,8 +224,6 @@ export const useFilterFieldProps = ({ options, service, params }) => { { filters }, ]; - field.title = t('Filter'); - if (dataLoadingMode === 'manual') { service.params = newParams; return service.mutate(undefined);