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