Skip to content

Commit

Permalink
feat: 代码优化
Browse files Browse the repository at this point in the history
  • Loading branch information
jifeng committed Apr 30, 2024
1 parent 3fb919d commit 2daa08b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/lib/components/node-wrapper/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ class NodeWrapper extends React.Component<INodeWrapperProps> {
} = this.props;

const { selectedData, activeLine } = context;
const isSelected = selectedData.nodes.find(item => item.id === data.id) !== undefined;
const isSelected =
selectedData.nodes.find(item => item.id === data.id) !== undefined;
return connectDragSource(
<div
id={data ? `topology-node-${data.id}` : ""}
Expand All @@ -232,7 +233,10 @@ class NodeWrapper extends React.Component<INodeWrapperProps> {
className="byai-topology-node-wrapper"
onClick={this.handleClick}
onContextMenu={this.handleRightClick}
onMouseDown={this.handleMouseDown}
onMouseDown={(e) => {
// @ts-ignore
this.handleMouseDown(e, isSelected);
}}
onMouseEnter={() => { onMouseEnter(data) }}
onMouseLeave={() => { onMouseLeave() }}>
{connectDragPreview(
Expand Down
3 changes: 1 addition & 2 deletions src/lib/components/topology/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ class Topology extends React.Component<ITopologyProps, ITopologyState> {
});
this.setContext(
{
selectedData: selectData
selectedData: selectData,
},
() => {
if (mode === SelectMode.BOX_SELECTION) {
Expand Down Expand Up @@ -2006,7 +2006,6 @@ class Topology extends React.Component<ITopologyProps, ITopologyState> {
}}
onClick={this.handleCanvasClick}
>

<Provider value={context}>
{this.renderNodes()}
{this.renderLines()}
Expand Down

0 comments on commit 2daa08b

Please sign in to comment.