Skip to content

Commit 093805b

Browse files
committed
🐛 修复associationList顺序问题
1 parent 64140e3 commit 093805b

File tree

5 files changed

+10
-11
lines changed

5 files changed

+10
-11
lines changed

app/src/core/render/canvas2d/entityRenderer/edge/EdgeRenderer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ export class EdgeRenderer {
186186
}
187187
if (edge.target.isHiddenBySectionCollapse) {
188188
return new LineEdge(this.project, {
189-
associationList: [this.getMinNonCollapseParentSection(edge.target), edge.source],
189+
associationList: [edge.source, this.getMinNonCollapseParentSection(edge.target)],
190190
text: edge.text,
191191
uuid: edge.uuid,
192192
});

app/src/core/stage/ProjectUpgrader.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Serialized } from "@/types/node";
2+
import { toast } from "sonner";
23
import { v4 as uuidv4 } from "uuid";
34
import { ConnectableEntity } from "./stageObject/abstract/ConnectableEntity";
45

@@ -385,7 +386,7 @@ export namespace ProjectUpgrader {
385386
const toNode = uuidMap.get(toUUID);
386387

387388
if (fromNode === undefined || toNode === undefined) {
388-
console.warn(`关联边的节点不存在`);
389+
toast.warning(`边 ${association.uuid} 关联的节点不存在: ${fromUUID} -> ${toUUID}`);
389390
continue;
390391
}
391392

app/src/core/stage/stageManager/concreteMethods/StageNodeConnector.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export class NodeConnector {
5353
return;
5454
}
5555
const newEdge = new LineEdge(this.project, {
56-
associationList: [toNode, fromNode],
56+
associationList: [fromNode, toNode],
5757
text,
5858
targetRectangleRate: new Vector(...(targetRectRate || [0.5, 0.5])),
5959
sourceRectangleRate: new Vector(...(sourceRectRate || [0.5, 0.5])),

app/src/core/stage/stageObject/abstract/Association.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,21 @@ export abstract class ConnectableAssociation extends Association {
2323
public override associationList: ConnectableEntity[] = [];
2424

2525
public reverse() {
26-
const temp = this.associationList[0];
27-
this.associationList[0] = this.associationList[1];
28-
this.associationList[1] = temp;
26+
this.associationList.reverse();
2927
}
3028

3129
get target(): ConnectableEntity {
32-
return this.associationList[0];
30+
return this.associationList[1];
3331
}
3432

3533
set target(value: ConnectableEntity) {
36-
this.associationList[0] = value;
34+
this.associationList[1] = value;
3735
}
3836

3937
get source(): ConnectableEntity {
40-
return this.associationList[1];
38+
return this.associationList[0];
4139
}
4240
set source(value: ConnectableEntity) {
43-
this.associationList[1] = value;
41+
this.associationList[0] = value;
4442
}
4543
}

app/src/core/stage/stageObject/association/LineEdge.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export class LineEdge extends Edge {
6262
// warn: 暂时无引用
6363
static fromTwoEntity(project: Project, source: ConnectableEntity, target: ConnectableEntity): LineEdge {
6464
const result = new LineEdge(project, {
65-
associationList: [target, source],
65+
associationList: [source, target],
6666
});
6767
return result;
6868
}

0 commit comments

Comments
 (0)