mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-01-26 19:09:52 +00:00
Deduplicate node title resolving
This commit is contained in:
@@ -37,7 +37,7 @@ import { useI18n } from 'vue-i18n'
|
||||
import { st } from '@/i18n'
|
||||
import { useQueueProgress } from '@/composables/queue/useQueueProgress'
|
||||
import { useExecutionStore } from '@/stores/executionStore'
|
||||
import { normalizeI18nKey } from '@/utils/formatUtil'
|
||||
import { resolveNodeDisplayName } from '@/utils/nodeTitleUtil'
|
||||
|
||||
const props = defineProps<{
|
||||
hidden?: boolean
|
||||
@@ -53,13 +53,11 @@ const {
|
||||
} = useQueueProgress()
|
||||
|
||||
const currentNodeName = computed(() => {
|
||||
const node = executionStore.executingNode
|
||||
if (!node) return t('g.emDash')
|
||||
const title = (node.title ?? '').toString().trim()
|
||||
if (title) return title
|
||||
const nodeType = (node.type ?? '').toString().trim() || t('g.untitled')
|
||||
const key = `nodeDefs.${normalizeI18nKey(nodeType)}.display_name`
|
||||
return st(key, nodeType)
|
||||
return resolveNodeDisplayName(executionStore.executingNode, {
|
||||
emptyLabel: t('g.emDash'),
|
||||
untitledLabel: t('g.untitled'),
|
||||
st
|
||||
})
|
||||
})
|
||||
|
||||
const shouldShow = computed(
|
||||
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
isToday,
|
||||
isYesterday
|
||||
} from '@/utils/dateTimeUtil'
|
||||
import { normalizeI18nKey } from '@/utils/formatUtil'
|
||||
import { resolveNodeDisplayName } from '@/utils/nodeTitleUtil'
|
||||
import { buildJobDisplay } from '@/utils/queueDisplay'
|
||||
import { jobStateFromTask } from '@/utils/queueUtil'
|
||||
|
||||
@@ -185,13 +185,11 @@ export function useJobList() {
|
||||
executionStore.isPromptInitializing(promptId)
|
||||
|
||||
const currentNodeName = computed(() => {
|
||||
const node = executionStore.executingNode
|
||||
if (!node) return t('g.emDash')
|
||||
const title = (node.title ?? '').toString().trim()
|
||||
if (title) return title
|
||||
const nodeType = (node.type ?? '').toString().trim() || t('g.untitled')
|
||||
const key = `nodeDefs.${normalizeI18nKey(nodeType)}.display_name`
|
||||
return st(key, nodeType)
|
||||
return resolveNodeDisplayName(executionStore.executingNode, {
|
||||
emptyLabel: t('g.emDash'),
|
||||
untitledLabel: t('g.untitled'),
|
||||
st
|
||||
})
|
||||
})
|
||||
|
||||
const selectedJobTab = ref<JobTab>('All')
|
||||
|
||||
28
src/utils/nodeTitleUtil.ts
Normal file
28
src/utils/nodeTitleUtil.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { normalizeI18nKey } from '@/utils/formatUtil'
|
||||
|
||||
export type NodeTitleInfo = {
|
||||
title?: string | number | null
|
||||
type?: string | number | null
|
||||
}
|
||||
|
||||
export type StaticTranslate = (key: string, fallbackMessage: string) => string
|
||||
|
||||
type ResolveNodeDisplayNameOptions = {
|
||||
emptyLabel: string
|
||||
untitledLabel: string
|
||||
st: StaticTranslate
|
||||
}
|
||||
|
||||
export function resolveNodeDisplayName(
|
||||
node: NodeTitleInfo | null | undefined,
|
||||
options: ResolveNodeDisplayNameOptions
|
||||
): string {
|
||||
if (!node) return options.emptyLabel
|
||||
|
||||
const title = (node.title ?? '').toString().trim()
|
||||
if (title.length > 0) return title
|
||||
|
||||
const nodeType = (node.type ?? '').toString().trim() || options.untitledLabel
|
||||
const key = `nodeDefs.${normalizeI18nKey(nodeType)}.display_name`
|
||||
return options.st(key, nodeType)
|
||||
}
|
||||
Reference in New Issue
Block a user