From c22c3605eb2b691a9cda7943c33ba257c427ec67 Mon Sep 17 00:00:00 2001 From: wangjiahao <1522128093@qq.com> Date: Thu, 1 Aug 2024 11:00:08 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=B7=A5=E4=BD=9C=E5=8F=B0):=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E5=AF=BC=E5=87=BA=E7=9A=84=E6=A8=A1=E6=9D=BF=E5=86=8D?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E5=88=B0=E6=A8=A1=E6=9D=BF=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E4=B8=AD=E6=97=A0=E6=B3=95=E4=BD=BF=E7=94=A8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/DataVisualizationServer.java | 19 +++++++++++++------ core/core-frontend/src/utils/imgUtils.ts | 2 +- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/core/core-backend/src/main/java/io/dataease/visualization/server/DataVisualizationServer.java b/core/core-backend/src/main/java/io/dataease/visualization/server/DataVisualizationServer.java index e53d980086..27461a0363 100644 --- a/core/core-backend/src/main/java/io/dataease/visualization/server/DataVisualizationServer.java +++ b/core/core-backend/src/main/java/io/dataease/visualization/server/DataVisualizationServer.java @@ -576,12 +576,19 @@ public class DataVisualizationServer implements DataVisualizationApi { // 模板市场记录 coreOptRecentManage.saveOpt(request.getResourceName(), OptConstants.OPT_RESOURCE_TYPE.TEMPLATE, OptConstants.OPT_TYPE.NEW); } - if(StringUtils.isNotEmpty(appDataStr)){ - VisualizationExport2AppVO appDataFormat = JsonUtil.parseObject(appDataStr,VisualizationExport2AppVO.class); - String dvInfo = appDataFormat.getVisualizationInfo(); - VisualizationBaseInfoVO baseInfoVO = JsonUtil.parseObject(dvInfo,VisualizationBaseInfoVO.class); - Long sourceDvId = baseInfoVO.getId(); - appDataStr = appDataStr.replaceAll(sourceDvId.toString(), newDvId.toString()); + if(StringUtils.isNotEmpty(appDataStr) && appDataStr.length()>10){ + try{ + VisualizationExport2AppVO appDataFormat = JsonUtil.parseObject(appDataStr,VisualizationExport2AppVO.class); + String dvInfo = appDataFormat.getVisualizationInfo(); + VisualizationBaseInfoVO baseInfoVO = JsonUtil.parseObject(dvInfo,VisualizationBaseInfoVO.class); + Long sourceDvId = baseInfoVO.getId(); + appDataStr = appDataStr.replaceAll(sourceDvId.toString(), newDvId.toString()); + }catch (Exception e){ + LogUtil.error(e); + appDataStr = null; + } + }else{ + appDataStr = null; } // 解析动态数据 Map dynamicDataMap = JsonUtil.parseObject(dynamicData, Map.class); diff --git a/core/core-frontend/src/utils/imgUtils.ts b/core/core-frontend/src/utils/imgUtils.ts index 0aa5825cde..f824dda73a 100644 --- a/core/core-frontend/src/utils/imgUtils.ts +++ b/core/core-frontend/src/utils/imgUtils.ts @@ -56,7 +56,7 @@ export function download2AppTemplate(downloadType, canvasDom, name, attachParams componentData: JSON.stringify(componentData.value), dynamicData: JSON.stringify(canvasViewDataTemplate), staticResource: JSON.stringify(staticResource || {}), - appData: JSON.stringify(attachParams || {}) + appData: attachParams ? JSON.stringify(attachParams) : null } const blob = new Blob([JSON.stringify(templateInfo)], { type: '' }) if (downloadType === 'template') {