mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-30 10:28:42 +00:00
app template
This commit is contained in:
@@ -89,6 +89,7 @@ const ChatBox = (
|
||||
const TextareaDom = useRef<HTMLTextAreaElement>(null);
|
||||
const controller = useRef(new AbortController());
|
||||
|
||||
const [refresh, setRefresh] = useState(false);
|
||||
const [variables, setVariables] = useState<Record<string, any>>({});
|
||||
const [chatHistory, setChatHistory] = useState<ChatSiteItemType[]>([]);
|
||||
|
||||
@@ -111,7 +112,7 @@ const ChatBox = (
|
||||
|
||||
const isLargeWidth = ChatBoxRef?.current?.clientWidth && ChatBoxRef?.current?.clientWidth >= 900;
|
||||
|
||||
const { register, reset, setValue, handleSubmit } = useForm<Record<string, any>>({
|
||||
const { register, reset, getValues, setValue, handleSubmit } = useForm<Record<string, any>>({
|
||||
defaultValues: variables
|
||||
});
|
||||
|
||||
@@ -370,12 +371,10 @@ const ChatBox = (
|
||||
label: item.value,
|
||||
value: item.value
|
||||
}))}
|
||||
{...register(item.key, {
|
||||
required: item.required
|
||||
})}
|
||||
value={getValues(item.key)}
|
||||
onchange={(e) => {
|
||||
setValue(item.key, e);
|
||||
// setRefresh((state) => !state);
|
||||
setRefresh(!refresh);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
@@ -401,7 +400,6 @@ const ChatBox = (
|
||||
</Flex>
|
||||
</Flex>
|
||||
)}
|
||||
{/* empty guide */}
|
||||
|
||||
{/* chat history */}
|
||||
<Box id={'history'} pb={[8, 2]}>
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import React, { useRef } from 'react';
|
||||
import React, { useRef, forwardRef } from 'react';
|
||||
import {
|
||||
Menu,
|
||||
Box,
|
||||
@@ -20,9 +20,12 @@ interface Props extends ButtonProps {
|
||||
onchange?: (val: string) => void;
|
||||
}
|
||||
|
||||
const MySelect = ({ placeholder, value, width = 'auto', list, onchange, ...props }: Props) => {
|
||||
const ref = useRef<HTMLDivElement>(null);
|
||||
const SelectRef = useRef(null);
|
||||
const MySelect = (
|
||||
{ placeholder, value, width = 'auto', list, onchange, ...props }: Props,
|
||||
selectRef: any
|
||||
) => {
|
||||
const ref = useRef<HTMLButtonElement>(null);
|
||||
const SelectRef = useRef<HTMLDivElement>(null);
|
||||
const menuItemStyles = {
|
||||
borderRadius: 'sm',
|
||||
py: 2,
|
||||
@@ -116,4 +119,4 @@ const MySelect = ({ placeholder, value, width = 'auto', list, onchange, ...props
|
||||
);
|
||||
};
|
||||
|
||||
export default React.memo(MySelect);
|
||||
export default React.memo(forwardRef(MySelect));
|
||||
|
Reference in New Issue
Block a user