|
|
@@ -4,11 +4,11 @@ import { h } from 'vue';
|
|
|
import { tryOnUnmounted, useParentElement } from '@vueuse/core';
|
|
|
import { VxeUI } from 'vxe-pc-ui';
|
|
|
|
|
|
-import { notification } from 'ant-design-vue';
|
|
|
+import { Button, notification } from 'ant-design-vue';
|
|
|
import { ArrowDownOutlined, ArrowRightOutlined, CloseOutlined, FullscreenExitOutlined, MenuOutlined, SearchOutlined, ToolOutlined } from '@ant-design/icons-vue';
|
|
|
|
|
|
import type { CallbackArgs } from '@logicflow/core';
|
|
|
-import { ProximityConnect } from '@logicflow/extension';
|
|
|
+import { ProximityConnect, InsertNodeInPolyline } from '@logicflow/extension';
|
|
|
import { Dagre } from '@logicflow/layout';
|
|
|
import VLogicFlowInit, { type LogicFlowInstance, type LogicFlowOptions, VLogicFlow, type VLogicFlowInstance } from '@/libs/logic-flow';
|
|
|
|
|
|
@@ -33,7 +33,7 @@ const options = reactive<LogicFlowOptions>({
|
|
|
snapToGrid: true,
|
|
|
snapline: false,
|
|
|
textEdit: false,
|
|
|
- plugins: [Dagre, ProximityConnect],
|
|
|
+ plugins: [Dagre, ProximityConnect, InsertNodeInPolyline],
|
|
|
pluginsOptions: {
|
|
|
proximityConnect: {
|
|
|
enable: true, // 插件是否启用
|
|
|
@@ -54,6 +54,7 @@ let instance!: VLogicFlowInstance;
|
|
|
let isUnmounted = false;
|
|
|
const hasInstance = () => !isUnmounted && !!instance && !!instance.lf;
|
|
|
// end
|
|
|
+let oldValue: FlowRequestData;
|
|
|
const init = (lf: LogicFlowInstance): void => {
|
|
|
instance = VLogicFlowInit(lf, {
|
|
|
register: [{ category: 'node', type: 'FlowNode', view: FlowNodeView, model: FlowNodeViewModel }],
|
|
|
@@ -63,7 +64,7 @@ const init = (lf: LogicFlowInstance): void => {
|
|
|
watchPostEffect(() => {
|
|
|
const value = requestData.value;
|
|
|
console.log('[AioFlowConfig] 接收 request-data 数据', value);
|
|
|
- update(value);
|
|
|
+ if (!oldValue || oldValue?.timestamp !== value?.timestamp) update(value);
|
|
|
});
|
|
|
});
|
|
|
|
|
|
@@ -115,8 +116,30 @@ const init = (lf: LogicFlowInstance): void => {
|
|
|
if (index > -1) nodes.value.splice(index, 1);
|
|
|
});
|
|
|
// @ts-ignore
|
|
|
- instance.listener('edge:proximity-connect', () => {
|
|
|
+ /*instance.listener('edge:proximity-connect', () => {
|
|
|
updateLayout();
|
|
|
+ });*/
|
|
|
+ // @ts-ignore
|
|
|
+ instance.listener('node:insert', (event: CallbackArgs<'data'>) => {
|
|
|
+ notification.success({
|
|
|
+ key: 'connection:node:insert',
|
|
|
+ message: '插入节点成功',
|
|
|
+ description: () =>
|
|
|
+ h(
|
|
|
+ Button,
|
|
|
+ {
|
|
|
+ type: 'primary',
|
|
|
+ size: 'small',
|
|
|
+ onClick: () => {
|
|
|
+ validate().catch();
|
|
|
+ notification.close('connection:node:insert');
|
|
|
+ },
|
|
|
+ },
|
|
|
+ { default: () => '检测连接' }
|
|
|
+ ),
|
|
|
+ top: '12px',
|
|
|
+ getContainer: () => (el.value as HTMLElement) ?? document.body,
|
|
|
+ });
|
|
|
});
|
|
|
};
|
|
|
|
|
|
@@ -220,7 +243,7 @@ const update = (data?: FlowRequestData) => {
|
|
|
|
|
|
instance.lf.renderRawData(graph);
|
|
|
updateLayout('TB');
|
|
|
- if (graph.nodes && graph.nodes.length > 2) updateLayout('center');
|
|
|
+ if (graph.nodes && graph.nodes.length > 2) setTimeout(() => updateLayout('center'), 100)
|
|
|
};
|
|
|
const validate = (tips = true) => {
|
|
|
if (!hasInstance()) return Promise.reject(new Error('LogicFlow 已销毁'));
|
|
|
@@ -268,9 +291,10 @@ const validate = (tips = true) => {
|
|
|
[Node.ID_Start]: instance.lf.getNodeModelById(Node.ID_Start)?.getProperties().requestData,
|
|
|
};
|
|
|
for (const group of nodeGroup.value) for (const node of group) if (node.id) data[node.id] = node.properties?.requestData;
|
|
|
- requestData.value = toFlowRequestData(gather, data);
|
|
|
- resolve({ gather, data: requestData.value });
|
|
|
- console.log('[AioFlowConfig] 更新 request-data 数据: ', requestData.value);
|
|
|
+ oldValue = toFlowRequestData(gather, data);
|
|
|
+ requestData.value = oldValue;
|
|
|
+ resolve({ gather, data: oldValue });
|
|
|
+ console.log('[AioFlowConfig] 更新 request-data 数据: ', );
|
|
|
} catch (error: any) {
|
|
|
if (tips) {
|
|
|
notification.error({
|