mirror of
http://112.124.100.131/huang.ze/ebiz-dify-ai.git
synced 2025-12-24 10:13:01 +08:00
feat: webapp support change inputs after conversation started (#16901)
This commit is contained in:
@@ -17,20 +17,25 @@ const InputsFormContent = ({ showTip }: Props) => {
|
||||
appParams,
|
||||
inputsForms,
|
||||
currentConversationId,
|
||||
currentConversationItem,
|
||||
currentConversationInputs,
|
||||
setCurrentConversationInputs,
|
||||
newConversationInputs,
|
||||
newConversationInputsRef,
|
||||
handleNewConversationInputsChange,
|
||||
} = useEmbeddedChatbotContext()
|
||||
const inputsFormValue = currentConversationId ? currentConversationItem?.inputs : newConversationInputs
|
||||
const inputsFormValue = currentConversationId ? currentConversationInputs : newConversationInputs
|
||||
const readonly = !!currentConversationId
|
||||
|
||||
const handleFormChange = useCallback((variable: string, value: any) => {
|
||||
setCurrentConversationInputs({
|
||||
...currentConversationInputs,
|
||||
[variable]: value,
|
||||
})
|
||||
handleNewConversationInputsChange({
|
||||
...newConversationInputsRef.current,
|
||||
[variable]: value,
|
||||
})
|
||||
}, [newConversationInputsRef, handleNewConversationInputsChange])
|
||||
}, [newConversationInputsRef, handleNewConversationInputsChange, currentConversationInputs, setCurrentConversationInputs])
|
||||
|
||||
return (
|
||||
<div className='space-y-4'>
|
||||
@@ -47,8 +52,6 @@ const InputsFormContent = ({ showTip }: Props) => {
|
||||
value={inputsFormValue?.[form.variable] || ''}
|
||||
onChange={e => handleFormChange(form.variable, e.target.value)}
|
||||
placeholder={form.label}
|
||||
readOnly={readonly}
|
||||
disabled={readonly}
|
||||
/>
|
||||
)}
|
||||
{form.type === InputVarType.number && (
|
||||
@@ -57,8 +60,6 @@ const InputsFormContent = ({ showTip }: Props) => {
|
||||
value={inputsFormValue?.[form.variable] || ''}
|
||||
onChange={e => handleFormChange(form.variable, e.target.value)}
|
||||
placeholder={form.label}
|
||||
readOnly={readonly}
|
||||
disabled={readonly}
|
||||
/>
|
||||
)}
|
||||
{form.type === InputVarType.paragraph && (
|
||||
@@ -66,8 +67,6 @@ const InputsFormContent = ({ showTip }: Props) => {
|
||||
value={inputsFormValue?.[form.variable] || ''}
|
||||
onChange={e => handleFormChange(form.variable, e.target.value)}
|
||||
placeholder={form.label}
|
||||
readOnly={readonly}
|
||||
disabled={readonly}
|
||||
/>
|
||||
)}
|
||||
{form.type === InputVarType.select && (
|
||||
@@ -77,7 +76,6 @@ const InputsFormContent = ({ showTip }: Props) => {
|
||||
items={form.options.map((option: string) => ({ value: option, name: option }))}
|
||||
onSelect={item => handleFormChange(form.variable, item.value as string)}
|
||||
placeholder={form.label}
|
||||
readonly={readonly}
|
||||
/>
|
||||
)}
|
||||
{form.type === InputVarType.singleFile && (
|
||||
|
||||
Reference in New Issue
Block a user