LogicFlow(Vue3)
vue
vuejs/vue: 是一个用于构建用户界面的 JavaScript 框架,具有简洁的语法和丰富的组件库,可以用于开发单页面应用程序和多页面应用程序。
项目地址:https://gitcode.com/gh_mirrors/vu/vue
·
步骤1.安装
//LogicFlow
npm install @logicflow/core --save
//LogicFlow组件
npm install @logicflow/extension --save
快速上手
// 创建容器
<div id="container"></div>
// 准备数据
const data = {
// 节点
nodes: [
{id: 21, type: 'rect',x: 100,y: 200,text: {value: '矩形节点',x: 100,y: 200}},
{id: 50,type: 'circle', x: 300,y: 400,text: {value: '圆形节点',x: 300,y: 400}},
],
// 边
edges:[
{type: 'polyline', sourceNodeId: 50,targetNodeId: 21 }
]
}
// 渲染画布
const lf = new LogicFlow({
container: document.querySelector('#container'),
width: 700,
height: 600,
});
lf.render(data);
步骤2.准备节点侧边栏
<!--组件栏-->
<div class="node-panel">
<div class="node-item" @mousedown='methods.mouseDownHandle(item)' v-for="(item,index) in shapeList" :key="index">
<div class="node-item-icon" :class="item.class">
<span class="node-label">{{item.text}}</span>
</div>
</div>
</div>
shapeList: [
{type: 'rect', text: '矩形',class:'node-rect'},
{type: 'circle', text: '圆形',class:'node-circle'},
{type: 'ellipse', text: '椭圆',class:'node-ellipse'},
{type: 'polygon', text: '多边形',class:'node-polygon'},
{type: 'my-rect', text: '自定义',class:'node-rect'},
],
拖拽事件 @mousedown:methods.mouseDownHandle(item)
/**
* 拖拽
* @param item 拖拽属性
*/
mouseDownHandle : function (item) {
data.lf.dnd.startDrag({
type:item.type,
text:item.text,
properties:{}
});
},
侧边栏的node样式(非专业前端,样式讲究凑合着看吧)
.node-panel {
width: 70px;
padding: 20px 0;
background-color: white;
box-shadow: 0 0 10px 1px rgb(228, 224, 219);
border-radius: 6px;
text-align: center;
z-index: 101;
}
.node-item {
margin-bottom: 20px;
}
.node-item-icon {
width: 30px;
height: 30px;
margin-left: 20px;
background-size: cover;
text-align: center;
}
.node-label {
font-size: 12px;
margin-top: 5px;
user-select: none;
}
.node-rect{
width: 40px;
height: 30px;
border: 2px solid black;
}
.node-circle{
width: 40px;
height: 40px;
border-radius: 50%;
border: 2px solid black;
}
.node-ellipse{
border: 2px solid black;
border-radius: 60%;
width: 40px;
height: 30px;
}
.node-polygon{
width: 40px;
height: 40px;
border: 2px solid black;
transform:rotate(45deg);
}
vuejs/vue: 是一个用于构建用户界面的 JavaScript 框架,具有简洁的语法和丰富的组件库,可以用于开发单页面应用程序和多页面应用程序。
最近提交(Master分支:2 个月前 )
9e887079
[skip ci] 1 年前
73486cb5
* chore: fix link broken
Signed-off-by: snoppy <michaleli@foxmail.com>
* Update packages/template-compiler/README.md [skip ci]
---------
Signed-off-by: snoppy <michaleli@foxmail.com>
Co-authored-by: Eduardo San Martin Morote <posva@users.noreply.github.com> 1 年前
AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。
更多推荐




所有评论(0)