|
| 1 | +<template> |
| 2 | + <Button |
| 3 | + v-tooltip.top="{ |
| 4 | + value: isDisabled |
| 5 | + ? t('selectionToolbox.executeButton.disabledTooltip') |
| 6 | + : t('selectionToolbox.executeButton.tooltip'), |
| 7 | + showDelay: 1000 |
| 8 | + }" |
| 9 | + :severity="isDisabled ? 'secondary' : 'success'" |
| 10 | + text |
| 11 | + :disabled="isDisabled" |
| 12 | + @mouseenter="() => handleMouseEnter()" |
| 13 | + @mouseleave="() => handleMouseLeave()" |
| 14 | + @click="handleClick" |
| 15 | + > |
| 16 | + <i-lucide:play /> |
| 17 | + </Button> |
| 18 | +</template> |
| 19 | + |
| 20 | +<script setup lang="ts"> |
| 21 | +import type { LGraphNode } from '@comfyorg/litegraph' |
| 22 | +import Button from 'primevue/button' |
| 23 | +import { computed, ref } from 'vue' |
| 24 | +import { useI18n } from 'vue-i18n' |
| 25 | +
|
| 26 | +import { useCommandStore } from '@/stores/commandStore' |
| 27 | +import { useCanvasStore } from '@/stores/graphStore' |
| 28 | +import { isLGraphNode } from '@/utils/litegraphUtil' |
| 29 | +
|
| 30 | +const { t } = useI18n() |
| 31 | +const canvasStore = useCanvasStore() |
| 32 | +const commandStore = useCommandStore() |
| 33 | +
|
| 34 | +const canvas = canvasStore.getCanvas() |
| 35 | +const buttonHovered = ref(false) |
| 36 | +const selectedOutputNodes = computed( |
| 37 | + () => |
| 38 | + canvasStore.selectedItems.filter( |
| 39 | + (item) => isLGraphNode(item) && item.constructor.nodeData.output_node |
| 40 | + ) as LGraphNode[] |
| 41 | +) |
| 42 | +
|
| 43 | +const isDisabled = computed(() => selectedOutputNodes.value.length === 0) |
| 44 | +
|
| 45 | +function outputNodeStokeStyle(this: LGraphNode) { |
| 46 | + if ( |
| 47 | + this.selected && |
| 48 | + this.constructor.nodeData.output_node && |
| 49 | + buttonHovered.value |
| 50 | + ) { |
| 51 | + return { color: 'orange', lineWidth: 2, padding: 10 } |
| 52 | + } |
| 53 | +} |
| 54 | +
|
| 55 | +const handleMouseEnter = () => { |
| 56 | + buttonHovered.value = true |
| 57 | + for (const node of selectedOutputNodes.value) { |
| 58 | + node.strokeStyles['outputNode'] = outputNodeStokeStyle |
| 59 | + } |
| 60 | + canvas.setDirty(true) |
| 61 | +} |
| 62 | +
|
| 63 | +const handleMouseLeave = () => { |
| 64 | + buttonHovered.value = false |
| 65 | + canvas.setDirty(true) |
| 66 | +} |
| 67 | +
|
| 68 | +const handleClick = async () => { |
| 69 | + await commandStore.execute('Comfy.QueueSelectedOutputNodes') |
| 70 | +} |
| 71 | +</script> |
0 commit comments