mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-30 19:21:54 +00:00
fix: node shape not reactive in vueNodes mode (#7302)
## Summary add node shape support in vueNodes fix https://github.com/Comfy-Org/ComfyUI_frontend/issues/7144 ## Screenshots (if applicable) https://github.com/user-attachments/assets/df8a4fa6-5686-435d-a814-4fe3990f7e69 ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-7302-fix-node-shape-not-reactive-in-vueNodes-mode-2c56d73d3650811c9ef5e4fe49c94f55) by [Unito](https://www.unito.io) --------- Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 97 KiB After Width: | Height: | Size: 100 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 42 KiB |
@@ -69,6 +69,7 @@ export interface VueNodeData {
|
|||||||
}
|
}
|
||||||
color?: string
|
color?: string
|
||||||
bgcolor?: string
|
bgcolor?: string
|
||||||
|
shape?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GraphNodeManager {
|
export interface GraphNodeManager {
|
||||||
@@ -234,7 +235,8 @@ export function useGraphNodeManager(graph: LGraph): GraphNodeManager {
|
|||||||
outputs: node.outputs ? [...node.outputs] : undefined,
|
outputs: node.outputs ? [...node.outputs] : undefined,
|
||||||
flags: node.flags ? { ...node.flags } : undefined,
|
flags: node.flags ? { ...node.flags } : undefined,
|
||||||
color: node.color || undefined,
|
color: node.color || undefined,
|
||||||
bgcolor: node.bgcolor || undefined
|
bgcolor: node.bgcolor || undefined,
|
||||||
|
shape: node.shape
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -571,6 +573,15 @@ export function useGraphNodeManager(graph: LGraph): GraphNodeManager {
|
|||||||
? propertyEvent.newValue
|
? propertyEvent.newValue
|
||||||
: undefined
|
: undefined
|
||||||
})
|
})
|
||||||
|
break
|
||||||
|
case 'shape':
|
||||||
|
vueNodeData.set(nodeId, {
|
||||||
|
...currentData,
|
||||||
|
shape:
|
||||||
|
typeof propertyEvent.newValue === 'number'
|
||||||
|
? propertyEvent.newValue
|
||||||
|
: undefined
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -495,6 +495,7 @@ export class LGraphNode
|
|||||||
}
|
}
|
||||||
|
|
||||||
set shape(v: RenderShape | 'default' | 'box' | 'round' | 'circle' | 'card') {
|
set shape(v: RenderShape | 'default' | 'box' | 'round' | 'circle' | 'card') {
|
||||||
|
const oldValue = this._shape
|
||||||
switch (v) {
|
switch (v) {
|
||||||
case 'default':
|
case 'default':
|
||||||
this._shape = undefined
|
this._shape = undefined
|
||||||
@@ -514,6 +515,14 @@ export class LGraphNode
|
|||||||
default:
|
default:
|
||||||
this._shape = v
|
this._shape = v
|
||||||
}
|
}
|
||||||
|
if (oldValue !== this._shape) {
|
||||||
|
this.graph?.trigger('node:property:changed', {
|
||||||
|
nodeId: this.id,
|
||||||
|
property: 'shape',
|
||||||
|
oldValue,
|
||||||
|
newValue: this._shape
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -11,7 +11,8 @@
|
|||||||
'bg-component-node-background lg-node absolute pb-1',
|
'bg-component-node-background lg-node absolute pb-1',
|
||||||
|
|
||||||
'contain-style contain-layout min-w-[225px] min-h-(--node-height) w-(--node-width)',
|
'contain-style contain-layout min-w-[225px] min-h-(--node-height) w-(--node-width)',
|
||||||
'rounded-2xl touch-none flex flex-col',
|
shapeClass,
|
||||||
|
'touch-none flex flex-col',
|
||||||
'border-1 border-solid border-component-node-border',
|
'border-1 border-solid border-component-node-border',
|
||||||
// hover (only when node should handle events)
|
// hover (only when node should handle events)
|
||||||
shouldHandleNodePointerEvents &&
|
shouldHandleNodePointerEvents &&
|
||||||
@@ -21,9 +22,9 @@
|
|||||||
outlineClass,
|
outlineClass,
|
||||||
cursorClass,
|
cursorClass,
|
||||||
{
|
{
|
||||||
'before:rounded-2xl before:pointer-events-none before:absolute before:bg-bypass/60 before:inset-0':
|
[`${beforeShapeClass} before:pointer-events-none before:absolute before:bg-bypass/60 before:inset-0`]:
|
||||||
bypassed,
|
bypassed,
|
||||||
'before:rounded-2xl before:pointer-events-none before:absolute before:inset-0':
|
[`${beforeShapeClass} before:pointer-events-none before:absolute before:inset-0`]:
|
||||||
muted,
|
muted,
|
||||||
'ring-4 ring-primary-500 bg-primary-500/10': isDraggingOver
|
'ring-4 ring-primary-500 bg-primary-500/10': isDraggingOver
|
||||||
},
|
},
|
||||||
@@ -140,7 +141,8 @@ import { st } from '@/i18n'
|
|||||||
import {
|
import {
|
||||||
LGraphCanvas,
|
LGraphCanvas,
|
||||||
LGraphEventMode,
|
LGraphEventMode,
|
||||||
LiteGraph
|
LiteGraph,
|
||||||
|
RenderShape
|
||||||
} from '@/lib/litegraph/src/litegraph'
|
} from '@/lib/litegraph/src/litegraph'
|
||||||
import { useSettingStore } from '@/platform/settings/settingStore'
|
import { useSettingStore } from '@/platform/settings/settingStore'
|
||||||
import { useTelemetry } from '@/platform/telemetry'
|
import { useTelemetry } from '@/platform/telemetry'
|
||||||
@@ -383,6 +385,28 @@ const cursorClass = computed(() => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const shapeClass = computed(() => {
|
||||||
|
switch (nodeData.shape) {
|
||||||
|
case RenderShape.BOX:
|
||||||
|
return 'rounded-none'
|
||||||
|
case RenderShape.CARD:
|
||||||
|
return 'rounded-tl-2xl rounded-br-2xl rounded-tr-none rounded-bl-none'
|
||||||
|
default:
|
||||||
|
return 'rounded-2xl'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const beforeShapeClass = computed(() => {
|
||||||
|
switch (nodeData.shape) {
|
||||||
|
case RenderShape.BOX:
|
||||||
|
return 'before:rounded-none'
|
||||||
|
case RenderShape.CARD:
|
||||||
|
return 'before:rounded-tl-2xl before:rounded-br-2xl before:rounded-tr-none before:rounded-bl-none'
|
||||||
|
default:
|
||||||
|
return 'before:rounded-2xl'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
// Event handlers
|
// Event handlers
|
||||||
const handleCollapse = () => {
|
const handleCollapse = () => {
|
||||||
handleNodeCollapse(nodeData.id, !isCollapsed.value)
|
handleNodeCollapse(nodeData.id, !isCollapsed.value)
|
||||||
|
|||||||
@@ -6,9 +6,9 @@
|
|||||||
v-else
|
v-else
|
||||||
:class="
|
:class="
|
||||||
cn(
|
cn(
|
||||||
'lg-node-header py-2 pl-2 pr-3 text-sm rounded-t-2xl w-full min-w-0',
|
'lg-node-header py-2 pl-2 pr-3 text-sm w-full min-w-0',
|
||||||
'text-node-component-header bg-node-component-header-surface',
|
'text-node-component-header bg-node-component-header-surface',
|
||||||
collapsed && 'rounded-2xl'
|
headerShapeClass
|
||||||
)
|
)
|
||||||
"
|
"
|
||||||
:style="headerStyle"
|
:style="headerStyle"
|
||||||
@@ -109,7 +109,7 @@ import type { VueNodeData } from '@/composables/graph/useGraphNodeManager'
|
|||||||
import { useErrorHandling } from '@/composables/useErrorHandling'
|
import { useErrorHandling } from '@/composables/useErrorHandling'
|
||||||
import { useFeatureFlags } from '@/composables/useFeatureFlags'
|
import { useFeatureFlags } from '@/composables/useFeatureFlags'
|
||||||
import { st } from '@/i18n'
|
import { st } from '@/i18n'
|
||||||
import { LGraphEventMode } from '@/lib/litegraph/src/litegraph'
|
import { LGraphEventMode, RenderShape } from '@/lib/litegraph/src/litegraph'
|
||||||
import { useSettingStore } from '@/platform/settings/settingStore'
|
import { useSettingStore } from '@/platform/settings/settingStore'
|
||||||
import NodeBadge from '@/renderer/extensions/vueNodes/components/NodeBadge.vue'
|
import NodeBadge from '@/renderer/extensions/vueNodes/components/NodeBadge.vue'
|
||||||
import { useNodeTooltips } from '@/renderer/extensions/vueNodes/composables/useNodeTooltips'
|
import { useNodeTooltips } from '@/renderer/extensions/vueNodes/composables/useNodeTooltips'
|
||||||
@@ -216,6 +216,28 @@ const nodeBadges = computed<NodeBadgeProps[]>(() =>
|
|||||||
)
|
)
|
||||||
const isPinned = computed(() => Boolean(nodeData?.flags?.pinned))
|
const isPinned = computed(() => Boolean(nodeData?.flags?.pinned))
|
||||||
const isApiNode = computed(() => Boolean(nodeData?.apiNode))
|
const isApiNode = computed(() => Boolean(nodeData?.apiNode))
|
||||||
|
|
||||||
|
const headerShapeClass = computed(() => {
|
||||||
|
if (collapsed) {
|
||||||
|
switch (nodeData?.shape) {
|
||||||
|
case RenderShape.BOX:
|
||||||
|
return 'rounded-none'
|
||||||
|
case RenderShape.CARD:
|
||||||
|
return 'rounded-tl-2xl rounded-br-2xl rounded-tr-none rounded-bl-none'
|
||||||
|
default:
|
||||||
|
return 'rounded-2xl'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
switch (nodeData?.shape) {
|
||||||
|
case RenderShape.BOX:
|
||||||
|
return 'rounded-t-none'
|
||||||
|
case RenderShape.CARD:
|
||||||
|
return 'rounded-tl-2xl rounded-tr-none'
|
||||||
|
default:
|
||||||
|
return 'rounded-t-2xl'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
// Subgraph detection
|
// Subgraph detection
|
||||||
const isSubgraphNode = computed(() => {
|
const isSubgraphNode = computed(() => {
|
||||||
if (!nodeData?.id) return false
|
if (!nodeData?.id) return false
|
||||||
|
|||||||
Reference in New Issue
Block a user