diff --git a/web/src/components/chunk-method-modal/hooks.ts b/web/src/components/chunk-method-modal/hooks.ts index 193d3f9c4..8f605ba55 100644 --- a/web/src/components/chunk-method-modal/hooks.ts +++ b/web/src/components/chunk-method-modal/hooks.ts @@ -46,6 +46,7 @@ const getParserList = ( }; export const useFetchParserListOnMount = ( + documentId: string, parserId: string, documentExtension: string, ) => { @@ -71,7 +72,7 @@ export const useFetchParserListOnMount = ( useEffect(() => { setSelectedTag(parserId); - }, [parserId]); + }, [parserId, documentId]); const handleChange = (tag: string, checked: boolean) => { const nextSelectedTag = checked ? tag : selectedTag; diff --git a/web/src/components/chunk-method-modal/index.tsx b/web/src/components/chunk-method-modal/index.tsx index 6a0155ee3..a74e24e22 100644 --- a/web/src/components/chunk-method-modal/index.tsx +++ b/web/src/components/chunk-method-modal/index.tsx @@ -36,11 +36,13 @@ interface IProps extends Omit { parserId: string; parserConfig: IKnowledgeFileParserConfig; documentExtension: string; + documentId: string; } const hidePagesChunkMethods = ['qa', 'table', 'picture', 'resume', 'one']; const ChunkMethodModal: React.FC = ({ + documentId, parserId, onOk, hideModal, @@ -49,6 +51,7 @@ const ChunkMethodModal: React.FC = ({ parserConfig, }) => { const { parserList, handleChange, selectedTag } = useFetchParserListOnMount( + documentId, parserId, documentExtension, ); diff --git a/web/src/pages/add-knowledge/components/knowledge-dataset/knowledge-upload-file/index.tsx b/web/src/pages/add-knowledge/components/knowledge-dataset/knowledge-upload-file/index.tsx index 0a8bb87e0..8cb643304 100644 --- a/web/src/pages/add-knowledge/components/knowledge-dataset/knowledge-upload-file/index.tsx +++ b/web/src/pages/add-knowledge/components/knowledge-dataset/knowledge-upload-file/index.tsx @@ -296,6 +296,7 @@ const KnowledgeUploadFile = () => { void) => { return { handleInputChange }; }; -export const useSetSelectedRecord = () => { - const [currentRecord, setCurrentRecord] = useState( - {} as IKnowledgeFile, - ); - - const setRecord = (record: IKnowledgeFile) => () => { - setCurrentRecord(record); - }; - - return { currentRecord, setRecord }; -}; - export const useRenameDocument = (documentId: string) => { const saveName = useSaveDocumentName(); diff --git a/web/src/pages/add-knowledge/components/knowledge-file/index.tsx b/web/src/pages/add-knowledge/components/knowledge-file/index.tsx index 6fa7f208d..68666a0fa 100644 --- a/web/src/pages/add-knowledge/components/knowledge-file/index.tsx +++ b/web/src/pages/add-knowledge/components/knowledge-file/index.tsx @@ -36,12 +36,12 @@ import { useHandleSearchChange, useNavigateToOtherPage, useRenameDocument, - useSetSelectedRecord, } from './hooks'; import ParsingActionCell from './parsing-action-cell'; import ParsingStatusCell from './parsing-status-cell'; import RenameModal from './rename-modal'; +import { useSetSelectedRecord } from '@/hooks/logicHooks'; import styles from './index.less'; const KnowledgeFile = () => { @@ -178,11 +178,8 @@ const KnowledgeFile = () => { key: 'action', render: (_, record) => ( { - setRecord(record)(); - showRenameModal(); - }} + setCurrentRecord={setRecord} + showRenameModal={showRenameModal} showChangeParserModal={showChangeParserModal} record={record} > @@ -237,6 +234,7 @@ const KnowledgeFile = () => { onOk={onCreateOk} /> = { location.pathname === '/knowledge/dataset/upload' ) { dispatch({ - type: 'kFModel/setPagination', + type: 'setPagination', payload: { current: 1, pageSize: 10 }, }); } diff --git a/web/src/pages/add-knowledge/components/knowledge-file/parsing-action-cell/index.tsx b/web/src/pages/add-knowledge/components/knowledge-file/parsing-action-cell/index.tsx index 4bb04d6b9..55fd93d3f 100644 --- a/web/src/pages/add-knowledge/components/knowledge-file/parsing-action-cell/index.tsx +++ b/web/src/pages/add-knowledge/components/knowledge-file/parsing-action-cell/index.tsx @@ -16,14 +16,14 @@ import styles from './index.less'; interface IProps { record: IKnowledgeFile; - setDocumentAndParserId: () => void; + setCurrentRecord: (record: IKnowledgeFile) => void; showRenameModal: () => void; showChangeParserModal: () => void; } const ParsingActionCell = ({ record, - setDocumentAndParserId, + setCurrentRecord, showRenameModal, showChangeParserModal, }: IProps) => { @@ -45,12 +45,25 @@ const ParsingActionCell = ({ }); }; + const setRecord = () => { + setCurrentRecord(record); + }; + + const onShowRenameModal = () => { + setRecord(); + showRenameModal(); + }; + const onShowChangeParserModal = () => { + setRecord(); + showChangeParserModal(); + }; + const chunkItems: MenuProps['items'] = [ { key: '1', label: (
-
@@ -65,11 +78,7 @@ const ParsingActionCell = ({ trigger={['click']} disabled={isRunning} > - @@ -77,7 +86,7 @@ const ParsingActionCell = ({