From 5bb23ca7389565456734922d0e444d21552971dc Mon Sep 17 00:00:00 2001 From: wanglin2 <1013335014@qq.com> Date: Fri, 28 Apr 2023 22:07:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=B8=BB=E9=A2=98=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=9B=B4=E6=96=B0,=E6=94=B9=E5=8F=98=E4=B8=8D?= =?UTF-8?q?=E6=B6=89=E5=8F=8A=E8=8A=82=E7=82=B9=E5=A4=A7=E5=B0=8F=E7=9A=84?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E4=B8=8D=E8=A7=A6=E5=8F=91=E8=8A=82=E7=82=B9?= =?UTF-8?q?=E9=87=8D=E6=96=B0=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simple-mind-map/index.js | 6 +++-- simple-mind-map/src/themes/default.js | 34 +++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/simple-mind-map/index.js b/simple-mind-map/index.js index 32a23c7b..1b283f4c 100644 --- a/simple-mind-map/index.js +++ b/simple-mind-map/index.js @@ -10,7 +10,7 @@ import BatchExecution from './src/BatchExecution' import { layoutValueList, CONSTANTS } from './src/utils/constant' import { SVG } from '@svgdotjs/svg.js' import { simpleDeepClone } from './src/utils' -import defaultTheme from './src/themes/default' +import defaultTheme, { checkIsNodeSizeIndependenceConfig } from './src/themes/default' // 默认选项配置 const defaultOpt = { @@ -267,7 +267,9 @@ class MindMap { // 设置主题配置 setThemeConfig(config) { this.opt.themeConfig = config - this.render(null, CONSTANTS.CHANGE_THEME) + // 检查改变的是否是节点大小无关的主题属性 + let res = checkIsNodeSizeIndependenceConfig(config) + this.render(null, res ? '' : CONSTANTS.CHANGE_THEME) } // 获取自定义主题配置 diff --git a/simple-mind-map/src/themes/default.js b/simple-mind-map/src/themes/default.js index 2b5e95cd..c9d9bfa6 100644 --- a/simple-mind-map/src/themes/default.js +++ b/simple-mind-map/src/themes/default.js @@ -156,4 +156,38 @@ export const supportActiveStyle = [ 'borderRadius' ] +// 检测主题配置是否是节点大小无关的 +const nodeSizeIndependenceList = [ + 'lineWidth', + 'lineColor', + 'lineDasharray', + 'lineStyle', + 'generalizationLineWidth', + 'generalizationLineColor', + 'associativeLineWidth', + 'associativeLineColor', + 'associativeLineActiveWidth', + 'associativeLineActiveColor', + 'associativeLineTextColor', + 'associativeLineTextFontSize', + 'associativeLineTextLineHeight', + 'associativeLineTextFontFamily', + 'backgroundColor', + 'backgroundImage', + 'backgroundRepeat', + 'backgroundPosition', + 'backgroundSize' +] +export const checkIsNodeSizeIndependenceConfig = (config) => { + let keys = Object.keys(config) + for(let i = 0; i < keys.length; i++) { + if (!nodeSizeIndependenceList.find((item) => { + return item === keys[i] + })) { + return false + } + } + return true +} + export const lineStyleProps = ['lineColor', 'lineDasharray', 'lineWidth']