diff --git a/web/app/components/workflow/nodes/if-else/components/condition-list/condition-item.tsx b/web/app/components/workflow/nodes/if-else/components/condition-list/condition-item.tsx index 803f8d14a5..e73654f974 100644 --- a/web/app/components/workflow/nodes/if-else/components/condition-list/condition-item.tsx +++ b/web/app/components/workflow/nodes/if-else/components/condition-list/condition-item.tsx @@ -260,6 +260,7 @@ const ConditionItem = ({ onValueChange={handleUpdateConditionValue} variables={numberVariables} isShort={isValueFieldShort} + unit={fileAttr?.key === 'size' ? 'Byte' : undefined} /> ) diff --git a/web/app/components/workflow/nodes/if-else/components/condition-number-input.tsx b/web/app/components/workflow/nodes/if-else/components/condition-number-input.tsx index c8ff090aae..5dabd967cd 100644 --- a/web/app/components/workflow/nodes/if-else/components/condition-number-input.tsx +++ b/web/app/components/workflow/nodes/if-else/components/condition-number-input.tsx @@ -6,6 +6,7 @@ import { import { useTranslation } from 'react-i18next' import { RiArrowDownSLine } from '@remixicon/react' import { capitalize } from 'lodash-es' +import { useBoolean } from 'ahooks' import { VarType as NumberVarType } from '../../tool/types' import VariableTag from '../../_base/components/variable-tag' import { @@ -36,6 +37,7 @@ type ConditionNumberInputProps = { onValueChange: (v: string) => void variables: NodeOutPutVar[] isShort?: boolean + unit?: string } const ConditionNumberInput = ({ numberVarType = NumberVarType.constant, @@ -44,10 +46,15 @@ const ConditionNumberInput = ({ onValueChange, variables, isShort, + unit, }: ConditionNumberInputProps) => { const { t } = useTranslation() const [numberVarTypeVisible, setNumberVarTypeVisible] = useState(false) const [variableSelectorVisible, setVariableSelectorVisible] = useState(false) + const [isFocus, { + setTrue: setFocus, + setFalse: setBlur, + }] = useBoolean() const handleSelectVariable = useCallback((valueSelector: ValueSelector) => { onValueChange(variableTransformer(valueSelector) as string) @@ -139,13 +146,18 @@ const ConditionNumberInput = ({ } { numberVarType === NumberVarType.constant && ( - onValueChange(e.target.value)} - placeholder={t('workflow.nodes.ifElse.enterValue') || ''} - /> +
+ onValueChange(e.target.value)} + placeholder={t('workflow.nodes.ifElse.enterValue') || ''} + onFocus={setFocus} + onBlur={setBlur} + /> + {!isFocus && unit &&
{unit}
} +
) }