mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-30 11:11:53 +00:00
Attach isLeaf info (#260)
This commit is contained in:
@@ -99,9 +99,8 @@ const renderedRoot = computed(() => {
|
|||||||
return fillNodeInfo(root.value)
|
return fillNodeInfo(root.value)
|
||||||
})
|
})
|
||||||
const fillNodeInfo = (node: TreeNode): TreeNode => {
|
const fillNodeInfo = (node: TreeNode): TreeNode => {
|
||||||
const isLeaf = node.children === undefined || node.children.length === 0
|
|
||||||
const isExpanded = expandedKeys.value[node.key]
|
const isExpanded = expandedKeys.value[node.key]
|
||||||
const icon = isLeaf
|
const icon = node.leaf
|
||||||
? 'pi pi-circle-fill'
|
? 'pi pi-circle-fill'
|
||||||
: isExpanded
|
: isExpanded
|
||||||
? 'pi pi-folder-open'
|
? 'pi pi-folder-open'
|
||||||
@@ -112,8 +111,8 @@ const fillNodeInfo = (node: TreeNode): TreeNode => {
|
|||||||
...node,
|
...node,
|
||||||
icon,
|
icon,
|
||||||
children,
|
children,
|
||||||
type: isLeaf ? 'node' : 'folder',
|
type: node.leaf ? 'node' : 'folder',
|
||||||
totalNodes: isLeaf
|
totalNodes: node.leaf
|
||||||
? 1
|
? 1
|
||||||
: children.reduce((acc, child) => acc + child.totalNodes, 0)
|
: children.reduce((acc, child) => acc + child.totalNodes, 0)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -260,6 +260,7 @@ export const useNodeDefStore = defineStore('nodeDef', {
|
|||||||
const root: TreeNode = {
|
const root: TreeNode = {
|
||||||
key: 'root',
|
key: 'root',
|
||||||
label: 'Nodes',
|
label: 'Nodes',
|
||||||
|
leaf: false,
|
||||||
children: []
|
children: []
|
||||||
}
|
}
|
||||||
for (const nodeDef of Object.values(state.nodeDefsByName)) {
|
for (const nodeDef of Object.values(state.nodeDefsByName)) {
|
||||||
@@ -270,7 +271,7 @@ export const useNodeDefStore = defineStore('nodeDef', {
|
|||||||
key += `/${part}`
|
key += `/${part}`
|
||||||
let next = current.children.find((child) => child.label === part)
|
let next = current.children.find((child) => child.label === part)
|
||||||
if (!next) {
|
if (!next) {
|
||||||
next = { key, label: part, children: [] }
|
next = { key, label: part, children: [], leaf: false }
|
||||||
current.children.push(next)
|
current.children.push(next)
|
||||||
}
|
}
|
||||||
current = next
|
current = next
|
||||||
@@ -278,7 +279,8 @@ export const useNodeDefStore = defineStore('nodeDef', {
|
|||||||
current.children.push({
|
current.children.push({
|
||||||
label: nodeDef.display_name,
|
label: nodeDef.display_name,
|
||||||
data: nodeDef,
|
data: nodeDef,
|
||||||
key: `${key}/${nodeDef.name}`
|
key: `${key}/${nodeDef.name}`,
|
||||||
|
leaf: true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return root
|
return root
|
||||||
|
|||||||
Reference in New Issue
Block a user