Skip to content

Commit

Permalink
✨ feat: 更新proflow配置的类型
Browse files Browse the repository at this point in the history
  • Loading branch information
jiangchu committed Oct 8, 2023
1 parent b914cd4 commit 3b06dde
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 26 deletions.
19 changes: 1 addition & 18 deletions src/ProFlow/constants.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ProFlowNode, ProFlowNodeData } from '@/constants';
import { Node } from 'reactflow';

export enum NodeSelect {
Expand All @@ -6,24 +7,6 @@ export enum NodeSelect {
WARNING = 'WARNING',
DEFAULT = 'DEFAULT',
}
export interface ProFlowNode {
id: string;
group?: boolean;
select?: NodeSelect;
data: ProFlowNodeData | ProFlowNode[];
}

export interface ProFlowNodeData {
title: string;
describe: string;
logo: string;
}

export interface ProFLowEdge {
id: string;
source: string;
target: string;
}

export interface InitialNode extends Node {
width?: number;
Expand Down
12 changes: 4 additions & 8 deletions src/ProFlow/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { useMemo, type CSSProperties, type MouseEvent as ReactMouseEvent } from 'react';
import ReactFlow, { Background, BackgroundVariant, Edge, Node, useEdgesState } from 'reactflow';
import { ProFlowController, RadiusEdge } from '../index';
import { ProFLowEdge, ProFlowNode } from './constants';
import ReactFlow, { Background, BackgroundVariant, Edge, Node } from 'reactflow';
import { ProFlowController, ProFlowEdge, ProFlowNode, RadiusEdge } from '../index';
import { convertMappingFrom, getRenderData } from './helper';
import { useStyles } from './styles';

Expand All @@ -12,7 +11,7 @@ interface ProFlowProps {
onPaneClick: (event: ReactMouseEvent) => void;
onNodeClick: (event: ReactMouseEvent, node: Node) => void;
nodes: ProFlowNode[];
edges: ProFLowEdge[];
edges: ProFlowEdge[];
className?: string;
style?: CSSProperties;
miniMap?: boolean;
Expand Down Expand Up @@ -40,10 +39,7 @@ const ProFlow: React.FC<Partial<ProFlowProps>> = (props) => {
};
}
}, [mapping]);
const [_edges] = useEdgesState(renderData.edges);

console.log(renderData.edges);
console.log(_edges);
// const [_edges] = useEdgesState(renderData.edges);

return (
<ReactFlow
Expand Down
14 changes: 14 additions & 0 deletions src/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,27 @@ export enum NodeSelect {
WARNING = 'WARNING',
DEFAULT = 'DEFAULT',
}

export enum EdgeType {
default = 'default',
radius = 'radius',
}

// 暴露给用户使用的Node配置
export interface ProFlowNode {
id: string;
group?: boolean;
select?: NodeSelect;
data: ProFlowNodeData | ProFlowNode[];
}

// 暴露给用户使用的Edge配置
export interface ProFlowEdge {
id: string;
source: string;
target: string;
type?: EdgeType;
}
export interface ProFlowNodeData {
title: string;
describe: string;
Expand Down

0 comments on commit 3b06dde

Please sign in to comment.