Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
logic-flow2
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
hookehuyr
2025-03-14 15:24:15 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
723acb6df74f37f328f61e8a8d7c109b7b1677e0
723acb6d
1 parent
7aaf0820
动态分组
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
178 additions
and
1 deletions
src/router/index.js
src/views/dynamic-group/index.vue
src/views/home.vue
src/router/index.js
View file @
723acb6
...
...
@@ -115,6 +115,11 @@ const router = createRouter({
name
:
'snapshot'
,
component
:
()
=>
import
(
'../views/snapshot/index.vue'
)
},
{
path
:
'/dynamic-group'
,
name
:
'dynamic-group'
,
component
:
()
=>
import
(
'../views/dynamic-group/index.vue'
)
},
]
})
...
...
src/views/dynamic-group/index.vue
0 → 100644
View file @
723acb6
<template>
<div class="container">
<div ref="container" class="flow-container"></div>
<div class="control-panel">
<el-button @click="openSelectionSelect">选区</el-button>
<div v-for="item in dndConfig" :key="item.type" class="dnd-item">
<img :src="item.icon" :alt="item.label" />
<span>{{ item.label }}</span>
</div>
</div>
</div>
</template>
<script setup>
import LogicFlow from "@logicflow/core";
import { DynamicGroup } from "@logicflow/extension";
const container = ref(null);
let lf = null;
// 拖拽面板配置
const dndConfig = [
{
type: 'dynamic-group',
label: '内置动态分组',
text: 'DynamicGroup',
icon: 'https://cdn.jsdelivr.net/gh/Logic-Flow/static@latest/docs/examples/extension/group/group.png',
},
{
type: 'circle',
label: '圆形',
text: 'Circle',
icon: 'https://cdn.jsdelivr.net/gh/Logic-Flow/static@latest/docs/examples/extension/group/circle.png',
},
{
type: 'rect',
label: '矩形',
text: 'Rect',
icon: 'https://cdn.jsdelivr.net/gh/Logic-Flow/static@latest/docs/examples/extension/group/rect.png',
},
];
// 选区功能
const openSelectionSelect = () => {
if (lf) {
lf.openSelectionSelect();
lf.once('selection:selected', () => {
lf.closeSelectionSelect();
});
}
};
onMounted(() => {
lf = new LogicFlow({
container: container.value,
grid: true,
multipleSelectKey: "alt",
autoExpand: false,
allowResize: true,
allowRotate: true,
nodeTextDraggable: false,
keyboard: {
enabled: true,
},
plugins: [DynamicGroup],
});
// 设置拖拽面板
const dndPanelConfig = [
{
label: '选区',
icon: 'https://cdn.jsdelivr.net/gh/Logic-Flow/static@latest/docs/examples/extension/bpmn/select.png',
callback: openSelectionSelect,
},
...dndConfig,
];
lf.setPatternItems(dndPanelConfig);
// 渲染数据
const graphData = {
nodes: [
{
id: 'circle_2',
type: 'circle',
x: 800,
y: 140,
text: {
value: 'circle_2',
x: 800,
y: 140,
editable: false,
draggable: true,
},
},
{
id: 'dynamic-group_1',
type: 'dynamic-group',
x: 500,
y: 140,
text: 'dynamic-group_1',
resizable: true,
properties: {
collapsible: true,
width: 420,
height: 250,
radius: 5,
isCollapsed: true,
},
},
{
id: 'dynamic-group_2',
type: 'dynamic-group',
x: 500,
y: 220,
text: 'dynamic-group_2',
resizable: true,
properties: {
width: 420,
height: 250,
radius: 5,
collapsible: false,
isCollapsed: false,
},
},
],
edges: [],
};
lf.render(graphData);
});
</script>
<style scoped>
.container {
width: 100vw;
height: 100vh;
display: flex;
flex-direction: column;
}
.flow-container {
flex: 1;
width: 100%;
height: 100%;
}
.control-panel {
position: absolute;
top: 20px;
left: 20px;
display: flex;
gap: 10px;
align-items: center;
}
.dnd-item {
display: flex;
flex-direction: column;
align-items: center;
cursor: pointer;
padding: 8px;
border: 1px solid #ddd;
border-radius: 4px;
}
.dnd-item img {
width: 24px;
height: 24px;
margin-bottom: 4px;
}
</style>
src/views/home.vue
View file @
723acb6
<!--
* @Date: 2025-03-10 14:37:31
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-03-1
3 23:00:31
* @LastEditTime: 2025-03-1
4 13:53:06
* @FilePath: /logic-flow2/src/views/home.vue
* @Description: 文件描述
-->
...
...
@@ -27,6 +27,7 @@
<el-button type="primary" @click="goTo('mini-map')">mini-map</el-button>
<el-button type="primary" @click="goTo('selection-select')">selection-select</el-button>
<el-button type="primary" @click="goTo('snapshot')">snapshot</el-button>
<el-button type="primary" @click="goTo('dynamic-group')">dynamic-group</el-button>
</template>
<script setup>
...
...
Please
register
or
login
to post a comment