Skip to content

Commit 5ba95a6

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

File tree

12 files changed

+304
-218
lines changed

12 files changed

+304
-218
lines changed

docs/xflow/index.md

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ import schema from './schema/basic';
4646
import data from './data/basic';
4747

4848

49-
50-
const nodeMenus = [
49+
const settings = [
5150
{
5251
title: 'Input',
5352
type: 'Start',
53+
hidden: true,
5454
icon: {
5555
type: 'icon-start',
5656
bgColor: '#17B26A',
@@ -59,6 +59,7 @@ const nodeMenus = [
5959
{
6060
title: 'Output',
6161
type: 'End',
62+
hidden: true,
6263
icon: {
6364
type: 'icon-end',
6465
bgColor: '#F79009',
@@ -135,6 +136,30 @@ const nodeMenus = [
135136
type: 'icon-gongju',
136137
bgColor: '#2E90FA'
137138
}
139+
},
140+
{
141+
title: '工具',
142+
type: '_group',
143+
items: [
144+
{
145+
title: '代码执行',
146+
type: 'Code',
147+
description: '执行一段 Groovy 或 Python 或 NodeJS 代码实现自定义逻辑',
148+
icon: {
149+
type: 'icon-code',
150+
bgColor: '#2E90FA'
151+
}
152+
},
153+
{
154+
title: '工具',
155+
type: 'tool',
156+
description: '允许使用工具能力',
157+
icon: {
158+
type: 'icon-gongju',
159+
bgColor: '#2E90FA'
160+
}
161+
},
162+
]
138163
}
139164
];
140165

@@ -166,10 +191,12 @@ export default () => {
166191

167192
return (
168193
<div style={{ height: '600px' }}>
169-
<XFlow
170-
nodes={nodes}
171-
edges={edges}
172-
nodeMenus={nodeMenus}
194+
<XFlow
195+
initialValues={{ nodes, edges }}
196+
settings={settings}
197+
nodeSelector={{
198+
showSearch: true,
199+
}}
173200
/>
174201
</div>
175202
);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { useShallow } from 'zustand/react/shallow';
55
import produce from 'immer';
66
import { uuid } from '../../utils';
77
import useStore from '../../models/store';
8-
import NodeSelectPopover from '../NodeSelectPopover';
8+
import NodeSelectPopover from '../NodesPopover';
99
import './index.less';
1010

1111
export default memo((edge: any) => {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ import { Handle, Position, useReactFlow } from '@xyflow/react';
88
import useStore from '../../models/store';
99
import { capitalize, uuid } from '../../utils';
1010
import { ConfigContext } from '../../models/context';
11-
import NodeSelectPopover from '../NodeSelectPopover';
11+
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;
1616
const configCtx: any = useContext(ConfigContext);
17-
const NodeWidget = configCtx?.nodeWidgets[`${capitalize(type)}Node`];
17+
const NodeWidget = configCtx?.widgets[`${capitalize(type)}Node`];
1818

1919
const [isHovered, setIsHovered] = useState(false);
2020
const reactflow = useReactFlow();

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

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

packages/x-flow/src/components/NodeSelectPopover/index.less renamed to packages/x-flow/src/components/NodesMenu/index.less

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
1-
.fai-reactflow-addblock {
2-
min-height: 400px;
3-
.node-item {
1+
.xflow-node-menu{
2+
min-height: 340px;
3+
min-width: 150px;
4+
5+
.menu-group-title {
6+
padding: 0 10px;
7+
color: #667085;
8+
font-size: 12px;
9+
font-weight: 500;
10+
line-height: 24px;
11+
}
12+
13+
.menu-item {
414
height: 32px;
515
color: #101828;
616
padding: 0 10px;
@@ -9,7 +19,7 @@
919
cursor: pointer;
1020
}
1121

12-
.node-item:hover {
22+
.menu-item:hover {
1323
background-color: #f9fafb;
1424
border-radius: 8px;
1525
}
@@ -24,7 +34,7 @@
2434
}
2535
}
2636

27-
.node-info-tooltip {
37+
.xflow-node-menu-tooltip {
2838
width: 200px;
2939

3040
.title {

0 commit comments

Comments
 (0)