From a430284aa21e3ae1f0d5654e55b2ad2852519cc2 Mon Sep 17 00:00:00 2001 From: wwf <yearningwang@iqtogether.com> Date: 星期三, 04 六月 2025 15:17:49 +0800 Subject: [PATCH] 初始化 --- app/components/workflow/nodes/tool/components/input-var-list.tsx | 92 +++++++++++++--------------------------------- 1 files changed, 26 insertions(+), 66 deletions(-) diff --git a/app/components/workflow/nodes/tool/components/input-var-list.tsx b/app/components/workflow/nodes/tool/components/input-var-list.tsx index 1a609c5..bab7c20 100644 --- a/app/components/workflow/nodes/tool/components/input-var-list.tsx +++ b/app/components/workflow/nodes/tool/components/input-var-list.tsx @@ -14,10 +14,6 @@ import Input from '@/app/components/workflow/nodes/_base/components/input-support-select-var' import useAvailableVarList from '@/app/components/workflow/nodes/_base/hooks/use-available-var-list' import { VarType } from '@/app/components/workflow/types' -import AppSelector from '@/app/components/plugins/plugin-detail-panel/app-selector' -import ModelParameterModal from '@/app/components/plugins/plugin-detail-panel/model-selector' -import { noop } from 'lodash-es' - type Props = { readOnly: boolean nodeId: string @@ -35,7 +31,7 @@ schema, value, onChange, - onOpen = noop, + onOpen = () => { }, isSupportConstantValue, filterVar, }) => { @@ -50,14 +46,12 @@ const paramType = (type: string) => { if (type === FormTypeEnum.textNumber) return 'Number' - else if (type === FormTypeEnum.file || type === FormTypeEnum.files) + else if (type === FormTypeEnum.file) + return 'File' + else if (type === FormTypeEnum.files) return 'Files' - else if (type === FormTypeEnum.appSelector) - return 'AppSelector' - else if (type === FormTypeEnum.modelSelector) - return 'ModelSelector' - else if (type === FormTypeEnum.toolSelector) - return 'ToolSelector' + else if (type === FormTypeEnum.select) + return 'Options' else return 'String' } @@ -79,7 +73,7 @@ }) onChange(newValue) } - }, [value, onChange]) + }, [value, onChange, isSupportConstantValue]) const handleMixedTypeChange = useCallback((variable: string) => { return (itemValue: string) => { @@ -111,30 +105,6 @@ } }, [value, onChange]) - const handleAppChange = useCallback((variable: string) => { - return (app: { - app_id: string - inputs: Record<string, any> - files?: any[] - }) => { - const newValue = produce(value, (draft: ToolVarInputs) => { - draft[variable] = app as any - }) - onChange(newValue) - } - }, [onChange, value]) - const handleModelChange = useCallback((variable: string) => { - return (model: any) => { - const newValue = produce(value, (draft: ToolVarInputs) => { - draft[variable] = { - ...draft[variable], - ...model, - } as any - }) - onChange(newValue) - } - }, [onChange, value]) - const [inputsIsFocus, setInputsIsFocus] = useState<Record<string, boolean>>({}) const handleInputFocus = useCallback((variable: string) => { return (value: boolean) => { @@ -159,27 +129,24 @@ type, required, tooltip, - scope, } = schema const varInput = value[variable] const isNumber = type === FormTypeEnum.textNumber const isSelect = type === FormTypeEnum.select - const isFile = type === FormTypeEnum.file || type === FormTypeEnum.files - const isAppSelector = type === FormTypeEnum.appSelector - const isModelSelector = type === FormTypeEnum.modelSelector - // const isToolSelector = type === FormTypeEnum.toolSelector - const isString = !isNumber && !isSelect && !isFile && !isAppSelector && !isModelSelector + const isFile = type === FormTypeEnum.file + const isFileArray = type === FormTypeEnum.files + const isString = !isNumber && !isSelect && !isFile && !isFileArray return ( <div key={variable} className='space-y-1'> - <div className='flex h-[18px] items-center space-x-2'> - <span className='code-sm-semibold text-text-secondary'>{label[language] || label.en_US}</span> - <span className='system-xs-regular text-text-tertiary'>{paramType(type)}</span> - {required && <span className='system-xs-regular text-util-colors-orange-dark-orange-dark-600'>Required</span>} + <div className='flex items-center h-[18px] space-x-2'> + <span className='text-text-secondary code-sm-semibold'>{label[language] || label.en_US}</span> + <span className='text-text-tertiary system-xs-regular'>{paramType(type)}</span> + {required && <span className='text-util-colors-orange-dark-orange-dark-600 system-xs-regular'>Required</span>} </div> {isString && ( <Input - className={cn(inputsIsFocus[variable] ? 'border-components-input-border-active bg-components-input-bg-active shadow-xs' : 'border-components-input-border-hover bg-components-input-bg-normal', 'rounded-lg border px-3 py-[6px]')} + className={cn(inputsIsFocus[variable] ? 'shadow-xs bg-gray-50 border-gray-300' : 'bg-gray-100 border-gray-100', 'rounded-lg px-3 py-[6px] border')} value={varInput?.value as string || ''} onChange={handleMixedTypeChange(variable)} readOnly={readOnly} @@ -214,29 +181,22 @@ onChange={handleFileChange(variable)} onOpen={handleOpen(index)} defaultVarKindType={VarKindType.variable} - filterVar={(varPayload: Var) => varPayload.type === VarType.file || varPayload.type === VarType.arrayFile} + filterVar={(varPayload: Var) => varPayload.type === VarType.file} /> )} - {isAppSelector && ( - <AppSelector - disabled={readOnly} - scope={scope || 'all'} - value={varInput as any} - onSelect={handleAppChange(variable)} - /> - )} - {isModelSelector && ( - <ModelParameterModal - popupClassName='!w-[387px]' - isAdvancedMode - isInWorkflow - value={varInput as any} - setModel={handleModelChange(variable)} + {isFileArray && ( + <VarReferencePicker readonly={readOnly} - scope={scope} + isShowNodeName + nodeId={nodeId} + value={varInput?.value || []} + onChange={handleFileChange(variable)} + onOpen={handleOpen(index)} + defaultVarKindType={VarKindType.variable} + filterVar={(varPayload: Var) => varPayload.type === VarType.arrayFile} /> )} - {tooltip && <div className='body-xs-regular text-text-tertiary'>{tooltip[language] || tooltip.en_US}</div>} + {tooltip && <div className='text-text-tertiary body-xs-regular'>{tooltip[language] || tooltip.en_US}</div>} </div> ) }) -- Gitblit v1.8.0