mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-28 10:12:11 +00:00
Add simpler interface for active DOM widgets
This commit is contained in:
@@ -21,16 +21,14 @@ import { useDomWidgetStore } from '@/stores/domWidgetStore'
|
|||||||
import { useCanvasStore } from '@/stores/graphStore'
|
import { useCanvasStore } from '@/stores/graphStore'
|
||||||
|
|
||||||
const domWidgetStore = useDomWidgetStore()
|
const domWidgetStore = useDomWidgetStore()
|
||||||
const widgetStates = computed(() =>
|
const widgetStates = computed(() => domWidgetStore.activeWidgetStates)
|
||||||
Array.from(domWidgetStore.widgetStates.values())
|
|
||||||
)
|
|
||||||
|
|
||||||
const updateWidgets = () => {
|
const updateWidgets = () => {
|
||||||
const lgCanvas = canvasStore.canvas
|
const lgCanvas = canvasStore.canvas
|
||||||
if (!lgCanvas) return
|
if (!lgCanvas) return
|
||||||
|
|
||||||
const lowQuality = lgCanvas.low_quality
|
const lowQuality = lgCanvas.low_quality
|
||||||
for (const widgetState of domWidgetStore.widgetStates.values()) {
|
for (const widgetState of widgetStates.value) {
|
||||||
const widget = widgetState.widget
|
const widget = widgetState.widget
|
||||||
const node = widget.node as LGraphNode
|
const node = widget.node as LGraphNode
|
||||||
|
|
||||||
|
|||||||
@@ -801,7 +801,7 @@ export class ComfyApp {
|
|||||||
const widgetStore = useDomWidgetStore()
|
const widgetStore = useDomWidgetStore()
|
||||||
|
|
||||||
// Assertions: UnwrapRef
|
// Assertions: UnwrapRef
|
||||||
for (const { widget } of widgetStore.widgetStates.values()) {
|
for (const { widget } of widgetStore.activeWidgetStates) {
|
||||||
if (!nodeSet.has(widget.node)) {
|
if (!nodeSet.has(widget.node)) {
|
||||||
widgetStore.deactivateWidget(widget.id)
|
widgetStore.deactivateWidget(widget.id)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,9 @@ export interface DomWidgetState extends PositionConfig {
|
|||||||
export const useDomWidgetStore = defineStore('domWidget', () => {
|
export const useDomWidgetStore = defineStore('domWidget', () => {
|
||||||
const widgetStates = ref<Map<string, DomWidgetState>>(new Map())
|
const widgetStates = ref<Map<string, DomWidgetState>>(new Map())
|
||||||
|
|
||||||
|
const activeWidgetStates = computed(() =>
|
||||||
|
[...widgetStates.value.values()].filter((state) => state.active)
|
||||||
|
)
|
||||||
const inactiveWidgetStates = computed(() =>
|
const inactiveWidgetStates = computed(() =>
|
||||||
[...widgetStates.value.values()].filter((state) => !state.active)
|
[...widgetStates.value.values()].filter((state) => !state.active)
|
||||||
)
|
)
|
||||||
@@ -60,6 +63,7 @@ export const useDomWidgetStore = defineStore('domWidget', () => {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
widgetStates,
|
widgetStates,
|
||||||
|
activeWidgetStates,
|
||||||
inactiveWidgetStates,
|
inactiveWidgetStates,
|
||||||
registerWidget,
|
registerWidget,
|
||||||
unregisterWidget,
|
unregisterWidget,
|
||||||
|
|||||||
Reference in New Issue
Block a user