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) ? (