diff --git a/packages/designer/src/setters/router-setter.tsx b/packages/designer/src/setters/router-setter.tsx index ead1fe48..5cc5a368 100644 --- a/packages/designer/src/setters/router-setter.tsx +++ b/packages/designer/src/setters/router-setter.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import React, { useEffect, useState } from 'react'; import { Box } from 'coral-system'; import { Input, Radio } from 'antd'; import { isValidUrl } from '@music163/tango-helpers'; @@ -12,25 +12,32 @@ export function RouterSetter(props: FormItemComponentProps) { }); const [input, setInput] = useState(props.value); const { routeOptions } = useWorkspaceData(); + + const displayType = props.type || 'both'; + useEffect(() => { + displayType === 'router' ? setType('select') : setType('input'); + }, [displayType]); return ( - setType(e.target.value)} - > - 选择路由 - 自定义输入 - + {['both', 'router'].includes(displayType) && ( + setType(e.target.value)} + > + 选择路由 + 自定义输入 + + )} {type === 'select' && ( )} {type === 'input' && ( setInput(e.target.value)}