mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-12 16:40:05 +00:00
## Summary Fixes the case where a value is updated in the graph but the result doesn't reflect on the widget representation on the relevant node. ## Changes - **What**: Uses vanilla Vue utilities instead of a special utility - **What**: Fewer places where state could be desynced. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-6741-Fix-WIP-Simplify-the-widget-state-logic-2af6d73d36508160b729db50608a2ea9) by [Unito](https://www.unito.io) --------- Co-authored-by: github-actions <github-actions@github.com>
61 lines
1.6 KiB
Vue
61 lines
1.6 KiB
Vue
<template>
|
|
<div class="w-full">
|
|
<WidgetSelect v-model="modelValue" :widget />
|
|
<div class="my-4">
|
|
<AudioPreviewPlayer
|
|
:audio-url="audioUrlFromWidget"
|
|
:readonly="readonly"
|
|
:hide-when-empty="isOutputNodeRef"
|
|
:show-options-button="true"
|
|
/>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { computed } from 'vue'
|
|
|
|
import type { LGraphNode } from '@/lib/litegraph/src/litegraph'
|
|
import { app } from '@/scripts/app'
|
|
import type { SimplifiedWidget } from '@/types/simplifiedWidget'
|
|
import { isOutputNode } from '@/utils/nodeFilterUtil'
|
|
|
|
import { getAudioUrlFromPath } from '../utils/audioUtils'
|
|
import WidgetSelect from './WidgetSelect.vue'
|
|
import AudioPreviewPlayer from './audio/AudioPreviewPlayer.vue'
|
|
|
|
const props = defineProps<{
|
|
widget: SimplifiedWidget<string | undefined>
|
|
readonly?: boolean
|
|
nodeId: string
|
|
}>()
|
|
|
|
const modelValue = defineModel<string>('modelValue')
|
|
|
|
defineEmits<{
|
|
'update:modelValue': [value: string]
|
|
}>()
|
|
|
|
// Get litegraph node
|
|
const litegraphNode = computed(() => {
|
|
if (!props.nodeId || !app.rootGraph) return null
|
|
return app.rootGraph.getNodeById(props.nodeId) as LGraphNode | null
|
|
})
|
|
|
|
// Check if this is an output node (PreviewAudio, SaveAudio, etc)
|
|
const isOutputNodeRef = computed(() => {
|
|
const node = litegraphNode.value
|
|
if (!node) return false
|
|
return isOutputNode(node)
|
|
})
|
|
|
|
const audioFilePath = computed(() => props.widget.value as string)
|
|
|
|
// Computed audio URL from widget value (for input files)
|
|
const audioUrlFromWidget = computed(() => {
|
|
const path = audioFilePath.value
|
|
if (!path) return ''
|
|
return getAudioUrlFromPath(path, 'input')
|
|
})
|
|
</script>
|