From e6a5f77333a91e79d581ceca86c6309617c0d968 Mon Sep 17 00:00:00 2001 From: zhaowei Date: Fri, 22 Aug 2025 15:54:53 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E4=BC=98=E5=8C=96ts=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/ParameterSelect/config.tsx | 19 +++++++++++-------- .../src/components/ParameterSelect/index.tsx | 2 +- .../components/PipelineNodeDrawer/index.tsx | 14 ++------------ react-ui/src/services/external/index.ts | 10 ++++++---- 4 files changed, 20 insertions(+), 25 deletions(-) diff --git a/react-ui/src/components/ParameterSelect/config.tsx b/react-ui/src/components/ParameterSelect/config.tsx index 59d984b0..71b1ff6b 100644 --- a/react-ui/src/components/ParameterSelect/config.tsx +++ b/react-ui/src/components/ParameterSelect/config.tsx @@ -16,14 +16,17 @@ export type SelectPropsConfig = { getLabel?: (value: any) => string; // 对象类型时,获取其 label }; -export type ParameterSelectDataType = - | 'dataset' - | 'model' - | 'service' - | 'resource' - | 'remote-image' - | 'remote-resource-type' - | 'remote-resource'; +export const ParameterSelectTypeList = [ + 'dataset', + 'model', + 'service', + 'resource', + 'remote-image', + 'remote-resource-type', + 'remote-resource', +] as const; + +export type ParameterSelectDataType = (typeof ParameterSelectTypeList)[number]; export const paramSelectConfig: Record = { dataset: { diff --git a/react-ui/src/components/ParameterSelect/index.tsx b/react-ui/src/components/ParameterSelect/index.tsx index 4beddf7f..cdae15ed 100644 --- a/react-ui/src/components/ParameterSelect/index.tsx +++ b/react-ui/src/components/ParameterSelect/index.tsx @@ -13,7 +13,7 @@ import { useCallback, useEffect, useMemo, useState } from 'react'; import FormInfo from '../FormInfo'; import { paramSelectConfig, type ParameterSelectDataType } from './config'; -export { type ParameterSelectDataType }; +export { ParameterSelectTypeList, type ParameterSelectDataType } from './config'; export type ParameterSelectObject = { value: any; diff --git a/react-ui/src/pages/Pipeline/components/PipelineNodeDrawer/index.tsx b/react-ui/src/pages/Pipeline/components/PipelineNodeDrawer/index.tsx index 0ceee5d5..c1341eb1 100644 --- a/react-ui/src/pages/Pipeline/components/PipelineNodeDrawer/index.tsx +++ b/react-ui/src/pages/Pipeline/components/PipelineNodeDrawer/index.tsx @@ -4,6 +4,7 @@ import ParameterInput, { requiredValidator } from '@/components/ParameterInput'; import ParameterSelect, { type ParameterSelectDataType, type ParameterSelectObject, + ParameterSelectTypeList, } from '@/components/ParameterSelect'; import ResourceSelectorModal, { ResourceSelectorType, @@ -43,17 +44,6 @@ type PipelineNodeParameterProps = { onFormChange: (data: PipelineNodeModelSerialize) => void; }; -// 自定义的下拉组件类型 -const parameterSelectList = [ - 'dataset', - 'model', - 'service', - 'resource', - 'remote-resource-type', - 'remote-image', - 'remote-resource', -]; - const PipelineNodeParameter = forwardRef(({ onFormChange }: PipelineNodeParameterProps, ref) => { const [form] = Form.useForm(); const [stagingItem, setStagingItem] = useState( @@ -402,7 +392,7 @@ const PipelineNodeParameter = forwardRef(({ onFormChange }: PipelineNodeParamete )} {item.value.type === ComponentType.Select && - (parameterSelectList.includes(item.value.item_type) ? ( + (ParameterSelectTypeList.includes(item.value.item_type as ParameterSelectDataType) ? (