Skip to content

Commit 7799ad9

Browse files
author
昔梦
committed
feat:弹窗的描述内容改为可配置
1 parent 72eeb9f commit 7799ad9

File tree

6 files changed

+29
-26
lines changed

6 files changed

+29
-26
lines changed

docs/xflow/api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ title: API
3737
| title | 节点名称 | `string` | |
3838
| type | 节点类型 | `string` | |
3939
| hidden | 是否在配置面板中显示节点 | `boolean` | false |
40+
| hideDesc | 是否在配置面板中显示节点的描述信息 | `boolean` | false |
4041
| targetHandleHidden | 是否隐藏左侧输入连接头 | `boolean` | false |
4142
| sourceHandleHidden | 是否隐藏右侧输出连接头 | `boolean` | false |
4243
| icon | 节点的图标配置 | `{type:string;bgColor:string}` | |

docs/xflow/schema/custom-settings.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export default [
5959
type: 'icon-model',
6060
bgColor: '#6172F3',
6161
},
62+
hideDesc:true // 隐藏配置面板描述信息
6263
},
6364
{
6465
title: 'Prompt',

packages/x-flow/src/components/PanelContainer/index.less

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
border-color: #fff;
5757
}
5858
textarea {
59-
margin: 12px 0;
59+
margin-top: 12px;
6060
}
6161
}
6262

@@ -122,4 +122,4 @@
122122
font-size: 12px;
123123
}
124124
}
125-
}
125+
}

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

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ const Panel: FC<IPanelProps> = (props: IPanelProps) => {
3939
const isDisabled = ['Input', 'Output'].includes(nodeType) || disabled;
4040
const [descVal, setDescVal] = useState(data?.desc);
4141
const [titleVal, setTitleVal] = useState(data?.title || nodeSetting?.title);
42+
const { hideDesc, nodeConfigPanelWidth } = nodeSetting;
4243

4344
// const description = getDescription(nodeType, props.description);
44-
4545
const handleNodeValueChange = debounce((data: any) => {
4646
const newNodes = produce(nodes, draft => {
4747
let node = null;
@@ -72,9 +72,10 @@ const Panel: FC<IPanelProps> = (props: IPanelProps) => {
7272
getContainer={false}
7373
rootClassName="custom-node-panel"
7474
open={true}
75-
width={nodeSetting?.nodeConfigPanelWidth || configPanelWidth || 400} // 改为配置的width 节点的width > 全局的width> 默认 400
75+
width={nodeConfigPanelWidth || configPanelWidth || 400} // 改为配置的width 节点的width > 全局的width> 默认 400
7676
mask={false}
7777
onClose={onClose}
78+
headerStyle={{ paddingBottom: '12px' }}
7879
title={
7980
<>
8081
<div className="title-box">
@@ -93,8 +94,7 @@ const Panel: FC<IPanelProps> = (props: IPanelProps) => {
9394
) : (
9495
<Input
9596
style={{ width: '100%' }}
96-
// defaultValue={data?.title || nodeSetting?.title}
97-
value={titleVal} // || nodeSetting?.title
97+
value={titleVal}
9898
onChange={e => {
9999
setTitleVal(e.target.value);
100100
handleNodeValueChange({ title: e.target.value });
@@ -119,23 +119,23 @@ const Panel: FC<IPanelProps> = (props: IPanelProps) => {
119119
</Space>
120120
</div>
121121
</div>
122-
<div className="desc-box">
123-
{isDisabled ? (
124-
description
125-
) : (
126-
<Input.TextArea
127-
placeholder="添加描述..."
128-
autoSize={{ minRows: 1 }}
129-
value={descVal}
130-
// value={data?.desc}
131-
// defaultValue={description}
132-
onChange={e => {
133-
setDescVal(e.target.value);
134-
handleNodeValueChange({ desc: e.target.value });
135-
}}
136-
/>
137-
)}
138-
</div>
122+
{!hideDesc && (
123+
<div className="desc-box">
124+
{isDisabled ? (
125+
description
126+
) : (
127+
<Input.TextArea
128+
placeholder="添加描述..."
129+
autoSize={{ minRows: 1 }}
130+
value={descVal}
131+
onChange={e => {
132+
setDescVal(e.target.value);
133+
handleNodeValueChange({ desc: e.target.value });
134+
}}
135+
/>
136+
)}
137+
</div>
138+
)}
139139
</>
140140
}
141141
>

packages/x-flow/src/nodes/node-switch/SwitchBuildInNodeWidget.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Flex, Typography } from 'antd';
1+
import { Space, Typography } from 'antd';
22
import React, { memo } from 'react';
33
import SourceHandle from '../../components/CustomNode/sourceHandle';
44
import './index.less';
@@ -17,7 +17,7 @@ export default memo((props: any) => {
1717
} = props;
1818

1919
return (
20-
<Flex vertical className="node-switch-widget" gap={5}>
20+
<Space direction='vertical' className="node-switch-widget" size={5}>
2121
{(data?.list || [{}])?.map((item, index) => (
2222
<div className="node-switch-widget-item" key={index}>
2323
<div className="item-header">
@@ -75,6 +75,6 @@ export default memo((props: any) => {
7575
/>
7676
</div>
7777
</div>
78-
</Flex>
78+
</Space>
7979
);
8080
});

packages/x-flow/src/nodes/node-switch/index.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
}
2828

2929
.node-switch-widget {
30+
width: 100%;
3031

3132
.item-header {
3233
position: relative;

0 commit comments

Comments
 (0)