Files
zguiy-flow/frontend/src/components/nodes/shared/useStandardNode.ts
2025-12-13 15:40:01 +08:00

29 lines
604 B
TypeScript

import { computed } from 'vue'
import type { BaseNodeProps, StandardNodeOptions } from './types'
export function useStandardNode<TData>(
props: BaseNodeProps<TData>,
options: StandardNodeOptions<TData>
) {
const bodyItems = computed(() => {
return options.body ? options.body(props) : []
})
const badge = computed(() => {
if (typeof options.badge === 'function') {
return options.badge(props)
}
return options.badge
})
const status = computed(() => options.status?.(props))
return {
props,
definition: options,
bodyItems,
badge,
status
}
}