mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-22 20:37:48 +00:00
export csv format & log title debounce (#3754)
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import React, { useMemo, useState } from 'react';
|
import React, { useEffect, useMemo, useState } from 'react';
|
||||||
import {
|
import {
|
||||||
Flex,
|
Flex,
|
||||||
Box,
|
Box,
|
||||||
@@ -35,6 +35,7 @@ import SearchInput from '@fastgpt/web/components/common/Input/SearchInput';
|
|||||||
import PopoverConfirm from '@fastgpt/web/components/common/MyPopover/PopoverConfirm';
|
import PopoverConfirm from '@fastgpt/web/components/common/MyPopover/PopoverConfirm';
|
||||||
import { useRequest2 } from '@fastgpt/web/hooks/useRequest';
|
import { useRequest2 } from '@fastgpt/web/hooks/useRequest';
|
||||||
import { downloadFetch } from '@/web/common/system/utils';
|
import { downloadFetch } from '@/web/common/system/utils';
|
||||||
|
import { debounce } from 'lodash';
|
||||||
|
|
||||||
const DetailLogsModal = dynamic(() => import('./DetailLogsModal'));
|
const DetailLogsModal = dynamic(() => import('./DetailLogsModal'));
|
||||||
|
|
||||||
@@ -50,6 +51,15 @@ const Logs = () => {
|
|||||||
|
|
||||||
const [detailLogsId, setDetailLogsId] = useState<string>();
|
const [detailLogsId, setDetailLogsId] = useState<string>();
|
||||||
const [logTitle, setLogTitle] = useState<string>();
|
const [logTitle, setLogTitle] = useState<string>();
|
||||||
|
const [inputValue, setInputValue] = useState('');
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const timer = setTimeout(() => {
|
||||||
|
setLogTitle(inputValue);
|
||||||
|
}, 500);
|
||||||
|
|
||||||
|
return () => clearTimeout(timer);
|
||||||
|
}, [inputValue]);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
value: chatSources,
|
value: chatSources,
|
||||||
@@ -162,8 +172,8 @@ const Logs = () => {
|
|||||||
<SearchInput
|
<SearchInput
|
||||||
placeholder={t('app:logs_title')}
|
placeholder={t('app:logs_title')}
|
||||||
w={'240px'}
|
w={'240px'}
|
||||||
value={logTitle}
|
value={inputValue}
|
||||||
onChange={(e) => setLogTitle(e.target.value)}
|
onChange={(e) => setInputValue(e.target.value)}
|
||||||
/>
|
/>
|
||||||
</Flex>
|
</Flex>
|
||||||
<Box flex={'1'} />
|
<Box flex={'1'} />
|
||||||
|
@@ -121,7 +121,7 @@ const SimpleEdit = () => {
|
|||||||
{currentTab === TabEnum.appEdit ? (
|
{currentTab === TabEnum.appEdit ? (
|
||||||
<Edit appForm={appForm} setAppForm={setAppForm} setPast={setPast} />
|
<Edit appForm={appForm} setAppForm={setAppForm} setPast={setPast} />
|
||||||
) : (
|
) : (
|
||||||
<Box flex={'1 0 0'} h={0} mt={[4, 0]}>
|
<Box flex={'1 0 0'} h={0} mt={[4, 0]} mb={[2, 4]}>
|
||||||
{currentTab === TabEnum.publish && <PublishChannel />}
|
{currentTab === TabEnum.publish && <PublishChannel />}
|
||||||
{currentTab === TabEnum.logs && <Logs />}
|
{currentTab === TabEnum.logs && <Logs />}
|
||||||
</Box>
|
</Box>
|
||||||
|
@@ -229,7 +229,7 @@ async function handler(req: ApiRequestProps<ExportChatLogsBody, {}>, res: NextAp
|
|||||||
);
|
);
|
||||||
let chatDetailsStr = '';
|
let chatDetailsStr = '';
|
||||||
try {
|
try {
|
||||||
chatDetailsStr = JSON.stringify(chatDetails);
|
chatDetailsStr = JSON.stringify(chatDetails).replace(/"/g, '""').replace(/\n/g, '\\n');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
addLog.error(`export chat logs error`, e);
|
addLog.error(`export chat logs error`, e);
|
||||||
}
|
}
|
||||||
@@ -252,6 +252,6 @@ async function handler(req: ApiRequestProps<ExportChatLogsBody, {}>, res: NextAp
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default NextAPI(
|
export default NextAPI(
|
||||||
useIPFrequencyLimit({ id: 'export-chat-logs', seconds: 2, limit: 1, force: true }),
|
useIPFrequencyLimit({ id: 'export-chat-logs', seconds: 60, limit: 1, force: true }),
|
||||||
handler
|
handler
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user