index.vue
1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<!--
* @Date: 2025-03-11 15:07:29
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-03-19 17:31:46
* @FilePath: /logic-flow2/src/views/node-model/index.vue
* @Description: 自定义节点model
-->
<template>
<div class="container">
<div ref="container" class="flow-container"></div>
</div>
</template>
<script setup>
import LogicFlow from "@logicflow/core";
import UserTask from "./customRect";
import customPolygon from "./customPolygon";
import data from "./data";
const SilentConfig = {
isSilentMode: true,
stopScrollGraph: true,
stopMoveGraph: true,
stopZoomGraph: true,
adjustNodePosition: true,
};
const container = ref(null);
let lf = null;
onMounted(() => {
lf = new LogicFlow({
container: container.value,
grid: true,
...SilentConfig,
});
lf.register(UserTask);
lf.register(customPolygon);
lf.on("node:click", ({ data }) => {
if (data.type === "custom-polygon") {
const node = lf.getNodeModelById(data.id);
console.log("节点顶点坐标:", node.points);
}
});
lf.render(data);
lf.translateCenter();
});
</script>
<style scoped>
.container {
width: 100vw;
height: 100vh;
display: flex;
flex-direction: column;
}
.flow-container {
flex: 1;
width: 100%;
height: 100%;
}
</style>