mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-19 15:09:11 +08:00
feat: support file size unit
This commit is contained in:
parent
6c5fcd1ffc
commit
7e8bafe186
@ -260,6 +260,7 @@ const ConditionItem = ({
|
|||||||
onValueChange={handleUpdateConditionValue}
|
onValueChange={handleUpdateConditionValue}
|
||||||
variables={numberVariables}
|
variables={numberVariables}
|
||||||
isShort={isValueFieldShort}
|
isShort={isValueFieldShort}
|
||||||
|
unit={fileAttr?.key === 'size' ? 'Byte' : undefined}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
@ -6,6 +6,7 @@ import {
|
|||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { RiArrowDownSLine } from '@remixicon/react'
|
import { RiArrowDownSLine } from '@remixicon/react'
|
||||||
import { capitalize } from 'lodash-es'
|
import { capitalize } from 'lodash-es'
|
||||||
|
import { useBoolean } from 'ahooks'
|
||||||
import { VarType as NumberVarType } from '../../tool/types'
|
import { VarType as NumberVarType } from '../../tool/types'
|
||||||
import VariableTag from '../../_base/components/variable-tag'
|
import VariableTag from '../../_base/components/variable-tag'
|
||||||
import {
|
import {
|
||||||
@ -36,6 +37,7 @@ type ConditionNumberInputProps = {
|
|||||||
onValueChange: (v: string) => void
|
onValueChange: (v: string) => void
|
||||||
variables: NodeOutPutVar[]
|
variables: NodeOutPutVar[]
|
||||||
isShort?: boolean
|
isShort?: boolean
|
||||||
|
unit?: string
|
||||||
}
|
}
|
||||||
const ConditionNumberInput = ({
|
const ConditionNumberInput = ({
|
||||||
numberVarType = NumberVarType.constant,
|
numberVarType = NumberVarType.constant,
|
||||||
@ -44,10 +46,15 @@ const ConditionNumberInput = ({
|
|||||||
onValueChange,
|
onValueChange,
|
||||||
variables,
|
variables,
|
||||||
isShort,
|
isShort,
|
||||||
|
unit,
|
||||||
}: ConditionNumberInputProps) => {
|
}: ConditionNumberInputProps) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const [numberVarTypeVisible, setNumberVarTypeVisible] = useState(false)
|
const [numberVarTypeVisible, setNumberVarTypeVisible] = useState(false)
|
||||||
const [variableSelectorVisible, setVariableSelectorVisible] = useState(false)
|
const [variableSelectorVisible, setVariableSelectorVisible] = useState(false)
|
||||||
|
const [isFocus, {
|
||||||
|
setTrue: setFocus,
|
||||||
|
setFalse: setBlur,
|
||||||
|
}] = useBoolean()
|
||||||
|
|
||||||
const handleSelectVariable = useCallback((valueSelector: ValueSelector) => {
|
const handleSelectVariable = useCallback((valueSelector: ValueSelector) => {
|
||||||
onValueChange(variableTransformer(valueSelector) as string)
|
onValueChange(variableTransformer(valueSelector) as string)
|
||||||
@ -139,13 +146,18 @@ const ConditionNumberInput = ({
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
numberVarType === NumberVarType.constant && (
|
numberVarType === NumberVarType.constant && (
|
||||||
|
<div className=' relative'>
|
||||||
<input
|
<input
|
||||||
className='block w-full px-2 text-[13px] text-components-input-text-filled placeholder:text-components-input-text-placeholder outline-none appearance-none bg-transparent'
|
className={cn('block w-full px-2 text-[13px] text-components-input-text-filled placeholder:text-components-input-text-placeholder outline-none appearance-none bg-transparent', unit && 'pr-6')}
|
||||||
type='number'
|
type='number'
|
||||||
value={value}
|
value={value}
|
||||||
onChange={e => onValueChange(e.target.value)}
|
onChange={e => onValueChange(e.target.value)}
|
||||||
placeholder={t('workflow.nodes.ifElse.enterValue') || ''}
|
placeholder={t('workflow.nodes.ifElse.enterValue') || ''}
|
||||||
|
onFocus={setFocus}
|
||||||
|
onBlur={setBlur}
|
||||||
/>
|
/>
|
||||||
|
{!isFocus && unit && <div className='absolute right-2 top-[50%] translate-y-[-50%] text-text-tertiary system-sm-regular'>{unit}</div>}
|
||||||
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user