feat: 清理 AIResponseBox 和表单组件代码,移除冗余注释和未使用的导入

This commit is contained in:
sd0ric4
2025-03-27 12:34:20 +08:00
parent c8a9c8157e
commit c160721cbe
3 changed files with 1 additions and 28 deletions

View File

@@ -6,7 +6,6 @@ import {
AccordionItem,
AccordionPanel,
Box,
Button,
Flex,
HStack
} from '@chakra-ui/react';
@@ -16,7 +15,7 @@ import {
ToolModuleResponseItemType,
UserChatItemValueItemType
} from '@fastgpt/global/core/chat/type';
import React, { useCallback, useEffect, useMemo } from 'react';
import React, { useCallback, useMemo } from 'react';
import MyIcon from '@fastgpt/web/components/common/Icon';
import Avatar from '@fastgpt/web/components/common/Avatar';
import {
@@ -223,7 +222,6 @@ const RenderUserFormInteractive = React.memo(function RenderFormInput({
}) {
const { t } = useTranslation();
// 处理默认值
const defaultValues = useMemo(() => {
if (interactive.type === 'userInput') {
return interactive.params.inputForm?.reduce((acc: Record<string, any>, item) => {
@@ -234,7 +232,6 @@ const RenderUserFormInteractive = React.memo(function RenderFormInput({
return {};
}, [interactive]);
// 提交表单时的处理
const handleFormSubmit = useCallback((data: Record<string, any>) => {
onSendPrompt({
text: JSON.stringify(data),

View File

@@ -11,16 +11,13 @@ import MyNumberInput from '@fastgpt/web/components/common/Input/NumberInput';
import { FlowNodeInputTypeEnum } from '@fastgpt/global/core/workflow/node/constant';
import MyIcon from '@fastgpt/web/components/common/Icon';
// 定义IconName类型 - 这应该与MyIcon组件要求的类型匹配
type IconName = 'core/workflow/debugNext' | 'common/loading' | 'core/chat/think';
// 定义选项接口
export interface SelectOption {
key: string;
value: string;
}
// 定义SelectOptionsComponent接口
export interface SelectOptionsComponentProps {
options: SelectOption[];
description?: string;
@@ -30,9 +27,6 @@ export interface SelectOptionsComponentProps {
variant?: string;
}
/**
* 共享的选项按钮组件
*/
export const SelectOptionsComponent = React.memo(function SelectOptionsComponent({
options = [],
description,
@@ -101,7 +95,6 @@ export const SelectOptionsComponent = React.memo(function SelectOptionsComponent
);
});
// 定义表单项接口
export interface FormItem {
label: string;
key?: string;
@@ -119,7 +112,6 @@ export interface FormItem {
}>;
}
// 定义FormInputComponent接口
export interface FormInputComponentProps {
inputForm: FormItem[];
description?: string;
@@ -132,9 +124,6 @@ export interface FormInputComponentProps {
isCompact?: boolean;
}
/**
* 共享的表单呈现组件
*/
export const FormInputComponent = React.memo(function FormInputComponent({
inputForm = [],
description,
@@ -319,7 +308,6 @@ export const FormInputComponent = React.memo(function FormInputComponent({
);
});
// 定义FormHandler接口
export interface UseFormHandlerReturn<T extends FieldValues = Record<string, any>> {
register: UseFormReturn<T>['register'];
setValue: UseFormReturn<T>['setValue'];
@@ -330,9 +318,6 @@ export interface UseFormHandlerReturn<T extends FieldValues = Record<string, any
getValues: UseFormReturn<T>['getValues'];
}
/**
* 创建共享的表单Hook
*/
export const useFormHandler = <T extends FieldValues = Record<string, any>>(
formConfig: UseFormProps<T> = {},
onSubmitCallback?: (data: T) => void

View File

@@ -17,7 +17,6 @@ import {
SelectOptionsComponent
} from './Form/FormComponents';
// 创建共用的交互式调试 Hook
const useInteractiveDebug = (
interactive: UserSelectInteractive | UserInputInteractive,
nodeId?: string
@@ -27,7 +26,6 @@ const useInteractiveDebug = (
workflowDebugData: v.workflowDebugData
}));
// 处理交互数据结构
const interactiveData = useMemo(() => {
return {
...interactive,
@@ -37,7 +35,6 @@ const useInteractiveDebug = (
};
}, [interactive]);
// 创建模拟的历史记录
const createMockHistory = useCallback((): ChatItemType[] => {
return [
{
@@ -52,12 +49,9 @@ const useInteractiveDebug = (
];
}, [interactiveData]);
// 启动调试的通用函数
const startDebug = useCallback(
(userContent: string, nodeUpdater: (node: any) => any) => {
if (!nodeId || !workflowDebugData) return;
// 创建包含用户交互的查询数据
const updatedQuery: UserChatItemValueItemType[] = [
...(workflowDebugData.query || []),
{
@@ -139,7 +133,6 @@ export const RenderUserFormInteractive = React.memo(function RenderFormInput({
const [isSubmitted, setIsSubmitted] = useState(false);
const { startDebug } = useInteractiveDebug(interactive, nodeId);
// 处理默认值
const defaultValues = useMemo(() => {
return interactive.params.inputForm?.reduce((acc: Record<string, any>, item) => {
acc[item.label] = !!item.value ? item.value : item.defaultValue;
@@ -147,7 +140,6 @@ export const RenderUserFormInteractive = React.memo(function RenderFormInput({
}, {});
}, [interactive.params.inputForm]);
// 提交表单时的处理
const handleFormSubmit = useCallback(
(formData: Record<string, any>) => {
if (!nodeId) return;
@@ -170,7 +162,6 @@ export const RenderUserFormInteractive = React.memo(function RenderFormInput({
[nodeId, startDebug, interactive.params.inputForm]
);
// 设置已提交状态
useEffect(() => {
if (interactive.params.submitted) {
setIsSubmitted(true);