Explorar o código

feat(tree): 获取最后子节点序列号

zhangweicheng %!s(int64=5) %!d(string=hai) anos
pai
achega
05f533664c
Modificáronse 2 ficheiros con 7 adicións e 1 borrados
  1. 1 1
      tree/package.json
  2. 6 0
      tree/src/nodeCtx.ts

+ 1 - 1
tree/package.json

@@ -1,6 +1,6 @@
 {
   "name": "@sc/tree",
-  "version": "1.0.14",
+  "version": "1.0.15",
   "description": "通用树",
   "main": "./dist/index.cjs.js",
   "module": "./dist/index.esm.js",

+ 6 - 0
tree/src/nodeCtx.ts

@@ -93,6 +93,12 @@ export class NodeContext<T = any> {
     return children[children.length - 1] || null;
   }
 
+  latestChildSeq(): number {
+    const latestChild = this.lastChild();
+    if (latestChild) return latestChild.seq;
+    return 0;
+  }
+
   // 获取节点后代(包含嵌套子项)
   posterity(): (TreeNode & T)[] {
     const posterity: (TreeNode & T)[] = [];