refactor: 将接口定义更改为类型别名,简化代码结构
This commit is contained in:
@@ -13,19 +13,19 @@ import MyIcon from '@fastgpt/web/components/common/Icon';
|
|||||||
|
|
||||||
type IconName = 'core/workflow/debugNext' | 'common/loading' | 'core/chat/think';
|
type IconName = 'core/workflow/debugNext' | 'common/loading' | 'core/chat/think';
|
||||||
|
|
||||||
export interface SelectOption {
|
export type SelectOption = {
|
||||||
key: string;
|
key: string;
|
||||||
value: string;
|
value: string;
|
||||||
}
|
};
|
||||||
|
|
||||||
export interface SelectOptionsComponentProps {
|
export type SelectOptionsComponentProps = {
|
||||||
options: SelectOption[];
|
options: SelectOption[];
|
||||||
description?: string;
|
description?: string;
|
||||||
selectedValue?: string;
|
selectedValue?: string;
|
||||||
onSelectOption: (value: string) => void;
|
onSelectOption: (value: string) => void;
|
||||||
isDisabled?: boolean;
|
isDisabled?: boolean;
|
||||||
variant?: string;
|
variant?: string;
|
||||||
}
|
};
|
||||||
|
|
||||||
export const SelectOptionsComponent = React.memo(function SelectOptionsComponent({
|
export const SelectOptionsComponent = React.memo(function SelectOptionsComponent({
|
||||||
options = [],
|
options = [],
|
||||||
@@ -112,7 +112,7 @@ export type FormItem = {
|
|||||||
}>;
|
}>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface FormInputComponentProps {
|
export type FormInputComponentProps = {
|
||||||
inputForm: FormItem[];
|
inputForm: FormItem[];
|
||||||
description?: string;
|
description?: string;
|
||||||
onSubmit?: (data: Record<string, any>) => void;
|
onSubmit?: (data: Record<string, any>) => void;
|
||||||
@@ -122,7 +122,7 @@ export interface FormInputComponentProps {
|
|||||||
showSubmitButton?: boolean;
|
showSubmitButton?: boolean;
|
||||||
submitButtonIcon?: IconName;
|
submitButtonIcon?: IconName;
|
||||||
isCompact?: boolean;
|
isCompact?: boolean;
|
||||||
}
|
};
|
||||||
|
|
||||||
export const FormInputComponent = React.memo(function FormInputComponent({
|
export const FormInputComponent = React.memo(function FormInputComponent({
|
||||||
inputForm = [],
|
inputForm = [],
|
||||||
@@ -308,7 +308,7 @@ export const FormInputComponent = React.memo(function FormInputComponent({
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
export interface UseFormHandlerReturn<T extends FieldValues = Record<string, any>> {
|
export type UseFormHandlerReturn<T extends FieldValues = Record<string, any>> = {
|
||||||
register: UseFormReturn<T>['register'];
|
register: UseFormReturn<T>['register'];
|
||||||
setValue: UseFormReturn<T>['setValue'];
|
setValue: UseFormReturn<T>['setValue'];
|
||||||
handleSubmit: UseFormReturn<T>['handleSubmit'];
|
handleSubmit: UseFormReturn<T>['handleSubmit'];
|
||||||
@@ -316,7 +316,7 @@ export interface UseFormHandlerReturn<T extends FieldValues = Record<string, any
|
|||||||
control: UseFormReturn<T>['control'];
|
control: UseFormReturn<T>['control'];
|
||||||
reset: UseFormReturn<T>['reset'];
|
reset: UseFormReturn<T>['reset'];
|
||||||
getValues: UseFormReturn<T>['getValues'];
|
getValues: UseFormReturn<T>['getValues'];
|
||||||
}
|
};
|
||||||
|
|
||||||
export const useFormHandler = <T extends FieldValues = Record<string, any>>(
|
export const useFormHandler = <T extends FieldValues = Record<string, any>>(
|
||||||
formConfig: UseFormProps<T> = {},
|
formConfig: UseFormProps<T> = {},
|
||||||
|
|||||||
@@ -11,10 +11,10 @@ import {
|
|||||||
UserSelectInteractive
|
UserSelectInteractive
|
||||||
} from '@fastgpt/global/core/workflow/template/system/interactive/type';
|
} from '@fastgpt/global/core/workflow/template/system/interactive/type';
|
||||||
import {
|
import {
|
||||||
SelectOptionsComponent,
|
type SelectOption,
|
||||||
SelectOption,
|
type FormItem,
|
||||||
FormInputComponent,
|
FormInputComponent,
|
||||||
FormItem
|
SelectOptionsComponent
|
||||||
} from '@/components/core/chat/components/Form/FormComponents';
|
} from '@/components/core/chat/components/Form/FormComponents';
|
||||||
|
|
||||||
const useInteractiveDebug = (
|
const useInteractiveDebug = (
|
||||||
|
|||||||
Reference in New Issue
Block a user