UPDATE: VERSION-20260326

This commit is contained in:
libertyspy
2026-03-26 22:05:31 +08:00
parent 18ccf490e4
commit 6656479327
8 changed files with 43 additions and 18 deletions

View File

@@ -46,6 +46,7 @@
<script lang="ts">
import { defineComponent, nextTick, onBeforeUnmount, onMounted, ref } from 'vue';
import {useRouter} from 'vue-router';
import { message } from 'ant-design-vue';
import { getTeleport } from '@antv/x6-vue-shape';
import { Graph, Node, type NodeProperties } from '@antv/x6';
@@ -54,8 +55,9 @@ import { Wrapper } from '@/components/wrapper';
import { safePreventDefault, safeStopPropagation } from '@/utils/event';
import Header from '../header.vue';
import type { PlatformWithComponents, Scenario } from './types';
import { createGraphTaskElement, createLineOptions, type GraphContainer, type GraphTaskElement, resolveGraph, useGraphCanvas } from '../graph';
import type { Scenario } from './types';
import type { PlatformWithComponents } from '../types';
import { createLineOptions, type GraphContainer, type GraphTaskElement, resolveGraph, useGraphCanvas } from '../graph';
import { registerScenarioElement } from './register';
import { createGraphScenarioElement, createGraphTaskElementFromScenario } from './utils';
@@ -63,7 +65,7 @@ import { createGraphScenarioElement, createGraphTaskElementFromScenario } from '
import PlatformCard from './platform-card.vue';
import NodesCard from './nodes-card.vue';
import { saveScenario } from './api';
import {resolveConnectionRelation} from './relation'
import { resolveConnectionRelation } from './relation';
const TeleportContainer = defineComponent(getTeleport());
@@ -82,6 +84,7 @@ export default defineComponent({
TeleportContainer,
},
setup() {
const router = useRouter();
const canvas = ref<HTMLDivElement | null>(null);
const graph = ref<Graph | null>(null);
const currentZoom = ref<number>(1);
@@ -105,6 +108,19 @@ export default defineComponent({
resizeCanvas,
} = useGraphCanvas();
const destroy = ()=> {
window.removeEventListener('resize', handleResize);
if (graph.value) {
try {
graph.value.clearCells();
} catch (error) {
console.warn('销毁画布时出错:', error);
}
graph.value = null;
console.log('画布已销毁');
}
}
// 处理拖动开始
const handleDragStart = (nm: PlatformWithComponents) => {
draggedNodeData.value = nm;
@@ -293,6 +309,14 @@ export default defineComponent({
currentScenarioEditing.value = null !== currentScenario.value;
});
handleGraphEvent('node:dblclick', () => {
destroy()
window.location.href = '/app/decision/designer'
// router.push({
// path: '/app/decision/designer'
// })
});
handleGraphEvent('node:click', (args: any) => {
const node = args.node as Node<NodeProperties>;
const newElement = node.getData() as GraphTaskElement;
@@ -382,18 +406,7 @@ export default defineComponent({
});
// 清理
onBeforeUnmount(() => {
window.removeEventListener('resize', handleResize);
if (graph.value) {
try {
graph.value.clearCells();
} catch (error) {
console.warn('销毁画布时出错:', error);
}
graph.value = null;
console.log('画布已销毁');
}
});
onBeforeUnmount(() => destroy());
return {
scenariosCardRef,

View File

@@ -8,7 +8,7 @@
*/
import type { ApiDataResponse, NullableString, PageableResponse } from '@/types';
import type { NullableString, PageableResponse } from '@/types';
import type { GraphContainer } from '../graph';
import type { Platform, PlatformComponent } from '../types';

View File

@@ -9,7 +9,7 @@
import type { GraphRect, GraphTaskElement } from '../graph';
import { generateKey } from '@/utils/strings';
import type { PlatformWithComponents } from './types';
import type { PlatformWithComponents } from '../types';
export const createGraphTaskElementFromScenario = (
platform: PlatformWithComponents,
@@ -28,6 +28,7 @@ export const createGraphTaskElementFromScenario = (
template: 0,
templateType: null,
category: null,
multiable: false,
group: null,
description: platform.description,
order: 0,