hookehuyr

优化显示:点击节点时,选中所有与之相连的边

...@@ -35,6 +35,7 @@ export function clickSelect(G6) { ...@@ -35,6 +35,7 @@ export function clickSelect(G6) {
35 const autoPaint = graph.get('autoPaint'); 35 const autoPaint = graph.get('autoPaint');
36 graph.setAutoPaint(false); 36 graph.setAutoPaint(false);
37 37
38 +
38 // 当前是否选择有变化 39 // 当前是否选择有变化
39 let selectChangeFlag = false 40 let selectChangeFlag = false
40 41
...@@ -49,7 +50,19 @@ export function clickSelect(G6) { ...@@ -49,7 +50,19 @@ export function clickSelect(G6) {
49 } 50 }
50 } 51 }
51 }) 52 })
53 +
52 } 54 }
55 +
56 + // 点击节点时,选中所有与之相连的边
57 + if (item.get('type') === 'node') {
58 + selectChangeFlag = true
59 + item.getEdges().forEach(edge => {
60 + graph.setItemState(edge, SELECTED_STATE, true);
61 + });
62 + } else {
63 + this.onCanvasClick();
64 + }
65 +
53 if (item.hasState(SELECTED_STATE)) { 66 if (item.hasState(SELECTED_STATE)) {
54 return 67 return
55 } else { 68 } else {
...@@ -59,6 +72,7 @@ export function clickSelect(G6) { ...@@ -59,6 +72,7 @@ export function clickSelect(G6) {
59 } 72 }
60 graph.emit('nodeselectchange', {target: item, select: true}); 73 graph.emit('nodeselectchange', {target: item, select: true});
61 } 74 }
75 +
62 if (selectChangeFlag) { 76 if (selectChangeFlag) {
63 this.emitSelectChange() 77 this.emitSelectChange()
64 } 78 }
......