From 52dce4329d500bc162cede811733163406821e58 Mon Sep 17 00:00:00 2001 From: chanx <1243304602@qq.com> Date: Fri, 11 Jul 2025 11:34:36 +0800 Subject: [PATCH] fix: fix dataset-page's bugs (#8786) ### What problem does this PR solve? fix dataset-page's bugs,Input component supports icon, added Radio component, and removed antd from chunk-result-bar page [#3221 ](https://github.com/infiniflow/ragflow/issues/3221) ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- .../components/entity-types-form-field.tsx | 45 +++--- web/src/components/entity-types-item.tsx | 2 +- .../use-handle-filter-submit.ts | 13 +- .../max-token-number-from-field.tsx | 3 +- web/src/components/originui/input.tsx | 55 ++++++-- .../raptor-form-fields.tsx | 56 ++++---- web/src/components/ui/input.tsx | 7 +- web/src/components/ui/popover.tsx | 22 ++- web/src/components/ui/radio.tsx | 133 ++++++++++++++++++ web/src/components/ui/segmented.tsx | 15 +- web/src/hooks/chunk-hooks.ts | 4 +- web/src/hooks/document-hooks.ts | 5 +- web/src/hooks/knowledge-hooks.ts | 5 +- web/src/hooks/logic-hooks.ts | 34 +++-- web/src/hooks/logic-hooks/navigate-hooks.ts | 2 + web/src/hooks/use-document-request.ts | 5 +- .../components/chunk-result-bar/index.tsx | 111 +++++++++------ .../components/knowledge-chunk/index.tsx | 11 +- .../dataset/use-bulk-operate-dataset.tsx | 4 +- .../setting/chunk-method-learn-more.tsx | 2 +- .../dataset/setting/configuration/naive.tsx | 2 +- .../pages/dataset/setting/general-form.tsx | 3 +- web/src/pages/dataset/setting/index.tsx | 13 -- 23 files changed, 399 insertions(+), 153 deletions(-) create mode 100644 web/src/components/ui/radio.tsx diff --git a/web/src/components/entity-types-form-field.tsx b/web/src/components/entity-types-form-field.tsx index 3a5de8ce5..ddf08cb0b 100644 --- a/web/src/components/entity-types-form-field.tsx +++ b/web/src/components/entity-types-form-field.tsx @@ -12,7 +12,13 @@ import { type EntityTypesFormFieldProps = { name?: string; }; - +const initialEntityTypes = [ + 'organization', + 'person', + 'geo', + 'event', + 'category', +]; export function EntityTypesFormField({ name = 'parser_config.entity_types', }: EntityTypesFormFieldProps) { @@ -23,24 +29,27 @@ export function EntityTypesFormField({ ( - -
- - * {t('entityTypes')} - -
- - - + defaultValue={initialEntityTypes} + render={({ field }) => { + return ( + +
+ + * {t('entityTypes')} + +
+ + + +
-
-
-
- -
- - )} +
+
+ +
+ + ); + }} /> ); } diff --git a/web/src/components/entity-types-item.tsx b/web/src/components/entity-types-item.tsx index d52fb0e13..ba26e5f4c 100644 --- a/web/src/components/entity-types-item.tsx +++ b/web/src/components/entity-types-item.tsx @@ -25,7 +25,7 @@ const EntityTypesItem = ({ rules={[{ required: true }]} initialValue={initialEntityTypes} > - + ); }; diff --git a/web/src/components/list-filter-bar/use-handle-filter-submit.ts b/web/src/components/list-filter-bar/use-handle-filter-submit.ts index 55cc4c6fe..189a8d6b8 100644 --- a/web/src/components/list-filter-bar/use-handle-filter-submit.ts +++ b/web/src/components/list-filter-bar/use-handle-filter-submit.ts @@ -1,12 +1,17 @@ +import { useGetPaginationWithRouter } from '@/hooks/logic-hooks'; import { useCallback, useState } from 'react'; import { FilterChange, FilterValue } from './interface'; export function useHandleFilterSubmit() { const [filterValue, setFilterValue] = useState({}); - - const handleFilterSubmit: FilterChange = useCallback((value) => { - setFilterValue(value); - }, []); + const { setPagination } = useGetPaginationWithRouter(); + const handleFilterSubmit: FilterChange = useCallback( + (value) => { + setFilterValue(value); + setPagination({ page: 1 }); + }, + [setPagination], + ); return { filterValue, setFilterValue, handleFilterSubmit }; } diff --git a/web/src/components/max-token-number-from-field.tsx b/web/src/components/max-token-number-from-field.tsx index a9646f90f..f1762c1a8 100644 --- a/web/src/components/max-token-number-from-field.tsx +++ b/web/src/components/max-token-number-from-field.tsx @@ -7,7 +7,7 @@ interface IProps { max?: number; } -export function MaxTokenNumberFormField({ max = 2048 }: IProps) { +export function MaxTokenNumberFormField({ max = 2048, initialValue }: IProps) { const { t } = useTranslate('knowledgeConfiguration'); return ( @@ -15,6 +15,7 @@ export function MaxTokenNumberFormField({ max = 2048 }: IProps) { name={'parser_config.chunk_token_num'} label={t('chunkTokenNumber')} max={max} + defaultValue={initialValue ?? 0} layout={FormLayout.Horizontal} > ); diff --git a/web/src/components/originui/input.tsx b/web/src/components/originui/input.tsx index d8c125f91..18cf78f97 100644 --- a/web/src/components/originui/input.tsx +++ b/web/src/components/originui/input.tsx @@ -1,24 +1,49 @@ import * as React from 'react'; import { cn } from '@/lib/utils'; +type InputProps = React.ComponentProps<'input'> & { + icon?: React.ReactNode; + iconPosition?: 'left' | 'right'; +}; -function Input({ className, type, ...props }: React.ComponentProps<'input'>) { +function Input({ + className, + type, + icon, + iconPosition = 'left', + ...props +}: InputProps) { return ( - + {icon && ( +
+ {icon} +
)} - {...props} - /> + +
); } diff --git a/web/src/components/parse-configuration/raptor-form-fields.tsx b/web/src/components/parse-configuration/raptor-form-fields.tsx index b38db7c87..8ee184e46 100644 --- a/web/src/components/parse-configuration/raptor-form-fields.tsx +++ b/web/src/components/parse-configuration/raptor-form-fields.tsx @@ -64,10 +64,10 @@ const RaptorFormFields = () => { control={form.control} name={UseRaptorField} render={({ field }) => { - if (typeof field.value === 'undefined') { - // default value set - form.setValue('parser_config.raptor.use_raptor', false); - } + // if (typeof field.value === 'undefined') { + // // default value set + // form.setValue('parser_config.raptor.use_raptor', false); + // } return ( { ( - -
- - {t('prompt')} - -
- -