export csv format & log title debounce (#3754)

This commit is contained in:
heheer
2025-02-11 17:36:00 +08:00
committed by GitHub
parent 8ac6494e60
commit f5d045eece
3 changed files with 16 additions and 6 deletions

View File

@@ -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'} />

View File

@@ -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>

View File

@@ -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
); );