From 9ebc0273339be4d5fb6f21b30c719d5dfcf6081e Mon Sep 17 00:00:00 2001 From: Misaki <491637568@qq.com> Date: Fri, 24 May 2024 11:21:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E7=94=9F=E6=88=90uid=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simple-mind-map/src/utils/index.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/simple-mind-map/src/utils/index.js b/simple-mind-map/src/utils/index.js index b192b9321..e734b186d 100644 --- a/simple-mind-map/src/utils/index.js +++ b/simple-mind-map/src/utils/index.js @@ -6,6 +6,13 @@ import { import MersenneTwister from './mersenneTwister' import { ForeignObject } from '@svgdotjs/svg.js' +// 可以在外部定义customFun,以实现自定义id生成规则 +export const createUidOption = { + defaultFun: () => uuidv4(), + customFun: null, +} + + // 深度优先遍历树 export const walk = ( root, @@ -446,7 +453,7 @@ export const getImageSize = src => { // 创建节点唯一的id export const createUid = () => { - return uuidv4() + return (typeof createUidOption?.customFun === 'function') ? createUidOption.customFun() : createUidOption.defaultFun() } // 加载图片文件