From 42f027fc7eec3669fdac0d0ce500fa80ba299e93 Mon Sep 17 00:00:00 2001 From: wangjiahao <1522128093@qq.com> Date: Tue, 2 Apr 2024 21:30:56 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E4=BB=AA=E8=A1=A8=E6=9D=BF):=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E5=90=AB=E6=9C=89=E9=A6=96=E9=80=89=E9=A1=B9=E7=9A=84?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E5=9C=A8tab=E9=A1=B5=E9=9D=A2=E4=B8=AD?= =?UTF-8?q?=E5=AE=B9=E6=98=93=E6=98=BE=E7=A4=BA=E9=94=99=E4=BD=8D=E9=97=AE?= =?UTF-8?q?=E9=A2=98#8569?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../canvas/components/editor/Preview.vue | 35 ++++++++----------- .../src/components/canvas/utils/utils.js | 9 +++-- core/frontend/src/store/index.js | 4 +++ 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/core/frontend/src/components/canvas/components/editor/Preview.vue b/core/frontend/src/components/canvas/components/editor/Preview.vue index e95a517e29..6669efb492 100644 --- a/core/frontend/src/components/canvas/components/editor/Preview.vue +++ b/core/frontend/src/components/canvas/components/editor/Preview.vue @@ -260,7 +260,7 @@ export default { showPosition: { type: String, required: false, - default: 'NotProvided' + default: 'preview' }, panelInfo: { type: Object, @@ -828,26 +828,21 @@ export default { if (this.componentData) { const componentData = deepCopy(this.componentData) componentData.forEach(component => { - if (!this.isMainCanvas() && component.type === 'custom' && component.options?.attrs?.selectFirst && this.format(component.style.width, this.scaleWidth) < 80) { - // do continue - } else { - Object.keys(component.style).forEach(key => { - if (this.needToChangeHeight.includes(key)) { - component.style[key] = this.format(component.style[key], this.scaleHeight) + Object.keys(component.style).forEach(key => { + if (this.needToChangeHeight.includes(key)) { + component.style[key] = this.format(component.style[key], this.scaleHeight) + } + if (this.needToChangeWidth.includes(key)) { + component.style[key] = this.format(component.style[key], this.scaleWidth) + } + if (this.needToChangeInnerWidth.includes(key)) { + if ((key === 'fontSize' || key === 'activeFontSize') && (this.terminal === 'mobile' || ['custom'].includes(component.type))) { + // do nothing 移动端字符大小无需按照比例缩放,当前保持不变(包括 v-text 和 过滤组件) + } else { + component.style[key] = this.formatPoint(component.style[key], this.previewCanvasScale.scalePointWidth) } - if (this.needToChangeWidth.includes(key)) { - component.style[key] = this.format(component.style[key], this.scaleWidth) - } - if (this.needToChangeInnerWidth.includes(key)) { - if ((key === 'fontSize' || key === 'activeFontSize') && (this.terminal === 'mobile' || ['custom'].includes(component.type))) { - // do nothing 移动端字符大小无需按照比例缩放,当前保持不变(包括 v-text 和 过滤组件) - } else { - component.style[key] = this.formatPoint(component.style[key], this.previewCanvasScale.scalePointWidth) - } - } - }) - } - + } + }) const maxWidth = this.canvasStyleData.width * this.scaleWidth / 100 if (component.style['width'] > maxWidth) { component.style['width'] = maxWidth diff --git a/core/frontend/src/components/canvas/utils/utils.js b/core/frontend/src/components/canvas/utils/utils.js index 60fea8b7f7..79fea5122c 100644 --- a/core/frontend/src/components/canvas/utils/utils.js +++ b/core/frontend/src/components/canvas/utils/utils.js @@ -179,10 +179,12 @@ export function panelDataPrepare(componentData, componentStyle, callback) { }) // 初始化密度为最高密度 componentStyle.aidedDesign.matrixBase = 4 - callback({ + const result = { 'componentData': resetID(componentData), 'componentStyle': componentStyle - }) + } + store.state.sourceComponentData = deepCopy(result.componentData) + callback(result) } export function resetID(data) { @@ -307,6 +309,9 @@ export function imgUrlTrans(url) { export function getNowCanvasComponentData(canvasId, showPosition) { if (showPosition && (showPosition.includes('email-task') || showPosition.includes('multiplexing'))) { return store.state.previewComponentData.filter(item => item.canvasId === canvasId) + } else if (showPosition === 'preview') { + console.log('test===' + JSON.stringify(deepCopy(store.state.sourceComponentData.filter(item => item.canvasId === canvasId)))) + return deepCopy(store.state.sourceComponentData.filter(item => item.canvasId === canvasId)) } else { return store.state.componentData.filter(item => item.canvasId === canvasId) } diff --git a/core/frontend/src/store/index.js b/core/frontend/src/store/index.js index 077498ebfe..e16296b2a8 100644 --- a/core/frontend/src/store/index.js +++ b/core/frontend/src/store/index.js @@ -154,6 +154,7 @@ const data = { }, previewVisible: false, previewComponentData: [], + sourceComponentData: [], currentCanvasNewId: [], lastViewRequestInfo: {}, multiplexingStyleAdapt: true, // 复用样式跟随主题 @@ -261,6 +262,9 @@ const data = { setPreviewComponentData(state, previewComponentData = []) { Vue.set(state, 'previewComponentData', previewComponentData) }, + setSourceComponentData(state, sourceComponentData = []) { + Vue.set(state, 'sourceComponentData', sourceComponentData) + }, setComponentViewsData(state, componentViewsData = {}) { Vue.set(state, 'componentViewsData', componentViewsData) },