mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-30 19:21:54 +00:00
Fix convert to subgraph shown on IO node
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<Button
|
<Button
|
||||||
|
v-show="isVisible"
|
||||||
v-tooltip.top="{
|
v-tooltip.top="{
|
||||||
value: t('commands.Comfy_Graph_ConvertToSubgraph.label'),
|
value: t('commands.Comfy_Graph_ConvertToSubgraph.label'),
|
||||||
showDelay: 1000
|
showDelay: 1000
|
||||||
@@ -13,10 +14,21 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import Button from 'primevue/button'
|
import Button from 'primevue/button'
|
||||||
|
import { computed } from 'vue'
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
|
|
||||||
import { useCommandStore } from '@/stores/commandStore'
|
import { useCommandStore } from '@/stores/commandStore'
|
||||||
|
import { useCanvasStore } from '@/stores/graphStore'
|
||||||
|
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
const commandStore = useCommandStore()
|
const commandStore = useCommandStore()
|
||||||
|
const canvasStore = useCanvasStore()
|
||||||
|
|
||||||
|
const isVisible = computed(() => {
|
||||||
|
return (
|
||||||
|
canvasStore.groupSelected ||
|
||||||
|
canvasStore.rerouteSelected ||
|
||||||
|
canvasStore.nodeSelected
|
||||||
|
)
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import type { Positionable } from '@comfyorg/litegraph/dist/interfaces'
|
|||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
import { type Raw, computed, markRaw, ref, shallowRef } from 'vue'
|
import { type Raw, computed, markRaw, ref, shallowRef } from 'vue'
|
||||||
|
|
||||||
import { isLGraphGroup, isLGraphNode } from '@/utils/litegraphUtil'
|
import { isLGraphGroup, isLGraphNode, isReroute } from '@/utils/litegraphUtil'
|
||||||
|
|
||||||
export const useTitleEditorStore = defineStore('titleEditor', () => {
|
export const useTitleEditorStore = defineStore('titleEditor', () => {
|
||||||
const titleEditorTarget = shallowRef<LGraphNode | LGraphGroup | null>(null)
|
const titleEditorTarget = shallowRef<LGraphNode | LGraphGroup | null>(null)
|
||||||
@@ -31,6 +31,7 @@ export const useCanvasStore = defineStore('canvas', () => {
|
|||||||
|
|
||||||
const nodeSelected = computed(() => selectedItems.value.some(isLGraphNode))
|
const nodeSelected = computed(() => selectedItems.value.some(isLGraphNode))
|
||||||
const groupSelected = computed(() => selectedItems.value.some(isLGraphGroup))
|
const groupSelected = computed(() => selectedItems.value.some(isLGraphGroup))
|
||||||
|
const rerouteSelected = computed(() => selectedItems.value.some(isReroute))
|
||||||
|
|
||||||
const getCanvas = () => {
|
const getCanvas = () => {
|
||||||
if (!canvas.value) throw new Error('getCanvas: canvas is null')
|
if (!canvas.value) throw new Error('getCanvas: canvas is null')
|
||||||
@@ -42,6 +43,7 @@ export const useCanvasStore = defineStore('canvas', () => {
|
|||||||
selectedItems,
|
selectedItems,
|
||||||
nodeSelected,
|
nodeSelected,
|
||||||
groupSelected,
|
groupSelected,
|
||||||
|
rerouteSelected,
|
||||||
updateSelectedItems,
|
updateSelectedItems,
|
||||||
getCanvas
|
getCanvas
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import type { ColorOption, LGraph } from '@comfyorg/litegraph'
|
import { ColorOption, LGraph, Reroute } from '@comfyorg/litegraph'
|
||||||
import { LGraphGroup, LGraphNode, isColorable } from '@comfyorg/litegraph'
|
import { LGraphGroup, LGraphNode, isColorable } from '@comfyorg/litegraph'
|
||||||
import type { ISerialisedGraph } from '@comfyorg/litegraph/dist/types/serialisation'
|
import type { ISerialisedGraph } from '@comfyorg/litegraph/dist/types/serialisation'
|
||||||
import type {
|
import type {
|
||||||
@@ -50,6 +50,10 @@ export const isLGraphGroup = (item: unknown): item is LGraphGroup => {
|
|||||||
return item instanceof LGraphGroup
|
return item instanceof LGraphGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const isReroute = (item: unknown): item is Reroute => {
|
||||||
|
return item instanceof Reroute
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the color option of all canvas items if they are all the same.
|
* Get the color option of all canvas items if they are all the same.
|
||||||
* @param items - The items to get the color option of.
|
* @param items - The items to get the color option of.
|
||||||
|
|||||||
Reference in New Issue
Block a user