mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-30 11:11:53 +00:00
[Refactor] Use litegraph LGraphNode.strokeStyles API (#3278)
This commit is contained in:
8
package-lock.json
generated
8
package-lock.json
generated
@@ -12,7 +12,7 @@
|
|||||||
"@alloc/quick-lru": "^5.2.0",
|
"@alloc/quick-lru": "^5.2.0",
|
||||||
"@atlaskit/pragmatic-drag-and-drop": "^1.3.1",
|
"@atlaskit/pragmatic-drag-and-drop": "^1.3.1",
|
||||||
"@comfyorg/comfyui-electron-types": "^0.4.31",
|
"@comfyorg/comfyui-electron-types": "^0.4.31",
|
||||||
"@comfyorg/litegraph": "^0.11.5",
|
"@comfyorg/litegraph": "^0.11.6",
|
||||||
"@primevue/forms": "^4.2.5",
|
"@primevue/forms": "^4.2.5",
|
||||||
"@primevue/themes": "^4.2.5",
|
"@primevue/themes": "^4.2.5",
|
||||||
"@sentry/vue": "^8.48.0",
|
"@sentry/vue": "^8.48.0",
|
||||||
@@ -478,9 +478,9 @@
|
|||||||
"license": "GPL-3.0-only"
|
"license": "GPL-3.0-only"
|
||||||
},
|
},
|
||||||
"node_modules/@comfyorg/litegraph": {
|
"node_modules/@comfyorg/litegraph": {
|
||||||
"version": "0.11.5",
|
"version": "0.11.6",
|
||||||
"resolved": "https://registry.npmjs.org/@comfyorg/litegraph/-/litegraph-0.11.5.tgz",
|
"resolved": "https://registry.npmjs.org/@comfyorg/litegraph/-/litegraph-0.11.6.tgz",
|
||||||
"integrity": "sha512-GBNloRNLEI/R+7zFcrXauMND1VJAMYqjheX6hcbqucCzSHBNlkcJnbhstvILSPIuv0GP1tEgzN4EDe5JtKIqoQ==",
|
"integrity": "sha512-X2VuqX8ipX/49WeaQpJ03NTb0lHR91KG2bPaMokqRh+64D9IIwe703dmuBSIxvF4ZfFMLCchcsjsRJcC6Bj/5w==",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/@cspotcode/source-map-support": {
|
"node_modules/@cspotcode/source-map-support": {
|
||||||
|
|||||||
@@ -71,7 +71,7 @@
|
|||||||
"@alloc/quick-lru": "^5.2.0",
|
"@alloc/quick-lru": "^5.2.0",
|
||||||
"@atlaskit/pragmatic-drag-and-drop": "^1.3.1",
|
"@atlaskit/pragmatic-drag-and-drop": "^1.3.1",
|
||||||
"@comfyorg/comfyui-electron-types": "^0.4.31",
|
"@comfyorg/comfyui-electron-types": "^0.4.31",
|
||||||
"@comfyorg/litegraph": "^0.11.5",
|
"@comfyorg/litegraph": "^0.11.6",
|
||||||
"@primevue/forms": "^4.2.5",
|
"@primevue/forms": "^4.2.5",
|
||||||
"@primevue/themes": "^4.2.5",
|
"@primevue/themes": "^4.2.5",
|
||||||
"@sentry/vue": "^8.48.0",
|
"@sentry/vue": "^8.48.0",
|
||||||
|
|||||||
@@ -3,10 +3,9 @@ import {
|
|||||||
LGraphCanvas,
|
LGraphCanvas,
|
||||||
LGraphEventMode,
|
LGraphEventMode,
|
||||||
LGraphNode,
|
LGraphNode,
|
||||||
LiteGraph,
|
LiteGraph
|
||||||
strokeShape
|
|
||||||
} from '@comfyorg/litegraph'
|
} from '@comfyorg/litegraph'
|
||||||
import type { IWidget, Rect, Vector2 } from '@comfyorg/litegraph'
|
import type { IWidget, Vector2 } from '@comfyorg/litegraph'
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
import type { ToastMessageOptions } from 'primevue/toast'
|
import type { ToastMessageOptions } from 'primevue/toast'
|
||||||
import { reactive } from 'vue'
|
import { reactive } from 'vue'
|
||||||
@@ -572,41 +571,6 @@ export class ComfyApp {
|
|||||||
|
|
||||||
const nodeErrors = self.lastNodeErrors?.[node.id]
|
const nodeErrors = self.lastNodeErrors?.[node.id]
|
||||||
|
|
||||||
let color = null
|
|
||||||
let lineWidth = 1
|
|
||||||
// @ts-expect-error fixme ts strict error
|
|
||||||
if (node.id === +self.runningNodeId) {
|
|
||||||
color = '#0f0'
|
|
||||||
} else if (self.dragOverNode && node.id === self.dragOverNode.id) {
|
|
||||||
color = 'dodgerblue'
|
|
||||||
} else if (nodeErrors?.errors) {
|
|
||||||
color = 'red'
|
|
||||||
lineWidth = 2
|
|
||||||
} else if (
|
|
||||||
self.lastExecutionError &&
|
|
||||||
// @ts-expect-error fixme ts strict error
|
|
||||||
+self.lastExecutionError.node_id === node.id
|
|
||||||
) {
|
|
||||||
color = '#f0f'
|
|
||||||
lineWidth = 2
|
|
||||||
}
|
|
||||||
|
|
||||||
if (color) {
|
|
||||||
const area: Rect = [
|
|
||||||
0,
|
|
||||||
-LiteGraph.NODE_TITLE_HEIGHT,
|
|
||||||
size[0],
|
|
||||||
size[1] + LiteGraph.NODE_TITLE_HEIGHT
|
|
||||||
]
|
|
||||||
strokeShape(ctx, area, {
|
|
||||||
shape: node._shape || node.constructor.shape || LiteGraph.ROUND_SHAPE,
|
|
||||||
thickness: lineWidth,
|
|
||||||
colour: color,
|
|
||||||
title_height: LiteGraph.NODE_TITLE_HEIGHT,
|
|
||||||
collapsed: node.collapsed
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// @ts-expect-error fixme ts strict error
|
// @ts-expect-error fixme ts strict error
|
||||||
if (self.progress && node.id === +self.runningNodeId) {
|
if (self.progress && node.id === +self.runningNodeId) {
|
||||||
ctx.fillStyle = 'green'
|
ctx.fillStyle = 'green'
|
||||||
|
|||||||
@@ -46,6 +46,26 @@ export const useLitegraphService = () => {
|
|||||||
|
|
||||||
constructor(title: string) {
|
constructor(title: string) {
|
||||||
super(title)
|
super(title)
|
||||||
|
this.strokeStyles['running'] = function (this: LGraphNode) {
|
||||||
|
if (this.id == app.runningNodeId) {
|
||||||
|
return { color: '#0f0' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.strokeStyles['nodeError'] = function (this: LGraphNode) {
|
||||||
|
if (app.lastNodeErrors?.[this.id]?.errors) {
|
||||||
|
return { color: 'red' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.strokeStyles['dragOver'] = function (this: LGraphNode) {
|
||||||
|
if (app.dragOverNode?.id == this.id) {
|
||||||
|
return { color: 'dodgerblue' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.strokeStyles['executionError'] = function (this: LGraphNode) {
|
||||||
|
if (app.lastExecutionError?.node_id == this.id) {
|
||||||
|
return { color: '#f0f', lineWidth: 2 }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const nodeMinSize = { width: 1, height: 1 }
|
const nodeMinSize = { width: 1, height: 1 }
|
||||||
// Process inputs using V2 schema
|
// Process inputs using V2 schema
|
||||||
|
|||||||
Reference in New Issue
Block a user