chore: preview input field readonly

This commit is contained in:
Joel 2025-10-16 10:42:47 +08:00
parent 0c7b9a462f
commit 18f2d24f8e
2 changed files with 9 additions and 1 deletions

View File

@ -18,7 +18,7 @@ const ChatUserInput = ({
inputs,
}: Props) => {
const { t } = useTranslation()
const { modelConfig, setInputs } = useContext(ConfigContext)
const { modelConfig, setInputs, readonly } = useContext(ConfigContext)
const promptVariables = modelConfig.configs.prompt_variables.filter(({ key, name }) => {
return key && key?.trim() && name && name?.trim()
@ -70,6 +70,7 @@ const ChatUserInput = ({
placeholder={name}
autoFocus={index === 0}
maxLength={max_length || DEFAULT_VALUE_MAX_LEN}
readOnly={readonly}
/>
)}
{type === 'paragraph' && (
@ -78,6 +79,7 @@ const ChatUserInput = ({
placeholder={name}
value={inputs[key] ? `${inputs[key]}` : ''}
onChange={(e) => { handleInputValueChange(key, e.target.value) }}
readOnly={readonly}
/>
)}
{type === 'select' && (
@ -87,6 +89,7 @@ const ChatUserInput = ({
onSelect={(i) => { handleInputValueChange(key, i.value as string) }}
items={(options || []).map(i => ({ name: i, value: i }))}
allowSearch={false}
disabled={readonly}
/>
)}
{type === 'number' && (
@ -97,6 +100,7 @@ const ChatUserInput = ({
placeholder={name}
autoFocus={index === 0}
maxLength={max_length || DEFAULT_VALUE_MAX_LEN}
readOnly={readonly}
/>
)}
{type === 'checkbox' && (
@ -105,6 +109,7 @@ const ChatUserInput = ({
value={!!inputs[key]}
required={required}
onChange={(value) => { handleInputValueChange(key, value) }}
readonly={readonly}
/>
)}
</div>

View File

@ -9,6 +9,7 @@ type Props = {
value: boolean
required?: boolean
onChange: (value: boolean) => void
readonly?: boolean
}
const BoolInput: FC<Props> = ({
@ -16,6 +17,7 @@ const BoolInput: FC<Props> = ({
onChange,
name,
required,
readonly,
}) => {
const { t } = useTranslation()
const handleChange = useCallback(() => {
@ -27,6 +29,7 @@ const BoolInput: FC<Props> = ({
className='!h-4 !w-4'
checked={!!value}
onCheck={handleChange}
disabled={readonly}
/>
<div className='system-sm-medium flex items-center gap-1 text-text-secondary'>
{name}