优化代码

This commit is contained in:
wanglin
2021-07-16 13:58:48 +08:00
parent a798a40fab
commit 19da1a4ff3
6 changed files with 16 additions and 10 deletions

View File

@@ -860,8 +860,8 @@ export default {
// 自定义配置...
}
},
// "layout": "logicalStructure",
"layout": "logicalStructure",
// "layout": "mindMap",
// "layout": "catalogOrganization"
"layout": "organizationStructure"
// "layout": "organizationStructure"
}

View File

@@ -87,6 +87,16 @@ class Base {
return newNode;
}
/**
* @Author: 王林
* @Date: 2021-07-16 13:48:43
* @Desc: 定位节点到画布中间
*/
setNodeCenter(node) {
node.left = (this.mindMap.width - node.width) / 2
node.top = (this.mindMap.height - node.height) / 2
}
/**
* javascript comment
* @Author: 王林25

View File

@@ -49,8 +49,7 @@ class CatalogOrganization extends Base {
let newNode = this.createNode(cur, parent, isRoot, layerIndex)
// 根节点定位在画布中心位置
if (isRoot) {
newNode.left = (this.mindMap.width - newNode.width) / 2
newNode.top = (this.mindMap.height - newNode.height) / 2
this.setNodeCenter(newNode)
} else {
// 非根节点
if (parent._node.isRoot) {

View File

@@ -49,8 +49,7 @@ class LogicalStructure extends Base {
let newNode = this.createNode(cur, parent, isRoot, layerIndex)
// 根节点定位在画布中心位置
if (isRoot) {
newNode.left = (this.mindMap.width - newNode.width) / 2
newNode.top = (this.mindMap.height - newNode.height) / 2
this.setNodeCenter(newNode)
} else {
// 非根节点
// 定位到父节点右侧

View File

@@ -50,8 +50,7 @@ class MindMap extends Base {
let newNode = this.createNode(cur, parent, isRoot, layerIndex)
// 根节点定位在画布中心位置
if (isRoot) {
newNode.left = (this.mindMap.width - newNode.width) / 2
newNode.top = (this.mindMap.height - newNode.height) / 2
this.setNodeCenter(newNode)
} else {
// 非根节点
// 三级及以下节点以上级为准

View File

@@ -50,8 +50,7 @@ class OrganizationStructure extends Base {
let newNode = this.createNode(cur, parent, isRoot, layerIndex)
// 根节点定位在画布中心位置
if (isRoot) {
newNode.left = (this.mindMap.width - newNode.width) / 2
newNode.top = (this.mindMap.height - newNode.height) / 2
this.setNodeCenter(newNode)
} else {
// 非根节点
// 定位到父节点下方