diff --git a/.gitignore b/.gitignore index 2ad6abc..15ee375 100644 --- a/.gitignore +++ b/.gitignore @@ -24,4 +24,5 @@ dist-ssr *.sw? # rag core -rag_web_core +rag_web_core_v0.20.5 +rag_web_core_deprecated \ No newline at end of file diff --git a/eslint.config.js b/eslint.config.js index e48fff1..78b365a 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -19,6 +19,5 @@ export default defineConfig([ ecmaVersion: 2020, globals: globals.browser, }, - ignores: ['rag_web_core/**'], }, ]) diff --git a/package.json b/package.json index 3ff1f00..988e678 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "@mui/icons-material": "^7.3.4", "@mui/material": "^7.3.4", "@mui/x-data-grid": "^8.14.0", + "@mui/x-date-pickers": "^8.14.0", "ahooks": "^3.9.5", "axios": "^1.12.2", "dayjs": "^1.11.18", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 99ab5ee..293b1cb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -23,6 +23,9 @@ importers: '@mui/x-data-grid': specifier: ^8.14.0 version: 8.14.0(@emotion/react@11.14.0(@types/react@19.2.2)(react@18.3.1))(@emotion/styled@11.14.1(@emotion/react@11.14.0(@types/react@19.2.2)(react@18.3.1))(@types/react@19.2.2)(react@18.3.1))(@mui/material@7.3.4(@emotion/react@11.14.0(@types/react@19.2.2)(react@18.3.1))(@emotion/styled@11.14.1(@emotion/react@11.14.0(@types/react@19.2.2)(react@18.3.1))(@types/react@19.2.2)(react@18.3.1))(@types/react@19.2.2)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(@mui/system@7.3.3(@emotion/react@11.14.0(@types/react@19.2.2)(react@18.3.1))(@emotion/styled@11.14.1(@emotion/react@11.14.0(@types/react@19.2.2)(react@18.3.1))(@types/react@19.2.2)(react@18.3.1))(@types/react@19.2.2)(react@18.3.1))(@types/react@19.2.2)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + '@mui/x-date-pickers': + specifier: ^8.14.0 + version: 8.14.0(@emotion/react@11.14.0(@types/react@19.2.2)(react@18.3.1))(@emotion/styled@11.14.1(@emotion/react@11.14.0(@types/react@19.2.2)(react@18.3.1))(@types/react@19.2.2)(react@18.3.1))(@mui/material@7.3.4(@emotion/react@11.14.0(@types/react@19.2.2)(react@18.3.1))(@emotion/styled@11.14.1(@emotion/react@11.14.0(@types/react@19.2.2)(react@18.3.1))(@types/react@19.2.2)(react@18.3.1))(@types/react@19.2.2)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(@mui/system@7.3.3(@emotion/react@11.14.0(@types/react@19.2.2)(react@18.3.1))(@emotion/styled@11.14.1(@emotion/react@11.14.0(@types/react@19.2.2)(react@18.3.1))(@types/react@19.2.2)(react@18.3.1))(@types/react@19.2.2)(react@18.3.1))(@types/react@19.2.2)(dayjs@1.11.18)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) ahooks: specifier: ^3.9.5 version: 3.9.5(react-dom@18.3.1(react@18.3.1))(react@18.3.1) @@ -588,6 +591,43 @@ packages: '@emotion/styled': optional: true + '@mui/x-date-pickers@8.14.0': + resolution: {integrity: sha512-fz8z1hoi1tbG1QUcZAkQdiO3GsCOpUeRfyANXDDzDN88L4VqwNEyrv0wmzmCfIX2sgur4gWwWJzMuCvauMgXRw==} + engines: {node: '>=14.0.0'} + peerDependencies: + '@emotion/react': ^11.9.0 + '@emotion/styled': ^11.8.1 + '@mui/material': ^5.15.14 || ^6.0.0 || ^7.0.0 + '@mui/system': ^5.15.14 || ^6.0.0 || ^7.0.0 + date-fns: ^2.25.0 || ^3.2.0 || ^4.0.0 + date-fns-jalali: ^2.13.0-0 || ^3.2.0-0 || ^4.0.0-0 + dayjs: ^1.10.7 + luxon: ^3.0.2 + moment: ^2.29.4 + moment-hijri: ^2.1.2 || ^3.0.0 + moment-jalaali: ^0.7.4 || ^0.8.0 || ^0.9.0 || ^0.10.0 + react: ^17.0.0 || ^18.0.0 || ^19.0.0 + react-dom: ^17.0.0 || ^18.0.0 || ^19.0.0 + peerDependenciesMeta: + '@emotion/react': + optional: true + '@emotion/styled': + optional: true + date-fns: + optional: true + date-fns-jalali: + optional: true + dayjs: + optional: true + luxon: + optional: true + moment: + optional: true + moment-hijri: + optional: true + moment-jalaali: + optional: true + '@mui/x-internals@8.14.0': resolution: {integrity: sha512-esYyl61nuuFXiN631TWuPh2tqdoyTdBI/4UXgwH3rytF8jiWvy6prPBPRHEH1nvW3fgw9FoBI48FlOO+yEI8xg==} engines: {node: '>=14.0.0'} @@ -2175,6 +2215,26 @@ snapshots: transitivePeerDependencies: - '@types/react' + '@mui/x-date-pickers@8.14.0(@emotion/react@11.14.0(@types/react@19.2.2)(react@18.3.1))(@emotion/styled@11.14.1(@emotion/react@11.14.0(@types/react@19.2.2)(react@18.3.1))(@types/react@19.2.2)(react@18.3.1))(@mui/material@7.3.4(@emotion/react@11.14.0(@types/react@19.2.2)(react@18.3.1))(@emotion/styled@11.14.1(@emotion/react@11.14.0(@types/react@19.2.2)(react@18.3.1))(@types/react@19.2.2)(react@18.3.1))(@types/react@19.2.2)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(@mui/system@7.3.3(@emotion/react@11.14.0(@types/react@19.2.2)(react@18.3.1))(@emotion/styled@11.14.1(@emotion/react@11.14.0(@types/react@19.2.2)(react@18.3.1))(@types/react@19.2.2)(react@18.3.1))(@types/react@19.2.2)(react@18.3.1))(@types/react@19.2.2)(dayjs@1.11.18)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)': + dependencies: + '@babel/runtime': 7.28.4 + '@mui/material': 7.3.4(@emotion/react@11.14.0(@types/react@19.2.2)(react@18.3.1))(@emotion/styled@11.14.1(@emotion/react@11.14.0(@types/react@19.2.2)(react@18.3.1))(@types/react@19.2.2)(react@18.3.1))(@types/react@19.2.2)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + '@mui/system': 7.3.3(@emotion/react@11.14.0(@types/react@19.2.2)(react@18.3.1))(@emotion/styled@11.14.1(@emotion/react@11.14.0(@types/react@19.2.2)(react@18.3.1))(@types/react@19.2.2)(react@18.3.1))(@types/react@19.2.2)(react@18.3.1) + '@mui/utils': 7.3.3(@types/react@19.2.2)(react@18.3.1) + '@mui/x-internals': 8.14.0(@types/react@19.2.2)(react@18.3.1) + '@types/react-transition-group': 4.4.12(@types/react@19.2.2) + clsx: 2.1.1 + prop-types: 15.8.1 + react: 18.3.1 + react-dom: 18.3.1(react@18.3.1) + react-transition-group: 4.4.5(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + optionalDependencies: + '@emotion/react': 11.14.0(@types/react@19.2.2)(react@18.3.1) + '@emotion/styled': 11.14.1(@emotion/react@11.14.0(@types/react@19.2.2)(react@18.3.1))(@types/react@19.2.2)(react@18.3.1) + dayjs: 1.11.18 + transitivePeerDependencies: + - '@types/react' + '@mui/x-internals@8.14.0(@types/react@19.2.2)(react@18.3.1)': dependencies: '@babel/runtime': 7.28.4 diff --git a/src/components/FormField/CheckboxFormField.tsx b/src/components/FormField/CheckboxFormField.tsx new file mode 100644 index 0000000..9fb0dd7 --- /dev/null +++ b/src/components/FormField/CheckboxFormField.tsx @@ -0,0 +1,74 @@ +import React from 'react'; +import { Checkbox, FormControlLabel, FormControl, FormHelperText, Box, Typography } from '@mui/material'; +import { useFormContext, Controller } from 'react-hook-form'; +import { type IFormLayoutType } from './index'; + +export interface CheckboxFormFieldProps extends IFormLayoutType { + name: string; + label: string; + defaultValue?: boolean; + required?: boolean; + disabled?: boolean; + helperText?: string; + color?: 'primary' | 'secondary' | 'default'; +} + +export function CheckboxFormField({ + name, + label, + defaultValue = false, + required = false, + disabled = false, + layout = 'vertical', + helperText, + color = 'primary', +}: CheckboxFormFieldProps) { + const { control, formState: { errors } } = useFormContext(); + const error = errors[name]; + const isHorizontal = layout === 'horizontal'; + + const checkbox = ( + ( + + field.onChange(e.target.checked)} + color={color} + required={required} + /> + } + label={isHorizontal ? undefined : label} + /> + {(error?.message || helperText) && ( + + {error?.message as string || helperText} + + )} + + )} + /> + ); + + if (isHorizontal) { + return ( + + + {label} + {required && *} + + + {checkbox} + + + ); + } + + return checkbox; +} \ No newline at end of file diff --git a/src/components/FormField/ChipListFormField.tsx b/src/components/FormField/ChipListFormField.tsx new file mode 100644 index 0000000..c6fe612 --- /dev/null +++ b/src/components/FormField/ChipListFormField.tsx @@ -0,0 +1,140 @@ +import React, { useState } from 'react'; +import { + Box, + Typography, + Chip, + IconButton, + TextField, + FormHelperText, +} from '@mui/material'; +import { Add as AddIcon } from '@mui/icons-material'; +import { Controller, useFormContext } from 'react-hook-form'; + +export interface ChipListFormFieldProps { + name: string; + label: string; + helperText?: string; + defaultValue?: string[]; + disabled?: boolean; + required?: boolean; + allowAdd?: boolean; + allowDelete?: boolean; + maxChips?: number; + placeholder?: string; + chipColor?: 'default' | 'primary' | 'secondary' | 'error' | 'info' | 'success' | 'warning'; + chipVariant?: 'filled' | 'outlined'; +} + +export const ChipListFormField: React.FC = ({ + name, + label, + helperText, + defaultValue = [], + disabled = false, + required = false, + allowAdd = true, + allowDelete = true, + maxChips, + placeholder = '输入后按回车添加', + chipColor = 'default', + chipVariant = 'outlined', +}) => { + const { control, setValue, getValues } = useFormContext(); + const [inputValue, setInputValue] = useState(''); + + const handleAddChip = (field: any) => { + if (inputValue.trim() && (!maxChips || field.value.length < maxChips)) { + const newChips = [...field.value, inputValue.trim()]; + field.onChange(newChips); + setInputValue(''); + } + }; + + const handleDeleteChip = (field: any, chipToDelete: string) => { + if (allowDelete) { + const newChips = field.value.filter((chip: string) => chip !== chipToDelete); + field.onChange(newChips); + } + }; + + const handleKeyPress = (event: React.KeyboardEvent, field: any) => { + if (event.key === 'Enter') { + event.preventDefault(); + handleAddChip(field); + } + }; + + return ( + + + {required && *} + {label} + + { + if (maxChips && value.length > maxChips) { + return `${label}最多只能有${maxChips}个标签`; + } + return true; + }, + }} + render={({ field, fieldState: { error } }) => ( + + {/* 标签显示区域 */} + + {field.value.map((chip: string, index: number) => ( + handleDeleteChip(field, chip) : undefined} + variant={chipVariant} + color={chipColor} + disabled={disabled} + /> + ))} + {field.value.length === 0 && ( + + 暂无标签 + + )} + + + {/* 添加标签输入框 */} + {allowAdd && !disabled && (!maxChips || field.value.length < maxChips) && ( + + setInputValue(e.target.value)} + onKeyPress={(e) => handleKeyPress(e, field)} + placeholder={placeholder} + size="small" + fullWidth + disabled={disabled} + /> + handleAddChip(field)} + disabled={!inputValue.trim() || disabled} + size="small" + > + + + + )} + + {/* 错误信息和帮助文本 */} + {(error || helperText) && ( + + {error?.message || helperText} + + )} + + )} + /> + + ); +}; \ No newline at end of file diff --git a/src/components/FormField/DatePickerFormField.tsx b/src/components/FormField/DatePickerFormField.tsx new file mode 100644 index 0000000..d5d251b --- /dev/null +++ b/src/components/FormField/DatePickerFormField.tsx @@ -0,0 +1,64 @@ +import React from 'react'; +import { Box, Typography } from '@mui/material'; +import { DatePicker } from '@mui/x-date-pickers/DatePicker'; +import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider'; +import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs'; +import { useFormContext, Controller } from 'react-hook-form'; +import dayjs, { Dayjs } from 'dayjs'; + +export interface DatePickerFormFieldProps { + name: string; + label: string; + defaultValue?: string | Date | Dayjs | null; + required?: boolean; + disabled?: boolean; + helperText?: string; + minDate?: string | Date | Dayjs; + maxDate?: string | Date | Dayjs; + format?: string; +} + +export function DatePickerFormField({ + name, + label, + defaultValue = null, + required = false, + disabled = false, + helperText, + minDate, + maxDate, + format = 'YYYY-MM-DD', +}: DatePickerFormFieldProps) { + const { control, formState: { errors } } = useFormContext(); + const error = errors[name]; + + const datePicker = ( + + ( + + )} + /> + + ); + + return datePicker; +} \ No newline at end of file diff --git a/src/components/FormField/MultilineTextFormField.tsx b/src/components/FormField/MultilineTextFormField.tsx new file mode 100644 index 0000000..e9b5276 --- /dev/null +++ b/src/components/FormField/MultilineTextFormField.tsx @@ -0,0 +1,80 @@ +import React from 'react'; +import { + Box, + Typography, + TextField, +} from '@mui/material'; +import { Controller, useFormContext } from 'react-hook-form'; + +export interface MultilineTextFormFieldProps { + name: string; + label: string; + helperText?: string; + defaultValue?: string; + disabled?: boolean; + required?: boolean; + fullWidth?: boolean; + rows?: number; + maxRows?: number; + minRows?: number; + placeholder?: string; + size?: 'small' | 'medium'; + maxLength?: number; +} + +export const MultilineTextFormField: React.FC = ({ + name, + label, + helperText, + defaultValue = '', + disabled = false, + required = false, + fullWidth = true, + rows = 4, + maxRows, + minRows, + placeholder, + size = 'medium', + maxLength, +}) => { + const { control } = useFormContext(); + + return ( + + + {required && *} + {label} + + ( + + )} + /> + + ); +}; \ No newline at end of file diff --git a/src/components/FormField/NumberInputFormField.tsx b/src/components/FormField/NumberInputFormField.tsx new file mode 100644 index 0000000..7841400 --- /dev/null +++ b/src/components/FormField/NumberInputFormField.tsx @@ -0,0 +1,112 @@ +import React from 'react'; +import { + Box, + Typography, + TextField, + IconButton, +} from '@mui/material'; +import { Add as AddIcon } from '@mui/icons-material'; +import { Controller, useFormContext } from 'react-hook-form'; + +export interface NumberInputFormFieldProps { + name: string; + label: string; + helperText?: string; + defaultValue?: number; + disabled?: boolean; + required?: boolean; + fullWidth?: boolean; + min?: number; + max?: number; + step?: number; + placeholder?: string; + size?: 'small' | 'medium'; + showRandomButton?: boolean; + onRandomClick?: () => void; +} + +export const NumberInputFormField: React.FC = ({ + name, + label, + helperText, + defaultValue = 0, + disabled = false, + required = false, + fullWidth = true, + min, + max, + step, + placeholder, + size = 'medium', + showRandomButton = false, + onRandomClick, +}) => { + const { control } = useFormContext(); + + const handleRandomClick = () => { + if (onRandomClick) { + onRandomClick(); + } else if (min !== undefined && max !== undefined) { + const randomValue = Math.floor(Math.random() * (max - min + 1)) + min; + // 这里需要通过setValue来更新表单值,但为了保持组件的纯净性, + // 建议通过onRandomClick回调来处理 + } + }; + + return ( + + + {required && *} + {label} + + ( + + { + const value = e.target.value === '' ? '' : Number(e.target.value); + field.onChange(value); + }} + /> + {showRandomButton && ( + + + + )} + + )} + /> + + ); +}; \ No newline at end of file diff --git a/src/components/FormField/SelectFormField.tsx b/src/components/FormField/SelectFormField.tsx new file mode 100644 index 0000000..b4115ad --- /dev/null +++ b/src/components/FormField/SelectFormField.tsx @@ -0,0 +1,96 @@ +import React from 'react'; +import { + Box, + Typography, + FormControl, + Select, + MenuItem, + FormHelperText, + InputLabel, +} from '@mui/material'; +import { Controller, useFormContext } from 'react-hook-form'; + +export interface SelectOption { + value: string | number; + label: string; + disabled?: boolean; +} + +export interface SelectFormFieldProps { + name: string; + label: string; + options: SelectOption[]; + helperText?: string; + defaultValue?: string | number; + disabled?: boolean; + required?: boolean; + fullWidth?: boolean; + size?: 'small' | 'medium'; + displayEmpty?: boolean; + emptyLabel?: string; + multiple?: boolean; +} + +export const SelectFormField: React.FC = ({ + name, + label, + options, + helperText, + defaultValue = '', + disabled = false, + required = false, + fullWidth = true, + size = 'medium', + displayEmpty = true, + emptyLabel = '请选择', + multiple = false, +}) => { + const { control } = useFormContext(); + + return ( + + + {required && *} + {label} + + ( + + + {(error || helperText) && ( + + {error?.message || helperText} + + )} + + )} + /> + + ); +}; \ No newline at end of file diff --git a/src/components/FormField/SliderFormField.tsx b/src/components/FormField/SliderFormField.tsx new file mode 100644 index 0000000..31c66b3 --- /dev/null +++ b/src/components/FormField/SliderFormField.tsx @@ -0,0 +1,86 @@ +import React from 'react'; +import { Box, Typography, Slider } from '@mui/material'; +import { useController, useFormContext } from 'react-hook-form'; + +export interface SliderFormFieldProps { + name: string; + label: string; + min?: number; + max?: number; + step?: number; + defaultValue?: number; + valueLabelDisplay?: 'on' | 'auto' | 'off'; + marks?: boolean | Array<{ value: number; label?: string }>; + disabled?: boolean; + required?: boolean; + sx?: object; +} + +export const SliderFormField: React.FC = ({ + name, + label, + min = 0, + max = 100, + step = 1, + defaultValue = 0, + valueLabelDisplay = 'on', + marks = false, + disabled = false, + required = false, + sx = {}, +}) => { + const { control } = useFormContext(); + + const { + field, + fieldState: { error }, + } = useController({ + name, + control, + defaultValue, + }); + + return ( + + + {label} + {required && *} + + + + field.onChange(value)} + sx={{ + color: error ? 'error.main' : 'primary.main', + }} + /> + + + {error && ( + + {error.message} + + )} + + ); +}; + +export default SliderFormField; \ No newline at end of file diff --git a/src/components/FormField/SliderInputFormField.tsx b/src/components/FormField/SliderInputFormField.tsx new file mode 100644 index 0000000..7f22c50 --- /dev/null +++ b/src/components/FormField/SliderInputFormField.tsx @@ -0,0 +1,105 @@ +import { + FormControl, + FormHelperText, + Box, + Typography, + Slider, + TextField, + Grid, +} from '@mui/material'; +import { useFormContext, Controller } from 'react-hook-form'; +import { type ReactNode } from 'react'; +import type { IFormLayoutType } from '.'; + +export type SliderInputFormFieldProps = { + max?: number; + min?: number; + step?: number; + name: string; + label: string; + tooltip?: ReactNode; + defaultValue?: number; + className?: string; +} & IFormLayoutType; + +export function SliderInputFormField({ + max = 100, + min = 0, + step = 1, + label, + name, + tooltip, + defaultValue = 0, + className, + layout = 'horizontal', +}: SliderInputFormFieldProps) { + const { control, formState: { errors } } = useFormContext(); + + const isHorizontal = layout === 'horizontal'; + + return ( + + ( + + + {label} + {tooltip && ( + + {tooltip} + + )} + + + + + + + + + + + + + + + + {errors[name] && ( + + {errors[name]?.message as string} + + )} + + )} + /> + + ); +} diff --git a/src/components/FormField/SwitchFormField.tsx b/src/components/FormField/SwitchFormField.tsx new file mode 100644 index 0000000..61ec977 --- /dev/null +++ b/src/components/FormField/SwitchFormField.tsx @@ -0,0 +1,72 @@ +import React from 'react'; +import { + Box, + Typography, + FormControlLabel, + Switch, + FormHelperText, +} from '@mui/material'; +import { Controller, useFormContext } from 'react-hook-form'; + +export interface SwitchFormFieldProps { + name: string; + label: string; + helperText?: string; + defaultValue?: boolean; + disabled?: boolean; + required?: boolean; + size?: 'small' | 'medium'; + color?: 'primary' | 'secondary' | 'error' | 'info' | 'success' | 'warning'; +} + +export const SwitchFormField: React.FC = ({ + name, + label, + helperText, + defaultValue = false, + disabled = false, + required = false, + size = 'medium', + color = 'primary', +}) => { + const { control } = useFormContext(); + + return ( + + ( + <> + + } + label={ + + {required && *} + {label} + + } + /> + {(error || helperText) && ( + + {error?.message || helperText} + + )} + + )} + /> + + ); +}; \ No newline at end of file diff --git a/src/components/FormField/TextFormField.tsx b/src/components/FormField/TextFormField.tsx new file mode 100644 index 0000000..25a63ee --- /dev/null +++ b/src/components/FormField/TextFormField.tsx @@ -0,0 +1,69 @@ +import React from 'react'; +import { TextField, Box, Typography } from '@mui/material'; +import { useFormContext, Controller } from 'react-hook-form'; +import { type IFormLayoutType } from './index'; + +export interface TextFormFieldProps extends IFormLayoutType { + name: string; + label: string; + placeholder?: string; + defaultValue?: string; + required?: boolean; + disabled?: boolean; + helperText?: string; + type?: 'text' | 'email' | 'password' | 'url' | 'tel'; +} + +export function TextFormField({ + name, + label, + placeholder, + defaultValue = '', + required = false, + disabled = false, + layout = 'vertical', + helperText, + type = 'text', +}: TextFormFieldProps) { + const { control, formState: { errors } } = useFormContext(); + const error = errors[name]; + const isHorizontal = layout === 'horizontal'; + + const textField = ( + ( + + )} + /> + ); + + if (isHorizontal) { + return ( + + + {label} + {required && *} + + + {textField} + + + ); + } + + return textField; +} \ No newline at end of file diff --git a/src/components/FormField/index.ts b/src/components/FormField/index.ts new file mode 100644 index 0000000..873c6b4 --- /dev/null +++ b/src/components/FormField/index.ts @@ -0,0 +1,35 @@ +// 基础组件导出 +export { SliderInputFormField } from './SliderInputFormField'; +export { SwitchFormField } from './SwitchFormField'; +export { SelectFormField } from './SelectFormField'; +export { MultilineTextFormField } from './MultilineTextFormField'; +export { NumberInputFormField } from './NumberInputFormField'; +export { ChipListFormField } from './ChipListFormField'; +export { SliderFormField } from './SliderFormField'; +export { TextFormField } from './TextFormField'; +export { DatePickerFormField } from './DatePickerFormField'; +export { CheckboxFormField } from './CheckboxFormField'; + +// 类型导出 +export type { SliderInputFormFieldProps } from './SliderInputFormField'; +export type { SwitchFormFieldProps } from './SwitchFormField'; +export type { SelectFormFieldProps, SelectOption } from './SelectFormField'; +export type { MultilineTextFormFieldProps } from './MultilineTextFormField'; +export type { NumberInputFormFieldProps } from './NumberInputFormField'; +export type { ChipListFormFieldProps } from './ChipListFormField'; +export type { SliderFormFieldProps } from './SliderFormField'; +export type { TextFormFieldProps } from './TextFormField'; +export type { DatePickerFormFieldProps } from './DatePickerFormField'; +export type { CheckboxFormFieldProps } from './CheckboxFormField'; + +export type IFormLayoutType = { + layout?: FormLayout; +}; + +export const FORM_LAYOUTS = { + Vertical: 'vertical', + Horizontal: 'horizontal', +} as const; + +export type FormLayout = (typeof FORM_LAYOUTS)[keyof typeof FORM_LAYOUTS]; + diff --git a/src/pages/FormFieldTest.tsx b/src/pages/FormFieldTest.tsx new file mode 100644 index 0000000..919016a --- /dev/null +++ b/src/pages/FormFieldTest.tsx @@ -0,0 +1,163 @@ +import React from 'react'; +import { Box, Typography, Paper, Divider } from '@mui/material'; +import { useForm, FormProvider } from 'react-hook-form'; +import { + SliderInputFormField, + SwitchFormField, + SelectFormField, + MultilineTextFormField, + NumberInputFormField, + ChipListFormField, + type SelectOption, +} from '@/components/FormField'; + +const FormFieldTest: React.FC = () => { + const methods = useForm({ + defaultValues: { + parser_config: { + auto_keywords: 5, + auto_questions: 3, + delimiter: '\n', + chunk_token_num: 512, + layout_recognize: 'DeepDOC', + html4excel: false, + }, + pagerank: 50, + custom_slider: 25, + }, + }); + + const onSubmit = (data: any) => { + console.log('Form Data:', data); + }; + + return ( + + + FormField 组件测试 + + + + +
+ + + 自动关键词和问题 + + + + + + + 分隔符配置 + + + + + + Token数量配置 + + + + + + 页面排名 + + + + + + 布局识别 + + + + + + Excel转HTML + + + + + + 自定义滑块(垂直布局) + + + + + + + + +
+
+ + + + 当前表单值 + +
+          {JSON.stringify(methods.watch(), null, 2)}
+        
+
+
+ ); +}; + +export default FormFieldTest; \ No newline at end of file diff --git a/src/pages/knowledge/configuration/audio.tsx b/src/pages/knowledge/configuration/audio.tsx index b0d1b8f..98aa5be 100644 --- a/src/pages/knowledge/configuration/audio.tsx +++ b/src/pages/knowledge/configuration/audio.tsx @@ -1,49 +1,16 @@ import React from 'react'; import { ConfigurationFormContainer } from './configuration-form-container'; -import { ChunkMethodItem, EmbeddingModelItem } from './common-item'; -import { Box, Typography } from '@mui/material'; +import { ChunkMethodItem, EmbeddingModelItem, PageRankItem, AutoKeywordsItem, AutoQuestionsItem, TagsItem } from './common-items'; export function AudioConfiguration() { return ( - - - - PageRank配置 - 待实现 - - - - - - 自动关键词配置 - 待实现 - - - - - - 自动问题配置 - 待实现 - - - - - - Raptor配置 - 待实现 - - - - - - GraphRAG配置 - 待实现 - - - - - - 标签配置 - 待实现 - - + + + + ); } \ No newline at end of file diff --git a/src/pages/knowledge/configuration/book.tsx b/src/pages/knowledge/configuration/book.tsx index 7e4dd28..750b140 100644 --- a/src/pages/knowledge/configuration/book.tsx +++ b/src/pages/knowledge/configuration/book.tsx @@ -1,60 +1,60 @@ import React from 'react'; import { ConfigurationFormContainer, MainContainer } from './configuration-form-container'; -import { ChunkMethodItem, EmbeddingModelItem } from './common-item'; -import { Box, Typography } from '@mui/material'; +import { + ChunkMethodItem, + EmbeddingModelItem, + LayoutRecognizeItem, + PageRankItem, + AutoKeywordsItem, + AutoQuestionsItem, + UseRaptorItem, + RaptorPromptItem, + RaptorMaxTokenItem, + RaptorThresholdItem, + RaptorMaxClusterItem, + RaptorRandomSeedItem, + UseGraphragItem, + EntityTypesItem, + GraphragMethodItem, + EntityNormalizeItem, + CommunityReportItem, + TagsItem +} from './common-items'; export function BookConfiguration() { return ( - - - 布局识别配置 - 待实现 - - + - - - - PageRank配置 - 待实现 - - + - - - 自动关键词配置 - 待实现 - - - - - 自动问题配置 - 待实现 - - + + - - - Raptor配置 - 待实现 - - + + + + + + - - - GraphRAG配置 - 待实现 - - + + + + + + + - - - 标签配置 - 待实现 - - + ); diff --git a/src/pages/knowledge/configuration/common-item.tsx b/src/pages/knowledge/configuration/common-item.tsx deleted file mode 100644 index b25a6f4..0000000 --- a/src/pages/knowledge/configuration/common-item.tsx +++ /dev/null @@ -1,118 +0,0 @@ -import { - FormControl, - InputLabel, - Select, - MenuItem, - FormHelperText, - Box, - Typography, - ListSubheader, -} from '@mui/material'; -import { useFormContext, Controller } from 'react-hook-form'; -import { DOCUMENT_PARSER_TYPES } from '@/constants/knowledge'; -import { useSelectChunkMethodList } from '../hooks'; -import { useEmbeddingModelOptions } from '@/hooks/llm-hooks'; - -// 解析器选项配置 -const PARSER_OPTIONS = [ - { value: DOCUMENT_PARSER_TYPES.Naive, label: 'General', description: '通用解析器' }, - { value: DOCUMENT_PARSER_TYPES.Qa, label: 'Q&A', description: 'Q&A解析器' }, - { value: DOCUMENT_PARSER_TYPES.Resume, label: 'Resume', description: 'Resume解析器' }, - { value: DOCUMENT_PARSER_TYPES.Manual, label: 'Manual', description: 'Manual解析器' }, - { value: DOCUMENT_PARSER_TYPES.Table, label: 'Table', description: 'Table解析器' }, - { value: DOCUMENT_PARSER_TYPES.Paper, label: 'Paper', description: 'Paper解析器' }, - { value: DOCUMENT_PARSER_TYPES.Book, label: 'Book', description: 'Book解析器' }, - { value: DOCUMENT_PARSER_TYPES.Laws, label: 'Laws', description: 'Laws解析器' }, - { value: DOCUMENT_PARSER_TYPES.Presentation, label: 'Presentation', description: 'Presentation解析器' }, - { value: DOCUMENT_PARSER_TYPES.One, label: 'One', description: 'One解析器' }, - { value: DOCUMENT_PARSER_TYPES.Tag, label: 'Tag', description: 'Tag解析器' }, -]; - -export function ChunkMethodItem() { - const { control, formState: { errors } } = useFormContext(); - const parserIds = useSelectChunkMethodList(); - - const parserOptions = parserIds.map((x) => ({ - value: x, - label: PARSER_OPTIONS.find((y) => y.value === x)?.label || x, - description: PARSER_OPTIONS.find((y) => y.value === x)?.description || x, - })); - - return ( - - - 切片方法 - - ( - - 选择切片方法 - - {errors.parser_id && ( - {errors.parser_id.message as string} - )} - - )} - /> - - ); -} - -export function EmbeddingModelItem() { - const { control, formState: { errors } } = useFormContext(); - - const { options: embdOptions } = useEmbeddingModelOptions(); - - return ( - - - 嵌入模型 - - ( - - 选择嵌入模型 - - {errors.embd_id && ( - {errors.embd_id.message as string} - )} - - )} - /> - - ); -} \ No newline at end of file diff --git a/src/pages/knowledge/configuration/common-items.tsx b/src/pages/knowledge/configuration/common-items.tsx new file mode 100644 index 0000000..bfc51f9 --- /dev/null +++ b/src/pages/knowledge/configuration/common-items.tsx @@ -0,0 +1,416 @@ +import { useMemo } from 'react'; +import { + FormControl, + InputLabel, + Select, + MenuItem, + FormHelperText, + Box, + Typography, + ListSubheader, + Button, +} from '@mui/material'; +import { Shuffle as ShuffleIcon } from '@mui/icons-material'; +import { useFormContext, Controller } from 'react-hook-form'; +import { DOCUMENT_PARSER_TYPES, LLM_MODEL_TYPES, type LlmModelType } from '@/constants/knowledge'; +import { useSelectChunkMethodList } from '../hooks'; +import { useEmbeddingModelOptions, useLlmOptionsByModelType } from '@/hooks/llm-hooks'; +import { + SliderInputFormField, + SwitchFormField, + SelectFormField, + MultilineTextFormField, + NumberInputFormField, + ChipListFormField, + TextFormField, + type SelectOption, +} from '@/components/FormField'; + +// 解析器选项配置 +const PARSER_OPTIONS = [ + { value: DOCUMENT_PARSER_TYPES.Naive, label: 'General', description: '通用解析器' }, + { value: DOCUMENT_PARSER_TYPES.Qa, label: 'Q&A', description: 'Q&A解析器' }, + { value: DOCUMENT_PARSER_TYPES.Resume, label: 'Resume', description: 'Resume解析器' }, + { value: DOCUMENT_PARSER_TYPES.Manual, label: 'Manual', description: 'Manual解析器' }, + { value: DOCUMENT_PARSER_TYPES.Table, label: 'Table', description: 'Table解析器' }, + { value: DOCUMENT_PARSER_TYPES.Paper, label: 'Paper', description: 'Paper解析器' }, + { value: DOCUMENT_PARSER_TYPES.Book, label: 'Book', description: 'Book解析器' }, + { value: DOCUMENT_PARSER_TYPES.Laws, label: 'Laws', description: 'Laws解析器' }, + { value: DOCUMENT_PARSER_TYPES.Presentation, label: 'Presentation', description: 'Presentation解析器' }, + { value: DOCUMENT_PARSER_TYPES.One, label: 'One', description: 'One解析器' }, + { value: DOCUMENT_PARSER_TYPES.Tag, label: 'Tag', description: 'Tag解析器' }, +]; + +export function ChunkMethodItem() { + const { control, formState: { errors } } = useFormContext(); + const parserIds = useSelectChunkMethodList(); + + const parserOptions = parserIds.map((x) => ({ + value: x, + label: PARSER_OPTIONS.find((y) => y.value === x)?.label || x, + description: PARSER_OPTIONS.find((y) => y.value === x)?.description || x, + })); + + return ( + + + 切片方法 + + ( + + 选择切片方法 + + {errors.parser_id && ( + {errors.parser_id.message as string} + )} + + )} + /> + + ); +} + +// 基于基础FormField组件的业务组合组件 + +// 分块token数量配置 +export function ChunkTokenNumberItem() { + return ( + + ); +} + +// 页面排名配置 +export function PageRankItem() { + return ( + + ); +} + +// 自动关键词数量配置 +export function AutoKeywordsItem() { + return ( + + ); +} + +// 自动问题数量配置 +export function AutoQuestionsItem() { + return ( + + ); +} + +// 表格转HTML开关 +export function HtmlForExcelItem() { + return ( + + ); +} + +// 标签集选择 +export function TagsItem() { + const tagsOptions: SelectOption[] = [ + { value: '', label: '请选择' }, + // 这里可以根据实际需求添加标签选项 + ]; + + return ( + + ); +} + +// RAPTOR策略开关 +export function UseRaptorItem() { + return ( + + ); +} + +// RAPTOR提示词配置 +export function RaptorPromptItem() { + return ( + + ); +} + +// RAPTOR最大token数配置 +export function RaptorMaxTokenItem() { + return ( + + ); +} + +// RAPTOR阈值配置 +export function RaptorThresholdItem() { + return ( + + ); +} + +// RAPTOR最大聚类数配置 +export function RaptorMaxClusterItem() { + return ( + + ); +} + +// RAPTOR随机种子配置 +export function RaptorRandomSeedItem() { + return ( + + ); +} + +// 知识图谱开关 +export function UseGraphragItem() { + return ( + + ); +} + +// 实体类型配置 +export function EntityTypesItem() { + return ( + + ); +} + +// GraphRAG方法选择 +export function GraphragMethodItem() { + const methodOptions: SelectOption[] = [ + { value: 'Light', label: 'Light' }, + { value: 'General', label: 'General' }, + ]; + + return ( + + ); +} + +// 实体归一化开关 +export function EntityNormalizeItem() { + return ( + + ); +} + +// 社区报告生成开关 +export function CommunityReportItem() { + return ( + + ); +} + +export function EmbeddingModelItem() { + const { control } = useFormContext(); + const { options } = useEmbeddingModelOptions(); + + return ( + + + 嵌入模型 + + + ( + + + + )} + /> + + + ); +} + +// PDF解析器配置 +export function LayoutRecognizeItem() { + const { control, setValue, formState } = useFormContext(); + const { getOptionsByModelType } = useLlmOptionsByModelType(); + + const options = useMemo(() => { + // 基础选项 + const basicOptions = [ + { value: 'DeepDOC', label: 'DeepDOC' }, + { value: 'Plain Text', label: '纯文本' } + ]; + + // 获取图像转文本模型选项 + const image2TextOptions = getOptionsByModelType(LLM_MODEL_TYPES.Image2text); + + // 将图像转文本模型选项转换为SelectOption格式 + const image2TextSelectOptions = image2TextOptions.flatMap(group => + group.options.map(option => ({ + value: option.value, + label: `${option.label} (实验性)` + })) + ); + + return [...basicOptions, ...image2TextSelectOptions]; + }, [getOptionsByModelType]); + + return ( + { + // 设置默认值 + if (typeof field.value === 'undefined') { + const defaultValue = formState.defaultValues?.parser_config?.layout_recognize ?? 'DeepDOC'; + setValue('parser_config.layout_recognize', defaultValue); + } + + return ( + + ); + }} + /> + ); +} + +// 文本分段标识符配置 +export function DelimiterItem() { + return ( + + ); +} \ No newline at end of file diff --git a/src/pages/knowledge/configuration/email.tsx b/src/pages/knowledge/configuration/email.tsx index d9c8aa7..127448a 100644 --- a/src/pages/knowledge/configuration/email.tsx +++ b/src/pages/knowledge/configuration/email.tsx @@ -1,49 +1,16 @@ import React from 'react'; import { ConfigurationFormContainer } from './configuration-form-container'; -import { ChunkMethodItem, EmbeddingModelItem } from './common-item'; -import { Box, Typography } from '@mui/material'; +import { ChunkMethodItem, EmbeddingModelItem, PageRankItem, AutoKeywordsItem, AutoQuestionsItem, TagsItem } from './common-items'; export function EmailConfiguration() { return ( - - - - PageRank配置 - 待实现 - - - - - - 自动关键词配置 - 待实现 - - - - - - 自动问题配置 - 待实现 - - - - - - Raptor配置 - 待实现 - - - - - - GraphRAG配置 - 待实现 - - - - - - 标签配置 - 待实现 - - + + + + ); } \ No newline at end of file diff --git a/src/pages/knowledge/configuration/index.tsx b/src/pages/knowledge/configuration/index.tsx index 778094f..d21316e 100644 --- a/src/pages/knowledge/configuration/index.tsx +++ b/src/pages/knowledge/configuration/index.tsx @@ -2,7 +2,7 @@ export { NaiveConfiguration } from './naive'; export { QAConfiguration } from './qa'; export { PaperConfiguration } from './paper'; -export { ChunkMethodItem, EmbeddingModelItem } from './common-item'; +export { ChunkMethodItem, EmbeddingModelItem } from './common-items'; export { ConfigurationFormContainer, MainContainer } from './configuration-form-container'; // 所有解析器配置组件 diff --git a/src/pages/knowledge/configuration/knowledge-graph.tsx b/src/pages/knowledge/configuration/knowledge-graph.tsx index 9b95c07..f091f2f 100644 --- a/src/pages/knowledge/configuration/knowledge-graph.tsx +++ b/src/pages/knowledge/configuration/knowledge-graph.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { ChunkMethodItem, EmbeddingModelItem } from './common-item'; +import { ChunkMethodItem, EmbeddingModelItem } from './common-items'; import { Box, Typography } from '@mui/material'; export function KnowledgeGraphConfiguration() { diff --git a/src/pages/knowledge/configuration/laws.tsx b/src/pages/knowledge/configuration/laws.tsx index 3a26c70..b9cc066 100644 --- a/src/pages/knowledge/configuration/laws.tsx +++ b/src/pages/knowledge/configuration/laws.tsx @@ -1,61 +1,16 @@ import React from 'react'; -import { ConfigurationFormContainer, MainContainer } from './configuration-form-container'; -import { ChunkMethodItem, EmbeddingModelItem } from './common-item'; -import { Box, Typography } from '@mui/material'; +import { ConfigurationFormContainer } from './configuration-form-container'; +import { ChunkMethodItem, EmbeddingModelItem, PageRankItem, AutoKeywordsItem, AutoQuestionsItem, TagsItem } from './common-items'; export function LawsConfiguration() { return ( - - - - - - 布局识别配置 - 待实现 - - - - - - - PageRank配置 - 待实现 - - - - - - - - 自动关键词配置 - 待实现 - - - - - 自动问题配置 - 待实现 - - - - - - - - Raptor配置 - 待实现 - - - - - - - GraphRAG配置 - 待实现 - - - - - - - 标签配置 - 待实现 - - - - + + + + + + + + ); } \ No newline at end of file diff --git a/src/pages/knowledge/configuration/manual.tsx b/src/pages/knowledge/configuration/manual.tsx index 6a4449a..4023d02 100644 --- a/src/pages/knowledge/configuration/manual.tsx +++ b/src/pages/knowledge/configuration/manual.tsx @@ -1,59 +1,67 @@ import React from 'react'; import { ConfigurationFormContainer, MainContainer } from './configuration-form-container'; -import { ChunkMethodItem, EmbeddingModelItem } from './common-item'; -import { Box, Typography } from '@mui/material'; +import { + ChunkMethodItem, + EmbeddingModelItem, + ChunkTokenNumberItem, + DelimiterItem, + LayoutRecognizeItem, + PageRankItem, + AutoKeywordsItem, + AutoQuestionsItem, + HtmlForExcelItem, + UseRaptorItem, + RaptorPromptItem, + RaptorMaxTokenItem, + RaptorThresholdItem, + RaptorMaxClusterItem, + RaptorRandomSeedItem, + UseGraphragItem, + EntityTypesItem, + GraphragMethodItem, + EntityNormalizeItem, + CommunityReportItem, + TagsItem +} from './common-items'; export function ManualConfiguration() { return ( - - - 布局识别配置 - 待实现 - - + + + - - - - PageRank配置 - 待实现 - - - - - 自动关键词配置 - 待实现 - - - - - 自动问题配置 - 待实现 - - + + + + - - - Raptor配置 - 待实现 - - + + + + + + - - - GraphRAG配置 - 待实现 - - + + + + + + + - - - 标签配置 - 待实现 - - + + + ); } \ No newline at end of file diff --git a/src/pages/knowledge/configuration/naive.tsx b/src/pages/knowledge/configuration/naive.tsx index 99d2c27..c8c5b3f 100644 --- a/src/pages/knowledge/configuration/naive.tsx +++ b/src/pages/knowledge/configuration/naive.tsx @@ -2,27 +2,39 @@ import React from 'react'; import { Box, Typography, - FormControl, - InputLabel, - Select, - MenuItem, - TextField, - FormControlLabel, - Switch, - Slider, Accordion, AccordionSummary, AccordionDetails, - Chip, - IconButton, } from '@mui/material'; -import { ExpandMore as ExpandMoreIcon, Add as AddIcon } from '@mui/icons-material'; -import { useFormContext, Controller } from 'react-hook-form'; +import { ExpandMore as ExpandMoreIcon } from '@mui/icons-material'; +import { useFormContext } from 'react-hook-form'; import { ConfigurationFormContainer, MainContainer } from './configuration-form-container'; -import { ChunkMethodItem, EmbeddingModelItem } from './common-item'; +import { + ChunkMethodItem, + EmbeddingModelItem, + ChunkTokenNumberItem, + PageRankItem, + AutoKeywordsItem, + AutoQuestionsItem, + HtmlForExcelItem, + TagsItem, + UseRaptorItem, + RaptorPromptItem, + RaptorMaxTokenItem, + RaptorThresholdItem, + RaptorMaxClusterItem, + RaptorRandomSeedItem, + UseGraphragItem, + EntityTypesItem, + GraphragMethodItem, + EntityNormalizeItem, + CommunityReportItem, + LayoutRecognizeItem, + DelimiterItem +} from './common-items'; export function NaiveConfiguration() { - const { control, watch, formState: { errors } } = useFormContext(); + const { formState: { errors } } = useFormContext(); return ( @@ -38,72 +50,16 @@ export function NaiveConfiguration() { {/* PDF解析器 */} - - - PDF解析器 - - ( - - - - )} - /> - + {/* 嵌入模型 */} {/* 建议文本块大小 */} - - - 建议文本块大小 - - ( - - field.onChange(value)} - /> - - )} - /> - + {/* 文本分段标识符 */} - - - *文本分段标识符 - - ( - - )} - /> - + @@ -116,250 +72,47 @@ export function NaiveConfiguration() { {/* 页面排名 */} - - - 页面排名 - - ( - - )} - /> - + {/* 自动关键词提取 */} - - - 自动关键词提取 - - ( - - )} - /> - + {/* 自动问题提取 */} - - - 自动问题提取 - - ( - - )} - /> - + {/* 表格转HTML */} - - ( - - } - label="表格转HTML" - /> - )} - /> - + {/* 标签集 */} - - - 标签集 - - ( - - - - )} - /> - + {/* 第三部分:RAPTOR策略 */} - + }> RAPTOR策略 {/* 使用召回增强RAPTOR策略 */} - - ( - - } - label="使用召回增强RAPTOR策略" - /> - )} - /> - + {/* 提示词 */} - - - 提示词 - - ( - - )} - /> - + {/* 最大token数 */} - - - 最大token数 - - ( - - field.onChange(value)} - /> - - )} - /> - + {/* 阈值 */} - - - 阈值 - - ( - - field.onChange(value)} - /> - - )} - /> - + {/* 最大聚类数 */} - - - 最大聚类数 - - ( - - field.onChange(value)} - /> - - )} - /> - + {/* 随机种子 */} - - - 随机种子 - - ( - - - - - - - )} - /> - + @@ -372,109 +125,19 @@ export function NaiveConfiguration() { {/* 提取知识图谱 */} - - ( - - } - label="提取知识图谱" - /> - )} - /> - + {/* 实体类型 */} - - - *实体类型 - - ( - - {['organization', 'person', 'geo', 'event', 'category'].map((type) => ( - {}} - variant="outlined" - /> - ))} - - - - - )} - /> - + {/* 方法 */} - - - 方法 - - ( - - - - )} - /> - + {/* 实体归一化 */} - - ( - - } - label="实体归一化" - /> - )} - /> - + {/* 社区报告生成 */} - - ( - - } - label="社区报告生成" - /> - )} - /> - + diff --git a/src/pages/knowledge/configuration/one.tsx b/src/pages/knowledge/configuration/one.tsx index 68bb262..7efd9ce 100644 --- a/src/pages/knowledge/configuration/one.tsx +++ b/src/pages/knowledge/configuration/one.tsx @@ -1,48 +1,67 @@ import React from 'react'; -import { ConfigurationFormContainer } from './configuration-form-container'; -import { ChunkMethodItem, EmbeddingModelItem } from './common-item'; -import { Box, Typography } from '@mui/material'; +import { ConfigurationFormContainer, MainContainer } from './configuration-form-container'; +import { + ChunkMethodItem, + EmbeddingModelItem, + ChunkTokenNumberItem, + DelimiterItem, + LayoutRecognizeItem, + PageRankItem, + AutoKeywordsItem, + AutoQuestionsItem, + HtmlForExcelItem, + UseRaptorItem, + RaptorPromptItem, + RaptorMaxTokenItem, + RaptorThresholdItem, + RaptorMaxClusterItem, + RaptorRandomSeedItem, + UseGraphragItem, + EntityTypesItem, + GraphragMethodItem, + EntityNormalizeItem, + CommunityReportItem, + TagsItem +} from './common-items'; export function OneConfiguration() { return ( - - - - - 布局识别配置 - 待实现 - - - + + + + + + + + - - - PageRank配置 - 待实现 - - + + + + + + - - - 自动关键词配置 - 待实现 - - + + + + + + + + - - - 自动问题配置 - 待实现 - - + + + + + + + - - - GraphRAG配置 - 待实现 - - - - - - 标签配置 - 待实现 - - - + + + + ); } \ No newline at end of file diff --git a/src/pages/knowledge/configuration/paper.tsx b/src/pages/knowledge/configuration/paper.tsx index dd18dd3..9989008 100644 --- a/src/pages/knowledge/configuration/paper.tsx +++ b/src/pages/knowledge/configuration/paper.tsx @@ -1,121 +1,61 @@ import React from 'react'; -import { - Box, - Typography, - FormControl, - InputLabel, - Select, - MenuItem, - TextField, - Slider, -} from '@mui/material'; -import { useFormContext, Controller } from 'react-hook-form'; import { ConfigurationFormContainer, MainContainer } from './configuration-form-container'; +import { + ChunkMethodItem, + EmbeddingModelItem, + LayoutRecognizeItem, + PageRankItem, + AutoKeywordsItem, + AutoQuestionsItem, + UseRaptorItem, + RaptorPromptItem, + RaptorMaxTokenItem, + RaptorThresholdItem, + RaptorMaxClusterItem, + RaptorRandomSeedItem, + UseGraphragItem, + EntityTypesItem, + GraphragMethodItem, + EntityNormalizeItem, + CommunityReportItem, + TagsItem +} from './common-items'; export function PaperConfiguration() { - const { control } = useFormContext(); - return ( - - - {/* 布局识别 */} - - - 布局识别 - - ( - - 布局识别方式 - - - )} - /> - + + + + + + + - {/* 自动关键词 */} - - - 自动关键词数量 - - ( - - field.onChange(value)} - /> - - )} - /> - + + + + - {/* 自动问题 */} - - - 自动问题数量 - - ( - - field.onChange(value)} - /> - - )} - /> - + + + + + + + + - {/* 标签数量 */} - - - Top N 标签数量 - - ( - field.onChange(parseInt(e.target.value))} - /> - )} - /> - + + + + + + + - - - 论文解析器专门优化用于学术论文的解析,能够更好地识别论文的结构和内容。 - - - - + + + + ); } \ No newline at end of file diff --git a/src/pages/knowledge/configuration/picture.tsx b/src/pages/knowledge/configuration/picture.tsx index a77d399..8803785 100644 --- a/src/pages/knowledge/configuration/picture.tsx +++ b/src/pages/knowledge/configuration/picture.tsx @@ -1,37 +1,16 @@ import React from 'react'; import { ConfigurationFormContainer } from './configuration-form-container'; -import { ChunkMethodItem, EmbeddingModelItem } from './common-item'; -import { Box, Typography } from '@mui/material'; +import { ChunkMethodItem, EmbeddingModelItem, PageRankItem, AutoKeywordsItem, AutoQuestionsItem, TagsItem } from './common-items'; export function PictureConfiguration() { return ( - - - - PageRank配置 - 待实现 - - - - - - 自动关键词配置 - 待实现 - - - - - - 自动问题配置 - 待实现 - - - - - - 标签配置 - 待实现 - - + + + + ); } \ No newline at end of file diff --git a/src/pages/knowledge/configuration/presentation.tsx b/src/pages/knowledge/configuration/presentation.tsx index f36bc6c..e1c1bd0 100644 --- a/src/pages/knowledge/configuration/presentation.tsx +++ b/src/pages/knowledge/configuration/presentation.tsx @@ -1,61 +1,16 @@ import React from 'react'; -import { ConfigurationFormContainer, MainContainer } from './configuration-form-container'; -import { ChunkMethodItem, EmbeddingModelItem } from './common-item'; -import { Box, Typography } from '@mui/material'; +import { ConfigurationFormContainer } from './configuration-form-container'; +import { ChunkMethodItem, EmbeddingModelItem, PageRankItem, AutoKeywordsItem, AutoQuestionsItem, TagsItem } from './common-items'; export function PresentationConfiguration() { return ( - - - - - - 布局识别配置 - 待实现 - - - - - - - PageRank配置 - 待实现 - - - - - - - - 自动关键词配置 - 待实现 - - - - - 自动问题配置 - 待实现 - - - - - - - - Raptor配置 - 待实现 - - - - - - - GraphRAG配置 - 待实现 - - - - - - - 标签配置 - 待实现 - - - - + + + + + + + + ); } \ No newline at end of file diff --git a/src/pages/knowledge/configuration/qa.tsx b/src/pages/knowledge/configuration/qa.tsx index e0e06a5..621e156 100644 --- a/src/pages/knowledge/configuration/qa.tsx +++ b/src/pages/knowledge/configuration/qa.tsx @@ -1,45 +1,14 @@ import React from 'react'; -import { - Box, - Typography, - TextField, -} from '@mui/material'; -import { useFormContext, Controller } from 'react-hook-form'; -import { ConfigurationFormContainer, MainContainer } from './configuration-form-container'; +import { ConfigurationFormContainer } from './configuration-form-container'; +import { ChunkMethodItem, EmbeddingModelItem, PageRankItem, TagsItem } from './common-items'; export function QAConfiguration() { - const { control } = useFormContext(); - return ( - - {/* 标签数量 */} - - - Top N 标签数量 - - ( - field.onChange(parseInt(e.target.value))} - /> - )} - /> - - - - - Q&A解析器专门用于处理问答格式的文档,会自动识别问题和答案的结构。 - - - + + + + ); } \ No newline at end of file diff --git a/src/pages/knowledge/configuration/resume.tsx b/src/pages/knowledge/configuration/resume.tsx index a3bad6b..9820b52 100644 --- a/src/pages/knowledge/configuration/resume.tsx +++ b/src/pages/knowledge/configuration/resume.tsx @@ -1,25 +1,16 @@ import React from 'react'; import { ConfigurationFormContainer } from './configuration-form-container'; -import { ChunkMethodItem, EmbeddingModelItem } from './common-item'; -import { Box, Typography } from '@mui/material'; +import { ChunkMethodItem, EmbeddingModelItem, PageRankItem, AutoKeywordsItem, AutoQuestionsItem, TagsItem } from './common-items'; export function ResumeConfiguration() { return ( - - - - PageRank配置 - 待实现 - - - - - - 标签配置 - 待实现 - - + + + + ); } \ No newline at end of file diff --git a/src/pages/knowledge/configuration/table.tsx b/src/pages/knowledge/configuration/table.tsx index a91097b..f14d074 100644 --- a/src/pages/knowledge/configuration/table.tsx +++ b/src/pages/knowledge/configuration/table.tsx @@ -1,19 +1,16 @@ import React from 'react'; import { ConfigurationFormContainer } from './configuration-form-container'; -import { ChunkMethodItem, EmbeddingModelItem } from './common-item'; -import { Box, Typography } from '@mui/material'; +import { ChunkMethodItem, EmbeddingModelItem, PageRankItem, AutoKeywordsItem, AutoQuestionsItem, TagsItem } from './common-items'; export function TableConfiguration() { return ( - - - - PageRank配置 - 待实现 - - + + + + ); } \ No newline at end of file diff --git a/src/pages/knowledge/configuration/tag.tsx b/src/pages/knowledge/configuration/tag.tsx index ced2767..278be0a 100644 --- a/src/pages/knowledge/configuration/tag.tsx +++ b/src/pages/knowledge/configuration/tag.tsx @@ -1,6 +1,6 @@ import React from 'react'; import { ConfigurationFormContainer } from './configuration-form-container'; -import { ChunkMethodItem, EmbeddingModelItem } from './common-item'; +import { ChunkMethodItem, EmbeddingModelItem } from './common-items'; import { Box, Typography } from '@mui/material'; export function TagConfiguration() { diff --git a/src/pages/knowledge/setting.tsx b/src/pages/knowledge/setting.tsx index c1963e3..fbf4bc1 100644 --- a/src/pages/knowledge/setting.tsx +++ b/src/pages/knowledge/setting.tsx @@ -71,6 +71,7 @@ function KnowledgeBaseSetting() { permission: knowledge.permission || 'me', avatar: knowledge.avatar, parser_id: knowledge.parser_id || DOCUMENT_PARSER_TYPES.Naive, + embd_id: knowledge.embd_id || '', parser_config: { chunk_token_num: knowledge.parser_config?.chunk_token_num || 512, delimiter: knowledge.parser_config?.delimiter || '\n', diff --git a/src/routes/index.tsx b/src/routes/index.tsx index 2fbfd67..4bc65cd 100644 --- a/src/routes/index.tsx +++ b/src/routes/index.tsx @@ -7,6 +7,7 @@ import Dashboard from '../pages/Dashboard'; import ModelsResources from '../pages/ModelsResources'; import { KnowledgeBaseList, KnowledgeBaseCreate, KnowledgeBaseDetail, KnowledgeBaseSetting, KnowledgeBaseTesting } from '../pages/knowledge'; import MCP from '../pages/MCP'; +import FormFieldTest from '../pages/FormFieldTest'; const AppRoutes = () => { return ( @@ -31,6 +32,7 @@ const AppRoutes = () => { } /> } /> } /> + } /> {/* 处理未匹配的路由 */}