|
@@ -3,17 +3,17 @@ import { computed } from 'vue'
|
|
|
import { Position } from '@vue-flow/core'
|
|
import { Position } from '@vue-flow/core'
|
|
|
import type { NodeProps } from '@vue-flow/core'
|
|
import type { NodeProps } from '@vue-flow/core'
|
|
|
import type {
|
|
import type {
|
|
|
- IWorkflowNode,
|
|
|
|
|
- CanvasConnectionPort,
|
|
|
|
|
- CanvasElementPortWithRenderData
|
|
|
|
|
|
|
+ IWorkflowNode,
|
|
|
|
|
+ CanvasConnectionPort,
|
|
|
|
|
+ CanvasElementPortWithRenderData
|
|
|
} from '../../Interface'
|
|
} from '../../Interface'
|
|
|
|
|
|
|
|
import { Icon } from '@repo/ui'
|
|
import { Icon } from '@repo/ui'
|
|
|
import CanvasHandle from './handles/CanvasHandle.vue'
|
|
import CanvasHandle from './handles/CanvasHandle.vue'
|
|
|
|
|
|
|
|
type Props = NodeProps<IWorkflowNode['data']> & {
|
|
type Props = NodeProps<IWorkflowNode['data']> & {
|
|
|
- readOnly?: boolean
|
|
|
|
|
- hovered?: boolean
|
|
|
|
|
|
|
+ readOnly?: boolean
|
|
|
|
|
+ hovered?: boolean
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const props = defineProps<Props>()
|
|
const props = defineProps<Props>()
|
|
@@ -22,76 +22,91 @@ const props = defineProps<Props>()
|
|
|
* 处理节点
|
|
* 处理节点
|
|
|
*/
|
|
*/
|
|
|
const createEndpoint = (data: {
|
|
const createEndpoint = (data: {
|
|
|
- port: CanvasConnectionPort
|
|
|
|
|
- index: number
|
|
|
|
|
- count: number
|
|
|
|
|
- offsetAxis: 'top' | 'left'
|
|
|
|
|
- position: Position
|
|
|
|
|
|
|
+ port: CanvasConnectionPort
|
|
|
|
|
+ index: number
|
|
|
|
|
+ count: number
|
|
|
|
|
+ offsetAxis: 'top' | 'left'
|
|
|
|
|
+ position: Position
|
|
|
}): CanvasElementPortWithRenderData => {
|
|
}): CanvasElementPortWithRenderData => {
|
|
|
- const { port, index, count, offsetAxis, position } = data
|
|
|
|
|
|
|
+ const { port, index, count, offsetAxis, position } = data
|
|
|
|
|
|
|
|
- return {
|
|
|
|
|
- ...port,
|
|
|
|
|
- handleId: `${port.type}-${index}`,
|
|
|
|
|
- position,
|
|
|
|
|
- connectionsCount: count,
|
|
|
|
|
- isConnecting: false,
|
|
|
|
|
- offset: {
|
|
|
|
|
- [offsetAxis]: `${(100 / (count + 1)) * (index + 1)}%`
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ return {
|
|
|
|
|
+ ...port,
|
|
|
|
|
+ handleId: `${port.type}-${index}`,
|
|
|
|
|
+ position,
|
|
|
|
|
+ connectionsCount: count,
|
|
|
|
|
+ isConnecting: false,
|
|
|
|
|
+ offset: {
|
|
|
|
|
+ [offsetAxis]: `${(100 / (count + 1)) * (index + 1)}%`
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Inputs
|
|
* Inputs
|
|
|
*/
|
|
*/
|
|
|
const inputs = computed(() =>
|
|
const inputs = computed(() =>
|
|
|
- (props.data.inputs || []).map((target, index) =>
|
|
|
|
|
- createEndpoint({
|
|
|
|
|
- port: target,
|
|
|
|
|
- index,
|
|
|
|
|
- count: props.data.inputs.length,
|
|
|
|
|
- offsetAxis: 'top',
|
|
|
|
|
- position: Position.Left
|
|
|
|
|
- })
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ (props.data.inputs || []).map((target, index) =>
|
|
|
|
|
+ createEndpoint({
|
|
|
|
|
+ port: target,
|
|
|
|
|
+ index,
|
|
|
|
|
+ count: props.data.inputs.length,
|
|
|
|
|
+ offsetAxis: 'top',
|
|
|
|
|
+ position: Position.Left
|
|
|
|
|
+ })
|
|
|
|
|
+ )
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Outputs
|
|
* Outputs
|
|
|
*/
|
|
*/
|
|
|
const outputs = computed(() =>
|
|
const outputs = computed(() =>
|
|
|
- (props.data.outputs || []).map((source, index) =>
|
|
|
|
|
- createEndpoint({
|
|
|
|
|
- port: source,
|
|
|
|
|
- index,
|
|
|
|
|
- count: props.data.outputs.length,
|
|
|
|
|
- offsetAxis: 'top',
|
|
|
|
|
- position: Position.Right
|
|
|
|
|
- })
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ (props.data.outputs || []).map((source, index) =>
|
|
|
|
|
+ createEndpoint({
|
|
|
|
|
+ port: source,
|
|
|
|
|
+ index,
|
|
|
|
|
+ count: props.data.outputs.length,
|
|
|
|
|
+ offsetAxis: 'top',
|
|
|
|
|
+ position: Position.Right
|
|
|
|
|
+ })
|
|
|
|
|
+ )
|
|
|
)
|
|
)
|
|
|
|
|
+
|
|
|
|
|
+const nodeClass = computed(() => {
|
|
|
|
|
+ let classes: string[] = []
|
|
|
|
|
+ if (props.selected) {
|
|
|
|
|
+ classes.push('ring-6px', 'ring-#e0e2e7')
|
|
|
|
|
+ }
|
|
|
|
|
+ if (inputs.value.length === 0) {
|
|
|
|
|
+ classes.push('rounded-l-36px')
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return classes
|
|
|
|
|
+})
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
<template>
|
|
|
- <div class="w-full h-full bg-#fff box-border border-2 border-solid border-#dcdcdc rounded-4px relative">
|
|
|
|
|
- <div class="w-full h-full relative flex items-center justify-center">
|
|
|
|
|
- <Icon :icon="data?.icon" height="40" width="40" :color="data?.iconColor" />
|
|
|
|
|
- </div>
|
|
|
|
|
|
|
+ <div
|
|
|
|
|
+ class="w-full h-full bg-#fff box-border border-2 border-solid border-#dcdcdc rounded-8px relative"
|
|
|
|
|
+ :class="nodeClass"
|
|
|
|
|
+ >
|
|
|
|
|
+ <div className="w-full h-full relative flex items-center justify-center">
|
|
|
|
|
+ <Icon :icon="data?.icon" height="40" width="40" :color="data?.iconColor" />
|
|
|
|
|
+ </div>
|
|
|
|
|
|
|
|
- <div class="absolute w-full bottom--22px text-12px text-center text-#222">
|
|
|
|
|
- {{ data?.displayName }}
|
|
|
|
|
- </div>
|
|
|
|
|
- <div class="absolute w-full bottom--38px text-12px text-center text-#999 truncate">
|
|
|
|
|
- {{ data.subtitle }}
|
|
|
|
|
- </div>
|
|
|
|
|
|
|
+ <div className="absolute w-full bottom--24px text-12px text-center text-#222">
|
|
|
|
|
+ {{ data?.displayName }}
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div className="absolute w-full bottom--40px text-12px text-center text-#999 truncate">
|
|
|
|
|
+ {{ data.subtitle }}
|
|
|
|
|
+ </div>
|
|
|
|
|
|
|
|
- <template v-for="target in inputs" :key="'handle-inputs-port' + target.index">
|
|
|
|
|
- <CanvasHandle v-bind="target" type="target" />
|
|
|
|
|
- </template>
|
|
|
|
|
|
|
+ <template v-for="target in inputs" :key="'handle-inputs-port' + target.index">
|
|
|
|
|
+ <CanvasHandle v-bind="target" type="target" />
|
|
|
|
|
+ </template>
|
|
|
|
|
|
|
|
- <template v-for="source in outputs" :key="'handle-outputs-port' + source.index">
|
|
|
|
|
- <CanvasHandle v-bind="source" type="source" />
|
|
|
|
|
- </template>
|
|
|
|
|
- </div>
|
|
|
|
|
|
|
+ <template v-for="source in outputs" :key="'handle-outputs-port' + source.index">
|
|
|
|
|
+ <CanvasHandle v-bind="source" type="source" />
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </div>
|
|
|
</template>
|
|
</template>
|