فهرست منبع

fix: 节点ID更换规则

kilnonedre 1 سال پیش
والد
کامیت
0a79fdfcea
5فایلهای تغییر یافته به همراه11 افزوده شده و 6 حذف شده
  1. 0 0
      dagtest2.dag
  2. 9 6
      packages/yili-dag/src/Dag.tsx
  3. 1 0
      untitled.dag
  4. 0 0
      untitled.txt
  5. 1 0
      untitled1.dag

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
dagtest2.dag


+ 9 - 6
packages/yili-dag/src/Dag.tsx

@@ -8,7 +8,7 @@ import ScriptNodeInfo from './ScriptNodeInfo';
 import OutputNodeInfo from './OutputNodeInfo';
 import ContextMenuView from './ContextMenu';
 import ReactDOM from 'react-dom';
-import { nanoid } from 'nanoid';
+// import { nanoid } from 'nanoid';
 import { signNodesSkip, DagToData } from './utils';
 import {
   executeDag,
@@ -696,13 +696,11 @@ export default class Dag extends React.Component<any, any> {
       if (dagJson?.graph) {
         graph.fromJSON(dagJson.graph);
         this.setState({
-          dagId:
-            dagJson?.dag_id ||
-            nanoid().replaceAll('-', 'a').replaceAll('_', 'b')
+          dagId: dagJson?.dag_id || nanoid()
         });
       } else {
         this.setState({
-          dagId: nanoid().replaceAll('-', 'a').replaceAll('_', 'b')
+          dagId: nanoid()
         });
       }
       this.refreshNodeStatus();
@@ -1124,7 +1122,7 @@ export default class Dag extends React.Component<any, any> {
 function initNodeData(graph: Graph, newNode: Node<Node.Properties>) {
   // 节点id
   newNode.data.id = newNode.id;
-  newNode.data.nodeId = nanoid().replaceAll('-', 'a').replaceAll('_', 'b');
+  newNode.data.nodeId = nanoid();
   newNode.data.nodeName = `node_${graph.getNodes().length + 1}`;
   switch (newNode.data.type) {
     case 'datasource':
@@ -1148,3 +1146,8 @@ function initNodeData(graph: Graph, newNode: Node<Node.Properties>) {
     default:
   }
 }
+
+// 节点ID
+function nanoid() {
+  return 'YL' + Date.now();
+}

+ 1 - 0
untitled.dag

@@ -0,0 +1 @@
+{"dag_id":"YL1678087053084","requirements":"e'y'teeyte","user_name":"XXX","user_id":1,"nodes_task_name":"dfs","nodes_task_id":123,"itermidate_data":["hdfs://host:port/uri"],"nodes":[{"id":"YL1678087055787","name":"node_1","op":"sql","data":{"inputs":{},"input_number":1,"script":""}}],"edges":[],"graph":{"cells":[{"position":{"x":260,"y":310},"size":{"width":180,"height":50},"view":"react-shape-view","shape":"dag-node","component":{"key":null,"ref":null,"props":{},"_owner":null,"_store":{}},"portMarkup":[{"tagName":"foreignObject","selector":"fo","children":[{"ns":"http://www.w3.org/1999/xhtml","tagName":"body","selector":"foBody","attrs":{"xmlns":"http://www.w3.org/1999/xhtml"},"style":{"width":"100%","height":"100%","background":"transparent"},"children":[{"tagName":"div","selector":"foContent","style":{"width":"100%","height":"100%"}}]}]}],"ports":{"groups":{"top":{"position":"top","attrs":{"fo":{"width":10,"height":10,"x":-5,"y":-5,"magnet":"true"}}},"bottom":{"position":"bottom","attrs":{"fo":{"width":10,"height":10,"x":-5,"y":-5,"magnet":"true"}}}},"items":[{"id":"input0","group":"top"},{"id":"r0","group":"bottom"}]},"id":"3edb588a-c7a3-4f69-8fe4-54fe8198aa8f","data":{"label":"sql","status":"failed","type":"script","id":"3edb588a-c7a3-4f69-8fe4-54fe8198aa8f","nodeId":"YL1678087055787","nodeName":"node_1","scriptText":"","outputNumber":1,"inputNumber":1},"zIndex":1}]}}

+ 0 - 0
untitled.txt


+ 1 - 0
untitled1.dag

@@ -0,0 +1 @@
+{"id":"uuid1","requirements":"","nodes":[],"edges":[]}

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است