Skip to content

Commit

Permalink
fix:单点调试修改
Browse files Browse the repository at this point in the history
  • Loading branch information
昔梦 committed Jan 9, 2025
1 parent fe183b7 commit 7b6ec0d
Showing 5 changed files with 18 additions and 11 deletions.
3 changes: 2 additions & 1 deletion docs/xflow/api.md
Original file line number Diff line number Diff line change
@@ -20,7 +20,6 @@ title: API
| onNodeClick | 节点点击事件 | `NodeMouseHandler` | |
| antdVersion | antd 的版本 | `V4 \| V5` | `V5` |
| readOnly | 只读模式 | `boolean` | `false` |
| onTesting | 单点调试方法 | `() => void` | |


## TNodePanel
@@ -103,6 +102,8 @@ title: API
| nodePanel | 自定义节点的面板配置信息 | [TNodePanel](#tnodepanel) | |
| switchExtra | 条件节点属性配置 | [TSwitchExtra](#tswitchextra) | |
| parallelExtra | 并行节点属性配置 | [TParallelExtra](#tparallelextra) | |
| onTesting | 节点的单点调试方法 | `(node,nodes) => void` | |




3 changes: 3 additions & 0 deletions docs/xflow/demo/nodeSetting/data.tsx
Original file line number Diff line number Diff line change
@@ -114,6 +114,9 @@ export const settings = [
type: 'icon-switch',
bgColor: '#06AED4',
},
onTesting: (node, nodes) => {
console.log("单点调试",node,nodes)
},
},
{
title: '工具',
17 changes: 12 additions & 5 deletions packages/x-flow/src/components/PanelContainer/index.tsx
Original file line number Diff line number Diff line change
@@ -47,7 +47,6 @@ const Panel: FC<IPanelProps> = (props: IPanelProps) => {
globalConfig,
antdVersion,
readOnly,
onTesting,
}: any = useContext(ConfigContext);
const nodeSetting = settingMap[nodeType] || {};
const { nodes, setNodes } = useStore(
@@ -60,7 +59,7 @@ const Panel: FC<IPanelProps> = (props: IPanelProps) => {
const isDisabled = ['Input', 'Output'].includes(nodeType) || disabled;
const [descVal, setDescVal] = useState(data?.desc);
const [titleVal, setTitleVal] = useState(data?.title || nodeSetting?.title);
const { nodePanel, iconSvg } = nodeSetting;
const { nodePanel, iconSvg, onTesting } = nodeSetting;
const hideDesc =
nodePanel?.hideDesc ?? globalConfig?.nodePanel?.hideDesc ?? false;
const isShowStatusPanel = Boolean(node?._status && openLogPanel);
@@ -152,7 +151,15 @@ const Panel: FC<IPanelProps> = (props: IPanelProps) => {
<Space size={[4, 4]}>
{!isDisabled && onTesting && (
<>
<IconView type="icon-yunhang" style={{ fontSize: 16 }} />
<IconView
type="icon-yunhang"
onClick={() => {
const n =
nodes?.find(item => item?.id === node?.id) || {};
onTesting(n, nodes);
}}
style={{ fontSize: 16 }}
/>
<Divider type="vertical" />
</>
)}
@@ -167,7 +174,7 @@ const Panel: FC<IPanelProps> = (props: IPanelProps) => {
</div>
{!hideDesc && (
<div className="desc-box">
{isDisabled ? (
{isDisabled ? (
description
) : (
<Input.TextArea
@@ -178,7 +185,7 @@ const Panel: FC<IPanelProps> = (props: IPanelProps) => {
setDescVal(e.target.value);
handleNodeValueChange({ desc: e.target.value });
}}
disabled={readOnly}
disabled={readOnly}
/>
)}
</div>
4 changes: 1 addition & 3 deletions packages/x-flow/src/types.ts
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@ export interface TNodeItem {
};
disabledCopy?: boolean;
disabledDelete?: boolean;

onTesting: (node,nodes) => void;// 单点调试方法
}

export interface TNodeGroup {
@@ -134,8 +134,6 @@ export interface FlowProps {
onNodeClick?: NodeMouseHandler;
onMenuItemClick?: (itemInfo: ItemInfo, defaultAction: () => void) => void;
clickAddNode?:(type:string,nodeItem:TNodeItem,addNode:(initData?:Record<string,any>)=>void)=>void
// 单点调试方法
onTesting?: () => void;// 单点调试方法
}
interface ItemInfo {
key: 'copy' | 'paste' | 'delete' | string;
2 changes: 0 additions & 2 deletions packages/x-flow/src/withProvider.tsx
Original file line number Diff line number Diff line change
@@ -33,7 +33,6 @@ export default function withProvider<T>(
antdVersion ='V5',
readOnly,
clickAddNode,
onTesting,
...restProps
} = props;
const settingMap = useMemo(() => {
@@ -66,7 +65,6 @@ export default function withProvider<T>(
...defaultWidgets,
...widgets,
},
onTesting
};

return (

0 comments on commit 7b6ec0d

Please sign in to comment.