fix: tool node fold (#2811)

* fix: tool node fold

* delete console
This commit is contained in:
heheer
2024-09-26 18:04:43 +08:00
committed by shilin66
parent 12645d49f5
commit 222d4112d7
2 changed files with 42 additions and 31 deletions

View File

@@ -34,8 +34,6 @@ const NodeTools = ({ data, selected }: NodeProps<FlowNodeItemType>) => {
text={t('common:core.workflow.tool.Select Tool')} text={t('common:core.workflow.tool.Select Tool')}
/> />
</Box> </Box>
<ToolSourceHandle />
</Box> </Box>
</NodeCard> </NodeCard>
); );

View File

@@ -9,7 +9,7 @@ import { useToast } from '@fastgpt/web/hooks/useToast';
import { FlowNodeTypeEnum } from '@fastgpt/global/core/workflow/node/constant'; import { FlowNodeTypeEnum } from '@fastgpt/global/core/workflow/node/constant';
import { useConfirm } from '@fastgpt/web/hooks/useConfirm'; import { useConfirm } from '@fastgpt/web/hooks/useConfirm';
import { LOGO_ICON } from '@fastgpt/global/common/system/constants'; import { LOGO_ICON } from '@fastgpt/global/common/system/constants';
import { ToolTargetHandle } from './Handle/ToolHandle'; import { ToolSourceHandle, ToolTargetHandle } from './Handle/ToolHandle';
import { useEditTextarea } from '@fastgpt/web/hooks/useEditTextarea'; import { useEditTextarea } from '@fastgpt/web/hooks/useEditTextarea';
import { ConnectionSourceHandle, ConnectionTargetHandle } from './Handle/ConnectionHandle'; import { ConnectionSourceHandle, ConnectionTargetHandle } from './Handle/ConnectionHandle';
import { useDebug } from '../../hooks/useDebug'; import { useDebug } from '../../hooks/useDebug';
@@ -165,6 +165,7 @@ const NodeCard = (props: Props) => {
{/* avatar and name */} {/* avatar and name */}
<Flex alignItems={'center'}> <Flex alignItems={'center'}>
{node?.flowNodeType !== FlowNodeTypeEnum.stopTool && (
<Box <Box
mr={2} mr={2}
cursor={'pointer'} cursor={'pointer'}
@@ -180,7 +181,12 @@ const NodeCard = (props: Props) => {
}} }}
> >
{!isFolded ? ( {!isFolded ? (
<MyIcon name={'core/chat/chevronDown'} w={'24px'} h={'24px'} color={'myGray.500'} /> <MyIcon
name={'core/chat/chevronDown'}
w={'24px'}
h={'24px'}
color={'myGray.500'}
/>
) : ( ) : (
<MyIcon <MyIcon
name={'core/chat/chevronRight'} name={'core/chat/chevronRight'}
@@ -190,6 +196,7 @@ const NodeCard = (props: Props) => {
/> />
)} )}
</Box> </Box>
)}
<Avatar src={avatar} borderRadius={'sm'} objectFit={'contain'} w={'30px'} h={'30px'} /> <Avatar src={avatar} borderRadius={'sm'} objectFit={'contain'} w={'30px'} h={'30px'} />
<Box ml={3} fontSize={'md'} fontWeight={'medium'}> <Box ml={3} fontSize={'md'} fontWeight={'medium'}>
{t(name as any)} {t(name as any)}
@@ -272,6 +279,8 @@ const NodeCard = (props: Props) => {
}, [ }, [
showToolHandle, showToolHandle,
nodeId, nodeId,
node?.flowNodeType,
isFolded,
avatar, avatar,
t, t,
name, name,
@@ -283,10 +292,9 @@ const NodeCard = (props: Props) => {
nodeList, nodeList,
intro, intro,
ConfirmSyncModal, ConfirmSyncModal,
onOpenCustomTitleModal,
onChangeNode, onChangeNode,
toast, onOpenCustomTitleModal,
isFolded toast
]); ]);
const RenderHandle = useMemo(() => { const RenderHandle = useMemo(() => {
return ( return (
@@ -296,6 +304,10 @@ const NodeCard = (props: Props) => {
</> </>
); );
}, [nodeId, isFolded]); }, [nodeId, isFolded]);
const RenderToolHandle = useMemo(
() => (node?.flowNodeType === FlowNodeTypeEnum.tools ? <ToolSourceHandle /> : null),
[node?.flowNodeType]
);
return ( return (
<Flex <Flex
@@ -337,6 +349,7 @@ const NodeCard = (props: Props) => {
{Header} {Header}
{!isFolded && children} {!isFolded && children}
{RenderHandle} {RenderHandle}
{RenderToolHandle}
<EditTitleModal maxLength={20} /> <EditTitleModal maxLength={20} />
</Flex> </Flex>