Initial commit
This commit is contained in:
@@ -22,7 +22,6 @@ export interface DraggableElement {
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
|
||||
export type ElementStatus = 'default' | 'success' | 'failed' | 'running' | string | null
|
||||
|
||||
export interface ElementPosition {
|
||||
@@ -39,10 +38,15 @@ export interface ElementVariable {
|
||||
}
|
||||
|
||||
export interface BaseElement {
|
||||
id: number;
|
||||
key: NullableString;
|
||||
type: NullableString;
|
||||
status: ElementStatus;
|
||||
key: string;
|
||||
name: string;
|
||||
type: string;
|
||||
width: number;
|
||||
height: number;
|
||||
position: ElementPosition;
|
||||
category: NullableString;
|
||||
element?: DraggableElement;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
export interface TaskNodeRect {
|
||||
@@ -54,11 +58,6 @@ export interface TaskNodeRect {
|
||||
|
||||
export interface TaskNodeElement extends BaseElement {
|
||||
template: number;
|
||||
name: NullableString;
|
||||
description: NullableString;
|
||||
width: number;
|
||||
height: number;
|
||||
position: ElementPosition;
|
||||
inputs: any;
|
||||
outputs: any;
|
||||
variables: ElementVariable[];
|
||||
@@ -73,10 +72,16 @@ export interface SettingTaskNodeElement extends TaskNodeElement {
|
||||
settings: NodeSetting[];
|
||||
}
|
||||
|
||||
export interface ModelElement extends BaseElement {
|
||||
edges: EdgeNodeElement[];
|
||||
}
|
||||
|
||||
export interface EdgeNodeElement extends BaseElement {
|
||||
export interface EdgeNodeElement {
|
||||
key: NullableString;
|
||||
source: NullableString;
|
||||
sourceName: NullableString;
|
||||
target: NullableString;
|
||||
targetName: NullableString;
|
||||
attrs: Record<any, any>;
|
||||
router: Record<any, any>;
|
||||
connector: any;
|
||||
|
||||
@@ -151,15 +151,18 @@ export const useGraphCanvas = (readonly: boolean = false): UseGraphCanvas => {
|
||||
|
||||
// 将连线存储到节点数据中
|
||||
const sourceEdges = sourceData.edges || [];
|
||||
const existingEdge = sourceEdges.find(e => e.targetKey === targetNode.id);
|
||||
const existingEdge = sourceEdges.find(e => e.target === targetNode.id);
|
||||
|
||||
if (!existingEdge) {
|
||||
sourceEdges.push({
|
||||
key: edge.id,
|
||||
sourceKey: sourceNode.id,
|
||||
source: sourceNode.id,
|
||||
sourceName: sourceData.name,
|
||||
targetKey: targetNode.id,
|
||||
targetName: targetData.name,
|
||||
connector: {},
|
||||
router: {},
|
||||
attrs: {},
|
||||
target: targetNode.id,
|
||||
targetName: targetData.name
|
||||
});
|
||||
sourceNode.replaceData({ ...sourceData, edges: sourceEdges });
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<div class="w-full">
|
||||
<div class="ks-designer-node-content">
|
||||
<div
|
||||
v-for="(item, index) in element?.element?.children || []"
|
||||
v-for="(item, index) in element?.children || []"
|
||||
:key="item.id || index"
|
||||
class="ks-designer-node-row"
|
||||
>
|
||||
@@ -43,7 +43,7 @@
|
||||
></div>
|
||||
</div>
|
||||
|
||||
<div v-if="!(element?.element?.children && element?.element?.children?.length > 0)" class="ks-designer-node-row">
|
||||
<div v-if="!(element?.children && element?.children?.length > 0)" class="ks-designer-node-row">
|
||||
<div class="port port-in" data-port="in-0" magnet="passive"></div>
|
||||
<div class="ks-designer-node-name" v-if="element?.category !== 'component'">
|
||||
{{ element?.name ?? '-' }}
|
||||
|
||||
@@ -111,7 +111,7 @@
|
||||
<script lang="ts">
|
||||
import { defineComponent, onMounted, type PropType, ref, watch } from 'vue';
|
||||
import { CheckOutlined } from '@ant-design/icons-vue';
|
||||
import type { ElementVariable, SettingTaskNodeElement } from './types';
|
||||
import type { ElementVariable, SettingTaskNodeElement } from './builder/element';
|
||||
import type { Graph, Node, NodeProperties } from '@antv/x6';
|
||||
import {generateKey} from '@/utils/strings'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user