Skip to content

Commit 69a25d7

Browse files
author
zhanbo.lh
committed
feat: 增加 schema 配置
1 parent 5ba95a6 commit 69a25d7

File tree

6 files changed

+46
-547
lines changed

6 files changed

+46
-547
lines changed

docs/xflow/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ const settings = [
5151
title: 'Input',
5252
type: 'Start',
5353
hidden: true,
54+
targetHandleHidden: true,
5455
icon: {
5556
type: 'icon-start',
5657
bgColor: '#17B26A',
@@ -60,6 +61,7 @@ const settings = [
6061
title: 'Output',
6162
type: 'End',
6263
hidden: true,
64+
sourceHandleHidden: true,
6365
icon: {
6466
type: 'icon-end',
6567
bgColor: '#F79009',

packages/x-flow/src/components/CustomNode/index.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ import classNames from 'classnames';
55
import produce from 'immer';
66
import { useShallow } from 'zustand/react/shallow';
77
import { Handle, Position, useReactFlow } from '@xyflow/react';
8-
import useStore from '../../models/store';
98
import { capitalize, uuid } from '../../utils';
9+
import useStore from '../../models/store';
1010
import { ConfigContext } from '../../models/context';
1111
import NodeSelectPopover from '../NodesPopover';
1212
import './index.less';
1313

1414
export default memo((props: any) => {
1515
const { id, type, data, layout, isConnectable, selected, onClick } = props;
16-
const configCtx: any = useContext(ConfigContext);
17-
const NodeWidget = configCtx?.widgets[`${capitalize(type)}Node`];
16+
const { widgets, settingMap } = useContext(ConfigContext);
17+
const NodeWidget = widgets[`${capitalize(type)}Node`];
1818

1919
const [isHovered, setIsHovered] = useState(false);
2020
const reactflow = useReactFlow();
@@ -60,14 +60,16 @@ export default memo((props: any) => {
6060
setEdges(newEdges);
6161
};
6262

63-
6463
let targetPosition = Position.Left;
6564
let sourcePosition = Position.Right;
6665
if (layout === 'TB') {
6766
targetPosition = Position.Top;
6867
sourcePosition = Position.Bottom;
6968
}
7069

70+
console.log(settingMap, 'settingMap=====')
71+
72+
7173
return (
7274
<div
7375
className={classNames('xflow-node-container', {
@@ -77,7 +79,7 @@ export default memo((props: any) => {
7779
onMouseEnter={() => setIsHovered(true)}
7880
onMouseLeave={() => setIsHovered(false)}
7981
>
80-
{ (
82+
{!settingMap?.[type]?.targetHandleHidden && (
8183
<Handle
8284
type='target'
8385
position={targetPosition}
@@ -90,7 +92,7 @@ export default memo((props: any) => {
9092
data={data}
9193
onClick={() => onClick(data)}
9294
/>
93-
{(
95+
{!settingMap?.[type]?.sourceHandleHidden && (
9496
<Handle
9597
type='source'
9698
position={sourcePosition}

packages/x-flow/src/components/CustomNode/utils.ts

Lines changed: 0 additions & 264 deletions
This file was deleted.

0 commit comments

Comments
 (0)