mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-22 23:39:45 +00:00
[TS] Use custom TreeNode type (#3164)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import type { TreeNode } from 'primevue/treenode'
|
||||
import type { TreeNode } from '@/types/treeExplorerTypes'
|
||||
|
||||
export function buildTree<T>(items: T[], key: (item: T) => string[]): TreeNode {
|
||||
const root: TreeNode = {
|
||||
@@ -45,7 +45,7 @@ export function flattenTree<T>(tree: TreeNode): T[] {
|
||||
while (stack.length) {
|
||||
const node = stack.pop()!
|
||||
if (node.leaf && node.data) result.push(node.data)
|
||||
stack.push(...(node.children || []))
|
||||
stack.push(...(node.children ?? []))
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user