From 34d3998566fe2b3a02e003025886423a1206c20e Mon Sep 17 00:00:00 2001 From: Joel Date: Sat, 11 May 2024 14:42:04 +0800 Subject: [PATCH] fix: webapps not show number type input field (#4292) --- .../base/chat/chat-with-history/config-panel/form.tsx | 11 +++++++++++ .../components/base/chat/chat-with-history/hooks.tsx | 11 +++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/web/app/components/base/chat/chat-with-history/config-panel/form.tsx b/web/app/components/base/chat/chat-with-history/config-panel/form.tsx index d34b1cc30f..39b2426a5f 100644 --- a/web/app/components/base/chat/chat-with-history/config-panel/form.tsx +++ b/web/app/components/base/chat/chat-with-history/config-panel/form.tsx @@ -37,6 +37,17 @@ const Form = () => { /> ) } + if (form.type === 'number') { + return ( + handleFormChange(variable, e.target.value)} + placeholder={`${label}${!required ? `(${t('appDebug.variableTable.optional')})` : ''}`} + /> + ) + } return ( { setNewConversationInputs(newInputs) }, []) const inputsForms = useMemo(() => { - return (appParams?.user_input_form || []).filter((item: any) => item.paragraph || item.select || item['text-input']).map((item: any) => { + return (appParams?.user_input_form || []).filter((item: any) => item.paragraph || item.select || item['text-input'] || item.number).map((item: any) => { if (item.paragraph) { return { ...item.paragraph, type: 'paragraph', } } + if (item.number) { + return { + ...item.number, + type: 'number', + } + } if (item.select) { return { ...item.select, type: 'select', } } + return { ...item['text-input'], type: 'text-input', @@ -226,7 +233,7 @@ export const useChatWithHistory = (installedAppInfo?: InstalledApp) => { setShowNewConversationItemInList(true) } }, [setShowConfigPanelBeforeChat, setShowNewConversationItemInList, checkInputsRequired]) - const currentChatInstanceRef = useRef<{ handleStop: () => void }>({ handleStop: () => {} }) + const currentChatInstanceRef = useRef<{ handleStop: () => void }>({ handleStop: () => { } }) const handleChangeConversation = useCallback((conversationId: string) => { currentChatInstanceRef.current.handleStop() setNewConversationId('')