fix: parameter input (#8076)

This commit is contained in:
crazywoola 2024-09-08 15:43:55 +08:00 committed by GitHub
parent feefeb44d7
commit 9050f92e5b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -127,12 +127,10 @@ const ParameterItem: FC<ParameterItemProps> = ({
&& !isNullOrUndefined(parameterRule.min)
&& !isNullOrUndefined(parameterRule.max)
if (parameterRule.type === 'int' || parameterRule.type === 'float') {
if (parameterRule.type === 'int') {
let step = 100
if (parameterRule.max) {
if (parameterRule.max < 10)
step = 0.1
else if (parameterRule.max < 100)
if (parameterRule.max < 100)
step = 1
else if (parameterRule.max < 1000)
step = 10
@ -164,6 +162,31 @@ const ParameterItem: FC<ParameterItemProps> = ({
)
}
if (parameterRule.type === 'float') {
return (
<>
{numberInputWithSlide && <Slider
className='w-[120px]'
value={renderValue as number}
min={parameterRule.min}
max={parameterRule.max}
step={0.1}
onChange={handleSlideChange}
/>}
<input
ref={numberInputRef}
className='shrink-0 block ml-4 pl-3 w-16 h-8 appearance-none outline-none rounded-lg bg-gray-100 text-[13px] text-gra-900'
type='number'
max={parameterRule.max}
min={parameterRule.min}
step={numberInputWithSlide ? 0.1 : +`0.${parameterRule.precision || 0}`}
onChange={handleNumberInputChange}
onBlur={handleNumberInputBlur}
/>
</>
)
}
if (parameterRule.type === 'boolean') {
return (
<Radio.Group