hookehuyr

fix 修复为节点自定义ID后,节点和连接线显示不正常的问题

...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
2 <div class="app" style="height: 100vh"> 2 <div class="app" style="height: 100vh">
3 <vue-flow-editor 3 <vue-flow-editor
4 ref="editor" 4 ref="editor"
5 - menuWidth="180px" 5 + menuWidth="200px"
6 modelWidth="300px" 6 modelWidth="300px"
7 :data="state.data" 7 :data="state.data"
8 :grid="showGrid" 8 :grid="showGrid"
...@@ -1004,6 +1004,11 @@ export default { ...@@ -1004,6 +1004,11 @@ export default {
1004 } 1004 }
1005 } 1005 }
1006 } 1006 }
1007 +
1008 + // TODO: 测试更新ID, 需要在添加前更新ID,不然会导致添加连接线时ID不一致。
1009 + model.id = String(new Date().getTime());
1010 + editor.updateModel(model);
1011 + state.data.nodes = editor.editorState.graph.save().nodes
1007 } 1012 }
1008 } 1013 }
1009 1014
...@@ -1016,9 +1021,6 @@ export default { ...@@ -1016,9 +1021,6 @@ export default {
1016 function handleAfterAdd(model: myObj, type: string) { 1021 function handleAfterAdd(model: myObj, type: string) {
1017 if (type === 'node') { 1022 if (type === 'node') {
1018 console.log(`新增节点`) 1023 console.log(`新增节点`)
1019 - // TODO: 测试更新ID,窗口变化时连接线会消失,但是只有单独操作一次的时候才会发生,如果多次生成连接线不会发生。
1020 - model.id = String(new Date().getTime());
1021 - editor.updateModel(model);
1022 state.data.nodes = editor.editorState.graph.save().nodes 1024 state.data.nodes = editor.editorState.graph.save().nodes
1023 } 1025 }
1024 if (type === 'edge') { 1026 if (type === 'edge') {
......