diff --git a/frontend/src/components/canvas/components/Editor/Preview.vue b/frontend/src/components/canvas/components/Editor/Preview.vue index 2dbc6c18d3..ccdf7bcd8e 100644 --- a/frontend/src/components/canvas/components/Editor/Preview.vue +++ b/frontend/src/components/canvas/components/Editor/Preview.vue @@ -9,7 +9,7 @@ @mouseup="deselectCurComponent" @mousedown="handleMouseDown" > - + {{ $t('panel.panelNull') }} @@ -103,7 +103,15 @@ export default { searchCount: 0, chartDetailsVisible: false, showChartInfo: {}, - showChartTableInfo: {} + showChartTableInfo: {}, + // 布局展示 1.pc pc端布局 2.mobile 移动端布局 + terminal: 'pc' + } + }, + created() { + const terminalInfo = this.$route.query.terminal + if (terminalInfo) { + this.terminal = terminalInfo } }, computed: { @@ -158,16 +166,15 @@ export default { mounted() { const _this = this const erd = elementResizeDetectorMaker() - // 监听div变动事件 - const mainDom = document.getElementById('canvasInfoMain') - erd.listenTo(mainDom, element => { + // 监听主div变动事件 + erd.listenTo(document.getElementById('canvasInfoMain'), element => { _this.$nextTick(() => { _this.restore() }) }) - // 监听div变动事件 + // 监听画布div变动事件 const tempCanvas = document.getElementById('canvasInfoTemp') - erd.listenTo(tempCanvas, element => { + erd.listenTo(document.getElementById('canvasInfoTemp'), element => { _this.$nextTick(() => { // 将mainHeight 修改为px 临时解决html2canvas 截图不全的问题 _this.mainHeight = tempCanvas.scrollHeight + 'px!important' @@ -176,6 +183,10 @@ export default { eventBus.$on('openChartDetailsDialog', this.openChartDetailsDialog) _this.$store.commit('clearLinkageSettingInfo', false) _this.canvasStyleDataInit() + // 如果当前终端设备是移动端,则进行移动端的布局设计 + if (_this.terminal === 'mobile') { + _this.initMobileCanvas() + } }, beforeDestroy() { clearInterval(this.timer) @@ -249,6 +260,9 @@ export default { }, handleMouseDown() { this.$store.commit('setClickComponentStatus', false) + }, + initMobileCanvas() { + this.$store.commit('openMobileLayout') } } } @@ -257,7 +271,7 @@ export default { diff --git a/frontend/src/components/canvas/components/Toolbar.vue b/frontend/src/components/canvas/components/Toolbar.vue index 8fb8e9271f..7a0ae083c2 100644 --- a/frontend/src/components/canvas/components/Toolbar.vue +++ b/frontend/src/components/canvas/components/Toolbar.vue @@ -347,25 +347,9 @@ export default { auxiliaryMatrixChange() { this.canvasStyleData.auxiliaryMatrix = !this.canvasStyleData.auxiliaryMatrix }, + // 启用移动端布局 openMobileLayout() { - this.$store.commit('setComponentDataCache', JSON.stringify(this.componentData)) - this.$store.commit('setPcComponentData', this.componentData) - const mainComponentData = [] - // 移动端布局转换 - this.componentData.forEach(item => { - if (item.mobileSelected) { - item.style = item.mobileStyle.style - item.x = item.mobileStyle.x - item.y = item.mobileStyle.y - item.sizex = item.mobileStyle.sizex - item.sizey = item.mobileStyle.sizey - item.auxiliaryMatrix = item.mobileStyle.auxiliaryMatrix - mainComponentData.push(item) - } - }) - - this.$store.commit('setComponentData', mainComponentData) - this.$store.commit('setMobileLayoutStatus', !this.mobileLayoutStatus) + this.$store.commit('openMobileLayout') }, editSave() { if (this.mobileLayoutStatus) { diff --git a/frontend/src/store/index.js b/frontend/src/store/index.js index 33b785240a..7eeadb1c1b 100644 --- a/frontend/src/store/index.js +++ b/frontend/src/store/index.js @@ -325,6 +325,26 @@ const data = { }, setMobileLayoutStatus(state, status) { state.mobileLayoutStatus = status + }, + // 启用移动端布局 + openMobileLayout(state) { + state.componentDataCache = JSON.stringify(state.componentData) + state.pcComponentData = state.componentData + const mainComponentData = [] + // 移动端布局转换 + state.componentData.forEach(item => { + if (item.mobileSelected) { + item.style = item.mobileStyle.style + item.x = item.mobileStyle.x + item.y = item.mobileStyle.y + item.sizex = item.mobileStyle.sizex + item.sizey = item.mobileStyle.sizey + item.auxiliaryMatrix = item.mobileStyle.auxiliaryMatrix + mainComponentData.push(item) + } + }) + state.componentData = mainComponentData + state.mobileLayoutStatus = !state.mobileLayoutStatus } }, modules: { diff --git a/frontend/src/views/panel/edit/ComponentWait.vue b/frontend/src/views/panel/edit/ComponentWait.vue index c7e8ccfd96..bff2b46bb7 100644 --- a/frontend/src/views/panel/edit/ComponentWait.vue +++ b/frontend/src/views/panel/edit/ComponentWait.vue @@ -82,7 +82,6 @@ export default { width: 100%; height: calc(100% - 30px); overflow-y: auto; - background-color: lightgray; } .component-custom { outline: none; diff --git a/frontend/src/views/panel/edit/ComponentWaitItem.vue b/frontend/src/views/panel/edit/ComponentWaitItem.vue index 3dacf4d900..22f9243a7d 100644 --- a/frontend/src/views/panel/edit/ComponentWaitItem.vue +++ b/frontend/src/views/panel/edit/ComponentWaitItem.vue @@ -8,6 +8,7 @@ v-if="config.type==='custom'" :id="'component' + config.id" class="component-custom" + :style="getComponentStyleDefault(config.style)" :out-style="outStyle" :element="config" /> @@ -17,6 +18,7 @@ ref="wrapperChild" :out-style="outStyle" :prop-value="config.propValue" + :style="getComponentStyleDefault(config.style)" :is-edit="false" :element="config" :h="itemHeight" @@ -27,6 +29,7 @@ diff --git a/frontend/src/views/panel/edit/index.vue b/frontend/src/views/panel/edit/index.vue index 2f25b2caa7..7064aee29b 100644 --- a/frontend/src/views/panel/edit/index.vue +++ b/frontend/src/views/panel/edit/index.vue @@ -125,13 +125,14 @@ - + @@ -336,6 +337,25 @@ export default { padding: this.componentGap + 'px' } }, + mobileCanvasStyle() { + let style + if (this.canvasStyleData.openCommonStyle) { + if (this.canvasStyleData.panel.backgroundType === 'image' && this.canvasStyleData.panel.imageUrl) { + style = { + background: `url(${this.canvasStyleData.panel.imageUrl}) no-repeat` + } + } else if (this.canvasStyleData.panel.backgroundType === 'color') { + style = { + background: this.canvasStyleData.panel.color + } + } else { + style = { + background: '#f7f8fa' + } + } + } + return style + }, customCanvasStyle() { let style = { padding: this.componentGap + 'px' @@ -684,7 +704,6 @@ export default { }, closeLeftPanel() { this.show = false - // this.beforeDestroy() }, previewFullScreen() { this.previewVisible = true @@ -975,6 +994,10 @@ export default { align-items: center; justify-content: center; } +.this_mobile_canvas_wait_cell{ + background-size:100% 100% !important; + border: 2px solid #9ea6b2 +} .this_canvas{ width: 100%;