diff --git a/simple-mind-map/src/utils/index.js b/simple-mind-map/src/utils/index.js index b3524ad8..7d1a8ea5 100644 --- a/simple-mind-map/src/utils/index.js +++ b/simple-mind-map/src/utils/index.js @@ -9,6 +9,13 @@ import { ForeignObject } from '@svgdotjs/svg.js' import merge from 'deepmerge' import { lineStyleProps } from '../theme/default' +// 可以在外部定义customFun,以实现自定义id生成规则 +export const createUidOption = { + defaultFun: () => uuidv4(), + customFun: null, +} + + // 深度优先遍历树 export const walk = ( root, @@ -484,7 +491,7 @@ export const getImageSize = src => { // 创建节点唯一的id export const createUid = () => { - return uuidv4() + return (typeof createUidOption?.customFun === 'function') ? createUidOption.customFun() : createUidOption.defaultFun() } // 加载图片文件