优化代码
This commit is contained in:
parent
a798a40fab
commit
19da1a4ff3
@ -860,8 +860,8 @@ export default {
|
|||||||
// 自定义配置...
|
// 自定义配置...
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// "layout": "logicalStructure",
|
"layout": "logicalStructure",
|
||||||
// "layout": "mindMap",
|
// "layout": "mindMap",
|
||||||
// "layout": "catalogOrganization"
|
// "layout": "catalogOrganization"
|
||||||
"layout": "organizationStructure"
|
// "layout": "organizationStructure"
|
||||||
}
|
}
|
||||||
@ -87,6 +87,16 @@ class Base {
|
|||||||
return newNode;
|
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
|
* javascript comment
|
||||||
* @Author: 王林25
|
* @Author: 王林25
|
||||||
|
|||||||
@ -49,8 +49,7 @@ class CatalogOrganization extends Base {
|
|||||||
let newNode = this.createNode(cur, parent, isRoot, layerIndex)
|
let newNode = this.createNode(cur, parent, isRoot, layerIndex)
|
||||||
// 根节点定位在画布中心位置
|
// 根节点定位在画布中心位置
|
||||||
if (isRoot) {
|
if (isRoot) {
|
||||||
newNode.left = (this.mindMap.width - newNode.width) / 2
|
this.setNodeCenter(newNode)
|
||||||
newNode.top = (this.mindMap.height - newNode.height) / 2
|
|
||||||
} else {
|
} else {
|
||||||
// 非根节点
|
// 非根节点
|
||||||
if (parent._node.isRoot) {
|
if (parent._node.isRoot) {
|
||||||
|
|||||||
@ -49,8 +49,7 @@ class LogicalStructure extends Base {
|
|||||||
let newNode = this.createNode(cur, parent, isRoot, layerIndex)
|
let newNode = this.createNode(cur, parent, isRoot, layerIndex)
|
||||||
// 根节点定位在画布中心位置
|
// 根节点定位在画布中心位置
|
||||||
if (isRoot) {
|
if (isRoot) {
|
||||||
newNode.left = (this.mindMap.width - newNode.width) / 2
|
this.setNodeCenter(newNode)
|
||||||
newNode.top = (this.mindMap.height - newNode.height) / 2
|
|
||||||
} else {
|
} else {
|
||||||
// 非根节点
|
// 非根节点
|
||||||
// 定位到父节点右侧
|
// 定位到父节点右侧
|
||||||
|
|||||||
@ -50,8 +50,7 @@ class MindMap extends Base {
|
|||||||
let newNode = this.createNode(cur, parent, isRoot, layerIndex)
|
let newNode = this.createNode(cur, parent, isRoot, layerIndex)
|
||||||
// 根节点定位在画布中心位置
|
// 根节点定位在画布中心位置
|
||||||
if (isRoot) {
|
if (isRoot) {
|
||||||
newNode.left = (this.mindMap.width - newNode.width) / 2
|
this.setNodeCenter(newNode)
|
||||||
newNode.top = (this.mindMap.height - newNode.height) / 2
|
|
||||||
} else {
|
} else {
|
||||||
// 非根节点
|
// 非根节点
|
||||||
// 三级及以下节点以上级为准
|
// 三级及以下节点以上级为准
|
||||||
|
|||||||
@ -50,8 +50,7 @@ class OrganizationStructure extends Base {
|
|||||||
let newNode = this.createNode(cur, parent, isRoot, layerIndex)
|
let newNode = this.createNode(cur, parent, isRoot, layerIndex)
|
||||||
// 根节点定位在画布中心位置
|
// 根节点定位在画布中心位置
|
||||||
if (isRoot) {
|
if (isRoot) {
|
||||||
newNode.left = (this.mindMap.width - newNode.width) / 2
|
this.setNodeCenter(newNode)
|
||||||
newNode.top = (this.mindMap.height - newNode.height) / 2
|
|
||||||
} else {
|
} else {
|
||||||
// 非根节点
|
// 非根节点
|
||||||
// 定位到父节点下方
|
// 定位到父节点下方
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user