支持virtual-virtual的父子关系

This commit is contained in:
Xu Chang 2025-05-04 21:26:56 +08:00
parent 3f7dd3db7b
commit cf6f7d0271
5 changed files with 13 additions and 5 deletions

View File

@ -247,6 +247,7 @@ declare class SingleNode<ED extends EntityDict & BaseEntityDict, T extends keyof
getParentFilter<T2 extends keyof ED>(childNode: ListNode<ED, keyof ED>, ignoreNewParent?: boolean): ED[T2]['Filter'] | undefined;
}
declare class VirtualNode<ED extends EntityDict & BaseEntityDict> extends Node<ED> {
protected parent?: VirtualNode<ED>;
protected children: Record<string, SingleNode<ED, keyof ED> | ListNode<ED, keyof ED> | VirtualNode<ED>>;
constructor(fullPath: string, path?: string, parent?: VirtualNode<ED>, stale?: boolean);
getModiOperations(): Array<{
@ -258,7 +259,7 @@ declare class VirtualNode<ED extends EntityDict & BaseEntityDict> extends Node<E
addChild(path: string, child: SingleNode<ED, keyof ED> | ListNode<ED, keyof ED> | VirtualNode<ED>): void;
removeChild(path: string): void;
getChild(path: string): VirtualNode<ED> | SingleNode<ED, keyof ED> | ListNode<ED, keyof ED>;
getParent(): undefined;
getParent(): VirtualNode<ED> | undefined;
destroy(): void;
getFreshValue(): undefined;
refresh(): Promise<void>;

View File

@ -1722,6 +1722,7 @@ class SingleNode extends EntityNode {
}
}
class VirtualNode extends Node {
parent;
children;
constructor(fullPath, path, parent, stale) {
super(fullPath);
@ -1729,6 +1730,7 @@ class VirtualNode extends Node {
this.stale = stale;
if (parent) {
parent.addChild(path, this);
this.parent = parent;
}
}
getModiOperations() {
@ -1772,7 +1774,7 @@ class VirtualNode extends Node {
return this.children[path];
}
getParent() {
return undefined;
return this.parent;
}
destroy() {
for (const k in this.children) {

View File

@ -247,6 +247,7 @@ declare class SingleNode<ED extends EntityDict & BaseEntityDict, T extends keyof
getParentFilter<T2 extends keyof ED>(childNode: ListNode<ED, keyof ED>, ignoreNewParent?: boolean): ED[T2]['Filter'] | undefined;
}
declare class VirtualNode<ED extends EntityDict & BaseEntityDict> extends Node<ED> {
protected parent?: VirtualNode<ED>;
protected children: Record<string, SingleNode<ED, keyof ED> | ListNode<ED, keyof ED> | VirtualNode<ED>>;
constructor(fullPath: string, path?: string, parent?: VirtualNode<ED>, stale?: boolean);
getModiOperations(): Array<{
@ -258,7 +259,7 @@ declare class VirtualNode<ED extends EntityDict & BaseEntityDict> extends Node<E
addChild(path: string, child: SingleNode<ED, keyof ED> | ListNode<ED, keyof ED> | VirtualNode<ED>): void;
removeChild(path: string): void;
getChild(path: string): VirtualNode<ED> | SingleNode<ED, keyof ED> | ListNode<ED, keyof ED>;
getParent(): undefined;
getParent(): VirtualNode<ED> | undefined;
destroy(): void;
getFreshValue(): undefined;
refresh(): Promise<void>;

View File

@ -1725,6 +1725,7 @@ class SingleNode extends EntityNode {
}
}
class VirtualNode extends Node {
parent;
children;
constructor(fullPath, path, parent, stale) {
super(fullPath);
@ -1732,6 +1733,7 @@ class VirtualNode extends Node {
this.stale = stale;
if (parent) {
parent.addChild(path, this);
this.parent = parent;
}
}
getModiOperations() {
@ -1775,7 +1777,7 @@ class VirtualNode extends Node {
return this.children[path];
}
getParent() {
return undefined;
return this.parent;
}
destroy() {
for (const k in this.children) {

View File

@ -2058,6 +2058,7 @@ class SingleNode<ED extends EntityDict & BaseEntityDict,
}
class VirtualNode<ED extends EntityDict & BaseEntityDict> extends Node<ED> {
protected parent?: VirtualNode<ED>;
protected children: Record<string, SingleNode<ED, keyof ED> | ListNode<ED, keyof ED> | VirtualNode<ED>>;
constructor(fullPath: string, path?: string, parent?: VirtualNode<ED>, stale?: boolean) {
super(fullPath);
@ -2065,6 +2066,7 @@ class VirtualNode<ED extends EntityDict & BaseEntityDict> extends Node<ED> {
this.stale = stale;
if (parent) {
parent.addChild(path!, this);
this.parent = parent;
}
}
@ -2116,7 +2118,7 @@ class VirtualNode<ED extends EntityDict & BaseEntityDict> extends Node<ED> {
return this.children[path];
}
getParent() {
return undefined;
return this.parent;
}
destroy() {
for (const k in this.children) {