From da39723f1765efa9c4820ac3342fa17a19579984 Mon Sep 17 00:00:00 2001 From: balibabu Date: Fri, 22 Mar 2024 19:21:20 +0800 Subject: [PATCH] feat: when Layout recognize is false, hide pages (#144) * feat: when Layout recognize is false, hide pages * feat: fix the name column to the leftmost part of the KnowledgeFile table --- .../knowledge-file/chunk-method-modal.tsx | 268 ++++++++++-------- .../components/knowledge-file/index.tsx | 1 + 2 files changed, 144 insertions(+), 125 deletions(-) diff --git a/web/src/pages/add-knowledge/components/knowledge-file/chunk-method-modal.tsx b/web/src/pages/add-knowledge/components/knowledge-file/chunk-method-modal.tsx index 12654335feb..70ea70fe1e7 100644 --- a/web/src/pages/add-knowledge/components/knowledge-file/chunk-method-modal.tsx +++ b/web/src/pages/add-knowledge/components/knowledge-file/chunk-method-modal.tsx @@ -1,4 +1,8 @@ +import MaxTokenNumber from '@/components/max-token-number'; import { IModalManagerChildrenProps } from '@/components/modal-manager'; +import { IKnowledgeFileParserConfig } from '@/interfaces/database/knowledge'; +import { IChangeParserConfigRequestBody } from '@/interfaces/request/document'; +import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons'; import { Button, Divider, @@ -9,14 +13,8 @@ import { Switch, Tag, } from 'antd'; -import React, { useEffect, useMemo } from 'react'; - -import MaxTokenNumber from '@/components/max-token-number'; -import { IKnowledgeFileParserConfig } from '@/interfaces/database/knowledge'; -import { IChangeParserConfigRequestBody } from '@/interfaces/request/document'; -import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons'; import omit from 'lodash/omit'; -import {} from 'module'; +import React, { useEffect, useMemo } from 'react'; import { useFetchParserListOnMount } from './hooks'; import styles from './index.less'; @@ -51,12 +49,10 @@ const ChunkMethodModal: React.FC = ({ const handleOk = async () => { const values = await form.validateFields(); - console.info(values); const parser_config = { ...values.parser_config, pages: values.pages?.map((x: any) => [x.from, x.to]) ?? [], }; - console.info(parser_config); onOk(selectedTag, parser_config); }; @@ -110,134 +106,156 @@ const ChunkMethodModal: React.FC = ({ + {
- {showPages && ( - <> - - {(fields, { add, remove }) => ( - <> - {fields.map(({ key, name, ...restField }) => ( - - 0 ? [name - 1, 'to'] : []} - rules={[ - { - required: true, - message: 'Missing start page number', - }, - ({ getFieldValue }) => ({ - validator(_, value) { - if ( - name === 0 || - !value || - getFieldValue(['pages', name - 1, 'to']) < - value - ) { - return Promise.resolve(); - } - return Promise.reject( - new Error( - 'The current value must be greater than the previous to!', - ), - ); - }, - }), - ]} - > - - - ({ - validator(_, value) { - if ( - !value || - getFieldValue(['pages', name, 'from']) < value - ) { - return Promise.resolve(); - } - return Promise.reject( - new Error( - 'The current value must be greater than to!', - ), - ); - }, - }), - ]} - > - - - {name > 0 && ( - remove(name)} /> - )} - - ))} - - - - - )} - - - - - - )} {showOne && ( )} + {showPages && ( + + {({ getFieldValue }) => + getFieldValue(['parser_config', 'layout_recognize']) && ( + <> + + {(fields, { add, remove }) => ( + <> + {fields.map(({ key, name, ...restField }) => ( + + 0 ? [name - 1, 'to'] : []} + rules={[ + { + required: true, + message: 'Missing start page number', + }, + ({ getFieldValue }) => ({ + validator(_, value) { + if ( + name === 0 || + !value || + getFieldValue([ + 'pages', + name - 1, + 'to', + ]) < value + ) { + return Promise.resolve(); + } + return Promise.reject( + new Error( + 'The current value must be greater than the previous to!', + ), + ); + }, + }), + ]} + > + + + ({ + validator(_, value) { + if ( + !value || + getFieldValue(['pages', name, 'from']) < + value + ) { + return Promise.resolve(); + } + return Promise.reject( + new Error( + 'The current value must be greater than to!', + ), + ); + }, + }), + ]} + > + + + {name > 0 && ( + remove(name)} + /> + )} + + ))} + + + + + )} + + + + + + + ) + } + + )} + {selectedTag === 'naive' && }
} 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 1859baee412..18f8475a79a 100644 --- a/web/src/pages/add-knowledge/components/knowledge-file/index.tsx +++ b/web/src/pages/add-knowledge/components/knowledge-file/index.tsx @@ -112,6 +112,7 @@ const KnowledgeFile = () => { title: 'Name', dataIndex: 'name', key: 'name', + fixed: 'left', render: (text: any, { id, thumbnail }) => (
toChunk(id)}>