diff --git a/.vscode/settings.json b/.vscode/settings.json index 86eefae2..22614a38 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,5 +3,6 @@ "editor.codeActionsOnSave": { "source.fixAll.eslint": true }, - "editor.formatOnSave": false + "editor.formatOnSave": false, + "typescript.tsdk": "node_modules/typescript/lib" } diff --git a/src/client/logic/components/tree.ts b/src/client/logic/components/tree.ts index ca77eed3..3016d3d2 100644 --- a/src/client/logic/components/tree.ts +++ b/src/client/logic/components/tree.ts @@ -159,11 +159,14 @@ export class ComponentWalker { instance: null, } + const uids: number[] = [] + // capture children if (depth < this.maxDepth || (instance.type as any).__isKeepAlive || parents.some(parent => (parent.type as any).__isKeepAlive)) { treeNode.children = await Promise.all(children .map((child, index, list) => this.capture(child, list, depth + 1)) .filter(Boolean)) + uids.push(...treeNode.children.map((child: any) => child.uid)) } // keep-alive @@ -171,7 +174,8 @@ export class ComponentWalker { const cachedComponents = this.getKeepAliveCachedInstances(instance) for (const cachedChild of cachedComponents) { const node = await this.capture({ ...cachedChild, isDeactivated: true }, [], depth + 1) - if (node) + const uid = node.uid + if (node && !uids.includes(uid)) treeNode.children.push(node) } }