Feat:修改节点uid的创建
This commit is contained in:
parent
94230f8ec6
commit
adccef5699
@ -32,9 +32,6 @@ class MindMap {
|
|||||||
this.svg = SVG().addTo(this.el).size(this.width, this.height)
|
this.svg = SVG().addTo(this.el).size(this.width, this.height)
|
||||||
this.draw = this.svg.group()
|
this.draw = this.svg.group()
|
||||||
|
|
||||||
// 节点id
|
|
||||||
this.uid = 1
|
|
||||||
|
|
||||||
// 初始化主题
|
// 初始化主题
|
||||||
this.initTheme()
|
this.initTheme()
|
||||||
|
|
||||||
@ -238,7 +235,7 @@ class MindMap {
|
|||||||
|
|
||||||
// 获取思维导图数据,节点树、主题、布局等
|
// 获取思维导图数据,节点树、主题、布局等
|
||||||
getData(withConfig) {
|
getData(withConfig) {
|
||||||
let nodeData = this.command.removeDataUid(this.command.getCopyData())
|
let nodeData = this.command.getCopyData()
|
||||||
let data = {}
|
let data = {}
|
||||||
if (withConfig) {
|
if (withConfig) {
|
||||||
data = {
|
data = {
|
||||||
|
|||||||
4
simple-mind-map/package-lock.json
generated
4
simple-mind-map/package-lock.json
generated
@ -1,11 +1,11 @@
|
|||||||
{
|
{
|
||||||
"name": "simple-mind-map",
|
"name": "simple-mind-map",
|
||||||
"version": "0.6.0",
|
"version": "0.6.7",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"version": "0.6.0",
|
"version": "0.6.7",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@svgdotjs/svg.js": "^3.0.16",
|
"@svgdotjs/svg.js": "^3.0.16",
|
||||||
|
|||||||
@ -89,7 +89,7 @@ class Command {
|
|||||||
this.history.shift()
|
this.history.shift()
|
||||||
}
|
}
|
||||||
this.activeHistoryIndex = this.history.length - 1
|
this.activeHistoryIndex = this.history.length - 1
|
||||||
this.mindMap.emit('data_change', this.removeDataUid(data))
|
this.mindMap.emit('data_change', data)
|
||||||
this.mindMap.emit(
|
this.mindMap.emit(
|
||||||
'back_forward',
|
'back_forward',
|
||||||
this.activeHistoryIndex,
|
this.activeHistoryIndex,
|
||||||
@ -110,7 +110,7 @@ class Command {
|
|||||||
this.history.length
|
this.history.length
|
||||||
)
|
)
|
||||||
let data = simpleDeepClone(this.history[this.activeHistoryIndex])
|
let data = simpleDeepClone(this.history[this.activeHistoryIndex])
|
||||||
this.mindMap.emit('data_change', this.removeDataUid(data))
|
this.mindMap.emit('data_change', data)
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -125,7 +125,7 @@ class Command {
|
|||||||
this.activeHistoryIndex += step
|
this.activeHistoryIndex += step
|
||||||
this.mindMap.emit('back_forward', this.activeHistoryIndex, this.history.length)
|
this.mindMap.emit('back_forward', this.activeHistoryIndex, this.history.length)
|
||||||
let data = simpleDeepClone(this.history[this.activeHistoryIndex])
|
let data = simpleDeepClone(this.history[this.activeHistoryIndex])
|
||||||
this.mindMap.emit('data_change', this.removeDataUid(data))
|
this.mindMap.emit('data_change', data)
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import Node from './Node'
|
import Node from './Node'
|
||||||
|
import { createUid } from '../../../utils/index'
|
||||||
|
|
||||||
// 检查是否存在概要
|
// 检查是否存在概要
|
||||||
function checkHasGeneralization () {
|
function checkHasGeneralization () {
|
||||||
@ -18,7 +19,7 @@ function createGeneralizationNode () {
|
|||||||
data: {
|
data: {
|
||||||
data: this.nodeData.data.generalization
|
data: this.nodeData.data.generalization
|
||||||
},
|
},
|
||||||
uid: this.mindMap.uid++,
|
uid: createUid(),
|
||||||
renderer: this.renderer,
|
renderer: this.renderer,
|
||||||
mindMap: this.mindMap,
|
mindMap: this.mindMap,
|
||||||
draw: this.draw,
|
draw: this.draw,
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import Node from '../core/render/node/Node'
|
import Node from '../core/render/node/Node'
|
||||||
import { CONSTANTS, initRootNodePositionMap } from '../constants/constant'
|
import { CONSTANTS, initRootNodePositionMap } from '../constants/constant'
|
||||||
import Lru from '../utils/Lru'
|
import Lru from '../utils/Lru'
|
||||||
|
import { createUid } from '../utils/index'
|
||||||
|
|
||||||
// 布局基类
|
// 布局基类
|
||||||
class Base {
|
class Base {
|
||||||
@ -101,7 +102,7 @@ class Base {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 创建新节点
|
// 创建新节点
|
||||||
let uid = this.mindMap.uid++
|
let uid = createUid()
|
||||||
newNode = new Node({
|
newNode = new Node({
|
||||||
data,
|
data,
|
||||||
uid,
|
uid,
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
import { v4 as uuidv4 } from 'uuid'
|
||||||
|
|
||||||
// 深度优先遍历树
|
// 深度优先遍历树
|
||||||
export const walk = (
|
export const walk = (
|
||||||
root,
|
root,
|
||||||
@ -424,3 +426,8 @@ export const getImageSize = src => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 创建节点唯一的id
|
||||||
|
export const createUid = () => {
|
||||||
|
return uuidv4()
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user