chore: improve bool input of start node (#26647)

This commit is contained in:
非法操作
2025-10-08 19:09:03 +08:00
committed by GitHub
parent dbd23f91e5
commit 9cca605bac
6 changed files with 59 additions and 7 deletions

View File

@ -126,8 +126,8 @@ const Result: FC<IResultProps> = ({
let hasEmptyInput = ''
const requiredVars = prompt_variables?.filter(({ key, name, required, type }) => {
if(type === 'boolean')
return false // boolean input is not required
if(type === 'boolean' || type === 'checkbox')
return false // boolean/checkbox input is not required
const res = (!key || !key.trim()) || (!name || !name.trim()) || (required || required === undefined || required === null)
return res
}) || [] // compatible with old version

View File

@ -51,6 +51,8 @@ const RunOnce: FC<IRunOnceProps> = ({
promptConfig.prompt_variables.forEach((item) => {
if (item.type === 'string' || item.type === 'paragraph')
newInputs[item.key] = ''
else if (item.type === 'checkbox')
newInputs[item.key] = false
else
newInputs[item.key] = undefined
})
@ -77,6 +79,8 @@ const RunOnce: FC<IRunOnceProps> = ({
newInputs[item.key] = item.default || ''
else if (item.type === 'number')
newInputs[item.key] = item.default
else if (item.type === 'checkbox')
newInputs[item.key] = item.default || false
else if (item.type === 'file')
newInputs[item.key] = item.default
else if (item.type === 'file-list')
@ -96,7 +100,7 @@ const RunOnce: FC<IRunOnceProps> = ({
{(inputs === null || inputs === undefined || Object.keys(inputs).length === 0) || !isInitialized ? null
: promptConfig.prompt_variables.map(item => (
<div className='mt-4 w-full' key={item.key}>
{item.type !== 'boolean' && (
{item.type !== 'checkbox' && (
<label className='system-md-semibold flex h-6 items-center text-text-secondary'>{item.name}</label>
)}
<div className='mt-1'>
@ -134,7 +138,7 @@ const RunOnce: FC<IRunOnceProps> = ({
onChange={(e: ChangeEvent<HTMLInputElement>) => { handleInputsChange({ ...inputsRef.current, [item.key]: e.target.value }) }}
/>
)}
{item.type === 'boolean' && (
{item.type === 'checkbox' && (
<BoolInput
name={item.name || item.key}
value={!!inputs[item.key]}