This commit is contained in:
JzoNg
2025-06-09 21:35:29 +08:00
parent a27aed544e
commit e9d196261b
3 changed files with 47 additions and 2 deletions

View File

@ -105,12 +105,15 @@ export const getConfiguredValue = (value: Record<string, any>, formSchemas: { va
type: 'constant',
value: formSchema.default,
}
if (formSchema.type === 'text-input' || formSchema.type === 'secret-input')
newValues[formSchema.variable].type = 'mixed'
if (formSchema.type === 'boolean') {
if (typeof value === 'string')
newValues[formSchema.variable].value = value === 'true' ? 1 : 0
newValues[formSchema.variable].value = value === 'true'
if (typeof value === 'boolean')
newValues[formSchema.variable].value = value ? 1 : 0
newValues[formSchema.variable].value = value
}
if (formSchema.type === 'number-input') {

View File

@ -0,0 +1,35 @@
'use client'
import type { FC } from 'react'
import cn from '@/utils/classnames'
type Props = {
value: boolean
onChange: (value: boolean) => void
}
const FormInputBoolean: FC<Props> = ({
value,
onChange,
}) => {
return (
<div className='flex w-full space-x-1'>
<div
className={cn(
'system-sm-regular flex h-8 grow cursor-default items-center justify-center rounded-md border border-components-option-card-option-border bg-components-option-card-option-bg px-2 text-text-secondary',
!value && 'cursor-pointer hover:border-components-option-card-option-border-hover hover:bg-components-option-card-option-bg-hover hover:shadow-xs',
value && 'system-sm-medium border-[1.5px] border-components-option-card-option-selected-border bg-components-option-card-option-selected-bg shadow-xs',
)}
onClick={() => onChange(true)}
>True</div>
<div
className={cn(
'system-sm-regular flex h-8 grow cursor-default items-center justify-center rounded-md border border-components-option-card-option-border bg-components-option-card-option-bg px-2 text-text-secondary',
value && 'cursor-pointer hover:border-components-option-card-option-border-hover hover:bg-components-option-card-option-bg-hover hover:shadow-xs',
!value && 'system-sm-medium border-[1.5px] border-components-option-card-option-selected-border bg-components-option-card-option-selected-bg shadow-xs',
)}
onClick={() => onChange(false)}
>False</div>
</div>
)
}
export default FormInputBoolean

View File

@ -11,6 +11,7 @@ import type { ValueSelector } from '@/app/components/workflow/types'
import FormInputTypeSwitch from './form-input-type-switch'
import Input from '@/app/components/base/input'
import { SimpleSelect } from '@/app/components/base/select'
import FormInputBoolean from './form-input-boolean'
import AppSelector from '@/app/components/plugins/plugin-detail-panel/app-selector'
import ModelParameterModal from '@/app/components/plugins/plugin-detail-panel/model-selector'
import VarReferencePicker from '@/app/components/workflow/nodes/_base/components/variable/var-reference-picker'
@ -157,6 +158,12 @@ const FormInputItem: FC<Props> = ({
placeholder={placeholder?.[language] || placeholder?.en_US}
/>
)}
{isBoolean && (
<FormInputBoolean
value={varInput.value as boolean}
onChange={handleValueChange}
/>
)}
{isSelect && (
<SimpleSelect
wrapperClassName='h-8 grow'