fix loadInitData refresh (#4169)
* fix * fix * form input number default & api dataset max token
This commit is contained in:
@@ -34,13 +34,13 @@ export function useLinkedScroll<
|
|||||||
bottom: null as { _id: string; index: number } | null
|
bottom: null as { _id: string; index: number } | null
|
||||||
});
|
});
|
||||||
const containerRef = useRef<HTMLDivElement>(null);
|
const containerRef = useRef<HTMLDivElement>(null);
|
||||||
const itemRefs = useRef<(HTMLElement | null)[]>([]);
|
const itemRefs = useRef<Map<string, HTMLElement | null>>(new Map());
|
||||||
|
|
||||||
const scrollToItem = async (id: string, retry = 3) => {
|
const scrollToItem = async (id: string, retry = 3) => {
|
||||||
const itemIndex = dataList.findIndex((item) => item._id === id);
|
const itemIndex = dataList.findIndex((item) => item._id === id);
|
||||||
if (itemIndex === -1) return;
|
if (itemIndex === -1) return;
|
||||||
|
|
||||||
const element = itemRefs.current[itemIndex];
|
const element = itemRefs.current.get(id);
|
||||||
|
|
||||||
if (!element || !containerRef.current) {
|
if (!element || !containerRef.current) {
|
||||||
if (retry > 0) {
|
if (retry > 0) {
|
||||||
@@ -64,7 +64,8 @@ export function useLinkedScroll<
|
|||||||
|
|
||||||
let scroolSign = useRef(false);
|
let scroolSign = useRef(false);
|
||||||
const { runAsync: loadInitData } = useRequest2(
|
const { runAsync: loadInitData } = useRequest2(
|
||||||
async (scrollWhenFinish = true, refresh = false) => {
|
async ({ scrollWhenFinish, refresh } = { scrollWhenFinish: true, refresh: false }) => {
|
||||||
|
console.log('loadInitData', params);
|
||||||
if (!currentData || isLoading) return;
|
if (!currentData || isLoading) return;
|
||||||
|
|
||||||
const item = dataList.find((item) => item._id === currentData.id);
|
const item = dataList.find((item) => item._id === currentData.id);
|
||||||
|
|||||||
@@ -299,6 +299,7 @@ const RenderUserFormInteractive = React.memo(function RenderFormInput({
|
|||||||
<MyNumberInput
|
<MyNumberInput
|
||||||
min={input.min}
|
min={input.min}
|
||||||
max={input.max}
|
max={input.max}
|
||||||
|
defaultValue={input.defaultValue}
|
||||||
isDisabled={interactive.params.submitted}
|
isDisabled={interactive.params.submitted}
|
||||||
bg={'white'}
|
bg={'white'}
|
||||||
register={register}
|
register={register}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import { useCopyData } from '@fastgpt/web/hooks/useCopyData';
|
|||||||
import InputDataModal from '@/pageComponents/dataset/detail/InputDataModal';
|
import InputDataModal from '@/pageComponents/dataset/detail/InputDataModal';
|
||||||
|
|
||||||
const CollectionQuoteItem = ({
|
const CollectionQuoteItem = ({
|
||||||
index,
|
|
||||||
quoteRefs,
|
quoteRefs,
|
||||||
quoteIndex,
|
quoteIndex,
|
||||||
setQuoteIndex,
|
setQuoteIndex,
|
||||||
@@ -22,8 +21,7 @@ const CollectionQuoteItem = ({
|
|||||||
dataId,
|
dataId,
|
||||||
collectionId
|
collectionId
|
||||||
}: {
|
}: {
|
||||||
index: number;
|
quoteRefs: MutableRefObject<Map<string, HTMLDivElement | null>>;
|
||||||
quoteRefs: MutableRefObject<(HTMLDivElement | null)[]>;
|
|
||||||
quoteIndex: number;
|
quoteIndex: number;
|
||||||
setQuoteIndex: Dispatch<SetStateAction<number>>;
|
setQuoteIndex: Dispatch<SetStateAction<number>>;
|
||||||
refreshList: () => void;
|
refreshList: () => void;
|
||||||
@@ -45,7 +43,7 @@ const CollectionQuoteItem = ({
|
|||||||
<>
|
<>
|
||||||
<Box
|
<Box
|
||||||
ref={(el: HTMLDivElement | null) => {
|
ref={(el: HTMLDivElement | null) => {
|
||||||
quoteRefs.current[index] = el;
|
quoteRefs.current.set(dataId, el);
|
||||||
}}
|
}}
|
||||||
p={2}
|
p={2}
|
||||||
py={2}
|
py={2}
|
||||||
@@ -163,9 +161,7 @@ const CollectionQuoteItem = ({
|
|||||||
'0px 1px 2px 0px rgba(19, 51, 107, 0.05), 0px 0px 1px 0px rgba(19, 51, 107, 0.08)'
|
'0px 1px 2px 0px rgba(19, 51, 107, 0.05), 0px 0px 1px 0px rgba(19, 51, 107, 0.08)'
|
||||||
}
|
}
|
||||||
cursor={'pointer'}
|
cursor={'pointer'}
|
||||||
onClick={() => {
|
onClick={() => copyData(`${q}${a ? '\n' + a : ''}`)}
|
||||||
copyData(q + '\n' + a);
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<MyIcon name="copy" w={'14px'} color={'myGray.500'} />
|
<MyIcon name="copy" w={'14px'} color={'myGray.500'} />
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|||||||
@@ -256,11 +256,10 @@ const CollectionReader = ({
|
|||||||
{formatedDataList.map((item, index) => (
|
{formatedDataList.map((item, index) => (
|
||||||
<CollectionQuoteItem
|
<CollectionQuoteItem
|
||||||
key={item._id}
|
key={item._id}
|
||||||
index={index}
|
quoteRefs={itemRefs as React.MutableRefObject<Map<string, HTMLDivElement | null>>}
|
||||||
quoteRefs={itemRefs as React.MutableRefObject<(HTMLDivElement | null)[]>}
|
|
||||||
quoteIndex={item.quoteIndex}
|
quoteIndex={item.quoteIndex}
|
||||||
setQuoteIndex={setQuoteIndex}
|
setQuoteIndex={setQuoteIndex}
|
||||||
refreshList={() => loadInitData(false, true)}
|
refreshList={() => loadInitData({ scrollWhenFinish: false, refresh: true })}
|
||||||
updated={item.updated}
|
updated={item.updated}
|
||||||
isCurrentSelected={item.isCurrentSelected}
|
isCurrentSelected={item.isCurrentSelected}
|
||||||
q={item.q}
|
q={item.q}
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ const ApiDatasetForm = ({
|
|||||||
<Input
|
<Input
|
||||||
bg={'myWhite.600'}
|
bg={'myWhite.600'}
|
||||||
placeholder={t('dataset:request_headers')}
|
placeholder={t('dataset:request_headers')}
|
||||||
maxLength={200}
|
maxLength={2000}
|
||||||
{...register('apiServer.authorization')}
|
{...register('apiServer.authorization')}
|
||||||
/>
|
/>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|||||||
Reference in New Issue
Block a user