diff --git a/packages/core/flow-engine/src/components/subModel/LazyDropdown.tsx b/packages/core/flow-engine/src/components/subModel/LazyDropdown.tsx index ec2a0b90d6..707d9bca24 100644 --- a/packages/core/flow-engine/src/components/subModel/LazyDropdown.tsx +++ b/packages/core/flow-engine/src/components/subModel/LazyDropdown.tsx @@ -9,6 +9,7 @@ import { Dropdown, DropdownProps, Input, Menu, Spin, Empty, InputProps } from 'antd'; import React, { useEffect, useState, useMemo, useRef, FC } from 'react'; +import { useFlowModel } from '../../hooks'; /** * 通过鼠标的位置计算出最佳的 dropdown 的高度,以尽量避免出现滚动条 @@ -72,6 +73,7 @@ interface LazyDropdownMenuProps extends Omit { } const LazyDropdown: React.FC & { menu: LazyDropdownMenuProps }> = ({ menu, ...props }) => { + const model = useFlowModel(); const [loadedChildren, setLoadedChildren] = useState>({}); const [loadingKeys, setLoadingKeys] = useState>(new Set()); const [menuVisible, setMenuVisible] = useState(false); @@ -82,6 +84,7 @@ const LazyDropdown: React.FC & { menu: LazyDropdownM const dropdownMaxHeight = useNiceDropdownMaxHeight([menuVisible]); const [isSearching, setIsSearching] = useState(false); const searchTimeoutRef = useRef(null); + const t = model.flowEngine.translate.bind(model.flowEngine); // 清理定时器,避免内存泄露 useEffect(() => { @@ -223,7 +226,7 @@ const LazyDropdown: React.FC & { menu: LazyDropdownM visible={menuVisible} variant="borderless" allowClear - placeholder={item.searchPlaceholder || 'search'} + placeholder={t(item.searchPlaceholder || 'Search')} value={currentSearchValue} onChange={(e) => { e.stopPropagation(); @@ -264,7 +267,7 @@ const LazyDropdown: React.FC & { menu: LazyDropdownM key: `${item.key}-empty`, label: (
- +
), disabled: true, @@ -278,7 +281,7 @@ const LazyDropdown: React.FC & { menu: LazyDropdownM return { type: 'group', key: item.key, - label: item.label, + label: typeof item.label === 'string' ? t(item.label) : item.label, children: groupChildren, }; } @@ -289,7 +292,7 @@ const LazyDropdown: React.FC & { menu: LazyDropdownM return { key: item.key, - label: item.label, + label: typeof item.label === 'string' ? t(item.label) : item.label, onClick: (info) => { if (children) { return; @@ -316,7 +319,7 @@ const LazyDropdown: React.FC & { menu: LazyDropdownM key: `${keyPath}-empty`, label: (
- +
), disabled: true,