Showing
3 changed files
with
138 additions
and
1 deletions
| ... | @@ -100,6 +100,11 @@ const router = createRouter({ | ... | @@ -100,6 +100,11 @@ const router = createRouter({ |
| 100 | name: 'adv-dnd-panel-custom', | 100 | name: 'adv-dnd-panel-custom', |
| 101 | component: () => import('../views/adv-dnd-panel/custom.vue') | 101 | component: () => import('../views/adv-dnd-panel/custom.vue') |
| 102 | }, | 102 | }, |
| 103 | + { | ||
| 104 | + path: '/mini-map', | ||
| 105 | + name: 'mini-map', | ||
| 106 | + component: () => import('../views/mini-map/index.vue') | ||
| 107 | + }, | ||
| 103 | ] | 108 | ] |
| 104 | }) | 109 | }) |
| 105 | 110 | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2025-03-10 14:37:31 | 2 | * @Date: 2025-03-10 14:37:31 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-03-13 17:45:28 | 4 | + * @LastEditTime: 2025-03-13 20:52:22 |
| 5 | * @FilePath: /logic-flow2/src/views/home.vue | 5 | * @FilePath: /logic-flow2/src/views/home.vue |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | --> | 7 | --> |
| ... | @@ -24,6 +24,7 @@ | ... | @@ -24,6 +24,7 @@ |
| 24 | <el-button type="primary" @click="goTo('adv-menu')">adv-menu</el-button> | 24 | <el-button type="primary" @click="goTo('adv-menu')">adv-menu</el-button> |
| 25 | <el-button type="primary" @click="goTo('adv-dnd-panel')">adv-dnd-panel</el-button> | 25 | <el-button type="primary" @click="goTo('adv-dnd-panel')">adv-dnd-panel</el-button> |
| 26 | <el-button type="primary" @click="goTo('adv-dnd-panel-custom')">adv-dnd-panel-custom</el-button> | 26 | <el-button type="primary" @click="goTo('adv-dnd-panel-custom')">adv-dnd-panel-custom</el-button> |
| 27 | + <el-button type="primary" @click="goTo('mini-map')">mini-map</el-button> | ||
| 27 | </template> | 28 | </template> |
| 28 | 29 | ||
| 29 | <script setup> | 30 | <script setup> | ... | ... |
src/views/mini-map/index.vue
0 → 100644
| 1 | +<!-- | ||
| 2 | + * @Date: 2025-03-10 16:52:35 | ||
| 3 | + * @LastEditors: hookehuyr hookehuyr@gmail.com | ||
| 4 | + * @LastEditTime: 2025-03-13 21:05:08 | ||
| 5 | + * @FilePath: /logic-flow2/src/views/mini-map/index.vue | ||
| 6 | + * @Description: 小地图 | ||
| 7 | +--> | ||
| 8 | +<template> | ||
| 9 | + <div class="container"> | ||
| 10 | + <div ref="container" class="flow-container"></div> | ||
| 11 | + <div class="mini-map-container"> | ||
| 12 | + <el-button type="primary" @click="toggleVisible"> | ||
| 13 | + {{ visible ? "隐藏" : "显示" }} | ||
| 14 | + </el-button> | ||
| 15 | + <el-button type="primary" @click="handleReset">重置</el-button> | ||
| 16 | + <el-button type="primary" @click="updatePositionWithObject1"> | ||
| 17 | + 左上角 | ||
| 18 | + </el-button> | ||
| 19 | + <el-button type="primary" @click="updatePositionWithObject2"> | ||
| 20 | + 右下角 | ||
| 21 | + </el-button> | ||
| 22 | + </div> | ||
| 23 | + </div> | ||
| 24 | +</template> | ||
| 25 | + | ||
| 26 | +<script setup> | ||
| 27 | +import LogicFlow from "@logicflow/core"; | ||
| 28 | +import { MiniMap } from "@logicflow/extension"; | ||
| 29 | + | ||
| 30 | +const container = ref(null); | ||
| 31 | +let lf = null; | ||
| 32 | + | ||
| 33 | +const miniMapOptions = { | ||
| 34 | + isShowHeader: false, | ||
| 35 | + isShowCloseIcon: true, | ||
| 36 | + headerTitle: "MiniMap", | ||
| 37 | + width: 200, | ||
| 38 | + height: 120, | ||
| 39 | + rightPosition: 100, | ||
| 40 | + bottomPosition: 100, | ||
| 41 | +}; | ||
| 42 | + | ||
| 43 | +const visible = ref(false); | ||
| 44 | +const position = ref(false); | ||
| 45 | + | ||
| 46 | +onMounted(() => { | ||
| 47 | + lf = new LogicFlow({ | ||
| 48 | + container: container.value, | ||
| 49 | + grid: true, | ||
| 50 | + plugins: [MiniMap], | ||
| 51 | + pluginsOptions: { | ||
| 52 | + miniMap: { | ||
| 53 | + ...miniMapOptions, | ||
| 54 | + }, | ||
| 55 | + }, | ||
| 56 | + }); | ||
| 57 | + | ||
| 58 | + lf.on("miniMap:close", () => { | ||
| 59 | + visible.value = false; | ||
| 60 | + }); | ||
| 61 | + | ||
| 62 | + lf.render({ | ||
| 63 | + nodes: [ | ||
| 64 | + { id: "node1", type: "rect", x: 200, y: 100 }, | ||
| 65 | + { id: "node2", type: "circle", x: 400, y: 100 }, | ||
| 66 | + ], | ||
| 67 | + edges: [{ id: "edge1", sourceNodeId: "node1", targetNodeId: "node2" }], | ||
| 68 | + }); | ||
| 69 | +}); | ||
| 70 | + | ||
| 71 | +const toggleVisible = () => { | ||
| 72 | + if (lf) { | ||
| 73 | + const miniMap = lf.extension.miniMap; | ||
| 74 | + if (visible.value) { | ||
| 75 | + miniMap.hide(); | ||
| 76 | + } else { | ||
| 77 | + miniMap.show(); | ||
| 78 | + } | ||
| 79 | + visible.value = !visible.value; | ||
| 80 | + } | ||
| 81 | +}; | ||
| 82 | + | ||
| 83 | +const handleReset = () => { | ||
| 84 | + if (lf) { | ||
| 85 | + lf.extension.miniMap.reset(); | ||
| 86 | + } | ||
| 87 | +}; | ||
| 88 | + | ||
| 89 | +const updatePosition = (position) => { | ||
| 90 | + if (lf) { | ||
| 91 | + const miniMap = lf.extension.miniMap; | ||
| 92 | + miniMap.updatePosition(position); | ||
| 93 | + position.value = position; | ||
| 94 | + } | ||
| 95 | +}; | ||
| 96 | + | ||
| 97 | +const updatePositionWithObject1 = () => { | ||
| 98 | + (lf?.extension.miniMap).updatePosition({ | ||
| 99 | + left: 100, | ||
| 100 | + top: 100, | ||
| 101 | + }); | ||
| 102 | +}; | ||
| 103 | + | ||
| 104 | +const updatePositionWithObject2 = () => { | ||
| 105 | + (lf?.extension.miniMap).updatePosition({ | ||
| 106 | + right: 100, | ||
| 107 | + bottom: 100, | ||
| 108 | + }); | ||
| 109 | +}; | ||
| 110 | +</script> | ||
| 111 | + | ||
| 112 | +<style scoped> | ||
| 113 | +.container { | ||
| 114 | + width: 100vw; | ||
| 115 | + height: 100vh; | ||
| 116 | + display: flex; | ||
| 117 | + flex-direction: column; | ||
| 118 | +} | ||
| 119 | + | ||
| 120 | +.flow-container { | ||
| 121 | + flex: 1; | ||
| 122 | + width: 100%; | ||
| 123 | + height: 100%; | ||
| 124 | +} | ||
| 125 | + | ||
| 126 | +.mini-map-container { | ||
| 127 | + position: absolute; | ||
| 128 | + bottom: 20px; | ||
| 129 | + right: 20px; | ||
| 130 | +} | ||
| 131 | +</style> |
-
Please register or login to post a comment