Forráskód Böngészése

添加update更新tree

visuddhinanda 11 hónapja
szülő
commit
eb743cbdca
1 módosított fájl, 18 hozzáadás és 17 törlés
  1. 18 17
      dashboard-v4/dashboard/src/components/task/ProjectTask.tsx

+ 18 - 17
dashboard-v4/dashboard/src/components/task/ProjectTask.tsx

@@ -7,6 +7,24 @@ import { useState } from "react";
 import { ITaskData } from "../../components/api/task";
 import { useIntl } from "react-intl";
 
+// 更新 ITaskData[] 中的函数
+export function update(input: ITaskData[], target: ITaskData[]): void {
+  for (const newItem of input) {
+    const match = target.findIndex((item) => item.id === newItem.id);
+    if (match >= 0) {
+      // 更新当前项的属性
+      target[match] = newItem;
+    } else {
+      // 如果没有找到,递归检查子项
+      for (const item of target) {
+        if (item.children) {
+          update([newItem], item.children);
+        }
+      }
+    }
+  }
+}
+
 interface IWidget {
   studioName?: string;
   projectId?: string;
@@ -30,23 +48,6 @@ const ProjectTask = ({
     onChange && onChange(listData);
   };
 
-  // 更新 origin 中的函数
-  function update(input: ITaskData[], target: ITaskData[]): void {
-    for (const newItem of input) {
-      const match = target.findIndex((item) => item.id === newItem.id);
-      if (match >= 0) {
-        // 更新当前项的属性
-        target[match] = newItem;
-      } else {
-        // 如果没有找到,递归检查子项
-        for (const item of target) {
-          if (item.children) {
-            update([newItem], item.children);
-          }
-        }
-      }
-    }
-  }
   return (
     <>
       <Tabs