فهرست منبع

fix(tree): prepareInsert计算问题

vian 5 سال پیش
والد
کامیت
194d5a3609
2فایلهای تغییر یافته به همراه5 افزوده شده و 3 حذف شده
  1. 1 1
      tree/package.json
  2. 4 2
      tree/src/tree.ts

+ 1 - 1
tree/package.json

@@ -1,6 +1,6 @@
 {
   "name": "@sc/tree",
-  "version": "1.0.3",
+  "version": "1.0.4",
   "description": "a template for npm package coding",
   "main": "./dist/index.cjs.js",
   "module": "./dist/index.esm.js",

+ 4 - 2
tree/src/tree.ts

@@ -270,13 +270,15 @@ export class Tree {
         insertParentMap[item.parentID] || (insertParentMap[item.parentID] = [])
       ).push(item);
     });
+    const combineMap: ParentMap = {};
     Object.entries(insertParentMap).forEach(([parentID, insertItems]) => {
       const items = this.parentMap[parentID];
+      combineMap[parentID] = [...insertParentMap[parentID]];
       if (items) {
-        insertParentMap[parentID].push(...items);
+        combineMap[parentID].push(...items);
       }
       // 重新排序
-      const combineItems = insertParentMap[parentID];
+      const combineItems = combineMap[parentID];
       Tree.sort(combineItems);
       combineItems.forEach((item, index) => {
         // 插入数据重新赋值