From ccd49bd345d4cfb83a3d66f9c5512a8b7894da87 Mon Sep 17 00:00:00 2001 From: "liu.shiyi" Date: Wed, 30 Aug 2023 09:32:48 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E4=BF=AE=E5=A4=8D=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E7=BB=84=E4=BB=B6=E8=AE=BE=E7=BD=AE=E4=B8=BB=E9=A2=98?= =?UTF-8?q?=E5=90=8E=E5=AF=BC=E5=85=A5=E5=88=B0=E5=A4=A7=E5=B1=8F=E4=B8=AD?= =?UTF-8?q?=E4=B8=BB=E9=A2=98=E5=88=87=E6=8D=A2=E5=A4=B1=E6=95=88=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data-room-ui/packages/BigScreenDesign/index.vue | 4 +++- data-room-ui/packages/Render/index.vue | 13 ++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/data-room-ui/packages/BigScreenDesign/index.vue b/data-room-ui/packages/BigScreenDesign/index.vue index e0ffa30c..2041576f 100644 --- a/data-room-ui/packages/BigScreenDesign/index.vue +++ b/data-room-ui/packages/BigScreenDesign/index.vue @@ -319,7 +319,9 @@ export default { group: randomStr, code: randomStr + chart.code } - this.$refs.Render.addChart(newChart, { x: chart.x, y: chart.y }, true) + // 如果是从组件库中添加的自定义组件,则不需要初始化theme + const isComponent = true + this.$refs.Render.addChart(newChart, { x: chart.x, y: chart.y }, isComponent) this.updateRightVisiable(false) }) }) diff --git a/data-room-ui/packages/Render/index.vue b/data-room-ui/packages/Render/index.vue index 0bf4665f..2b86eb6a 100644 --- a/data-room-ui/packages/Render/index.vue +++ b/data-room-ui/packages/Render/index.vue @@ -306,7 +306,7 @@ export default { this.hLine = hLine }, // 新增元素 - addChart (chart, position) { + addChart (chart, position, isComponent) { const { left, top } = this.$el.getBoundingClientRect() const _chart = !chart.code ? JSON.parse(chart) : chart let option = _chart.option @@ -330,12 +330,11 @@ export default { option } config.key = config.code - // TODO:新添加一个组件时应该有默认的两套主题 - // 先暂时只考虑g2组件 - // if (['customComponent'].includes(_chart.type)) { - config.theme = settingToTheme(config, 'dark') - config.theme = settingToTheme(config, 'light') - // } + // 1、从左侧新增时会初始化theme的内容 2、从组件库添加自定义组件时不用初始化 + if (!isComponent) { + config.theme = settingToTheme(config, 'dark') + config.theme = settingToTheme(config, 'light') + } this.addItem(config) }, addSourceChart (chart, position) {