forked from github/dataease
fix: 移动端PC坐标转换自适应
This commit is contained in:
parent
adc77145c7
commit
d70fea56f9
@ -42,7 +42,7 @@
|
|||||||
"qs": "^6.11.0",
|
"qs": "^6.11.0",
|
||||||
"snowflake-id": "^1.1.0",
|
"snowflake-id": "^1.1.0",
|
||||||
"tinymce": "^5.8.2",
|
"tinymce": "^5.8.2",
|
||||||
"vant": "^4.8.2",
|
"vant": "^4.8.3",
|
||||||
"vue": "^3.3.4",
|
"vue": "^3.3.4",
|
||||||
"vue-clipboard3": "^2.0.0",
|
"vue-clipboard3": "^2.0.0",
|
||||||
"vue-codemirror": "^6.1.1",
|
"vue-codemirror": "^6.1.1",
|
||||||
|
@ -1,5 +1,13 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="shape" ref="shapeInnerRef" :id="domId" @dblclick="handleDbClick">
|
<div class="shape" ref="shapeInnerRef" :id="domId" @dblclick="handleDbClick">
|
||||||
|
<div v-if="showCheck" class="del-from-mobile" @click="delFromMobile">
|
||||||
|
<label class="el-checkbox el-checkbox--small is-checked"
|
||||||
|
><span class="el-checkbox__input is-checked"
|
||||||
|
><input class="el-checkbox__original" checked type="checkbox" /><span
|
||||||
|
class="el-checkbox__inner"
|
||||||
|
></span></span
|
||||||
|
></label>
|
||||||
|
</div>
|
||||||
<div
|
<div
|
||||||
class="shape-outer"
|
class="shape-outer"
|
||||||
v-show="contentDisplay"
|
v-show="contentDisplay"
|
||||||
@ -113,7 +121,8 @@ const {
|
|||||||
curLinkageView,
|
curLinkageView,
|
||||||
tabCollisionActiveId,
|
tabCollisionActiveId,
|
||||||
tabMoveInActiveId,
|
tabMoveInActiveId,
|
||||||
tabMoveOutComponentId
|
tabMoveOutComponentId,
|
||||||
|
mobileInPc
|
||||||
} = storeToRefs(dvMainStore)
|
} = storeToRefs(dvMainStore)
|
||||||
const { editorMap, areaData, isCtrlOrCmdDown } = storeToRefs(composeStore)
|
const { editorMap, areaData, isCtrlOrCmdDown } = storeToRefs(composeStore)
|
||||||
const emit = defineEmits([
|
const emit = defineEmits([
|
||||||
@ -126,6 +135,7 @@ const emit = defineEmits([
|
|||||||
'linkJumpSetOpen',
|
'linkJumpSetOpen',
|
||||||
'linkageSetOpen'
|
'linkageSetOpen'
|
||||||
])
|
])
|
||||||
|
|
||||||
const isEditMode = computed(() => editMode.value === 'edit')
|
const isEditMode = computed(() => editMode.value === 'edit')
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
seriesIdMap: {
|
seriesIdMap: {
|
||||||
@ -246,6 +256,17 @@ const initialAngle = {
|
|||||||
}
|
}
|
||||||
const cursors = ref({})
|
const cursors = ref({})
|
||||||
|
|
||||||
|
const showCheck = computed(() => {
|
||||||
|
return mobileInPc.value && element.value.canvasId === 'canvas-main'
|
||||||
|
})
|
||||||
|
|
||||||
|
const delFromMobile = () => {
|
||||||
|
useEmitt().emitter.emit('onMobileStatusChange', {
|
||||||
|
type: 'delFromMobile',
|
||||||
|
value: element.value.id
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const angleToCursor = [
|
const angleToCursor = [
|
||||||
// 每个范围的角度对应的光标
|
// 每个范围的角度对应的光标
|
||||||
{ start: 338, end: 23, cursor: 'nw' },
|
{ start: 338, end: 23, cursor: 'nw' },
|
||||||
@ -879,6 +900,13 @@ onMounted(() => {
|
|||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
.shape {
|
.shape {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|
||||||
|
.del-from-mobile {
|
||||||
|
position: absolute;
|
||||||
|
right: 5px;
|
||||||
|
top: 5px;
|
||||||
|
z-index: 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.shape-shadow {
|
.shape-shadow {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref, onMounted, unref, onBeforeUnmount, computed } from 'vue'
|
import { ref, onMounted, unref, onBeforeUnmount, computed } from 'vue'
|
||||||
|
import eventBus from '@/utils/eventBus'
|
||||||
import { useEmitt } from '@/hooks/web/useEmitt'
|
import { useEmitt } from '@/hooks/web/useEmitt'
|
||||||
import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain'
|
import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain'
|
||||||
import { getStyle } from '@/utils/style'
|
import { getStyle } from '@/utils/style'
|
||||||
@ -33,7 +34,9 @@ const handleLoad = () => {
|
|||||||
'panelInit',
|
'panelInit',
|
||||||
JSON.parse(
|
JSON.parse(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
componentData: JSON.parse(JSON.stringify(unref(componentData))),
|
componentData: JSON.parse(
|
||||||
|
JSON.stringify(unref(componentData.value.filter(ele => !!ele.inMobile)))
|
||||||
|
),
|
||||||
canvasStyleData: JSON.parse(JSON.stringify(unref(canvasStyleData))),
|
canvasStyleData: JSON.parse(JSON.stringify(unref(canvasStyleData))),
|
||||||
canvasViewInfo: JSON.parse(JSON.stringify(unref(canvasViewInfo))),
|
canvasViewInfo: JSON.parse(JSON.stringify(unref(canvasViewInfo))),
|
||||||
dvInfo: JSON.parse(JSON.stringify(unref(dvInfo)))
|
dvInfo: JSON.parse(JSON.stringify(unref(dvInfo)))
|
||||||
@ -51,6 +54,31 @@ const hanedleMessage = event => {
|
|||||||
mobileLoading.value = false
|
mobileLoading.value = false
|
||||||
handleLoad()
|
handleLoad()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (event.data.type === 'delFromMobile') {
|
||||||
|
componentData.value.some(ele => {
|
||||||
|
if (ele.id === event.data.value) {
|
||||||
|
ele.inMobile = false
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.data.type === 'mobileSaveFromMobile') {
|
||||||
|
componentData.value.forEach(ele => {
|
||||||
|
const com = event.data.value[ele.id]
|
||||||
|
if (!!com) {
|
||||||
|
const { x, y, sizeX, sizeY } = com
|
||||||
|
ele.mx = x
|
||||||
|
ele.my = y
|
||||||
|
ele.mSizeX = sizeX
|
||||||
|
ele.mSizeY = sizeY
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
eventBus.emit('save')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
window.addEventListener('message', hanedleMessage)
|
window.addEventListener('message', hanedleMessage)
|
||||||
@ -81,6 +109,11 @@ const addToMobile = com => {
|
|||||||
<Icon class="toolbar-icon" name="icon_left_outlined" />
|
<Icon class="toolbar-icon" name="icon_left_outlined" />
|
||||||
</el-icon>
|
</el-icon>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="mobile-save">
|
||||||
|
<el-button type="primary" @click="mobileStatusChange('mobileSave', undefined)"
|
||||||
|
>保存</el-button
|
||||||
|
>
|
||||||
|
</div>
|
||||||
<div class="mobile-canvas">
|
<div class="mobile-canvas">
|
||||||
<div class="config-panel-title">{{ dvInfo.name }}</div>
|
<div class="config-panel-title">{{ dvInfo.name }}</div>
|
||||||
<div class="config-panel-content" v-loading="mobileLoading">
|
<div class="config-panel-content" v-loading="mobileLoading">
|
||||||
@ -120,7 +153,7 @@ const addToMobile = com => {
|
|||||||
/>
|
/>
|
||||||
<div class="mobile-com-mask"></div>
|
<div class="mobile-com-mask"></div>
|
||||||
|
|
||||||
<div class="pc-select-to-mobile" @click="addToMobile(config)"></div>
|
<div class="pc-select-to-mobile" v-if="!mobileLoading" @click="addToMobile(config)"></div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
@ -132,6 +165,19 @@ const addToMobile = com => {
|
|||||||
height: 100vh;
|
height: 100vh;
|
||||||
width: 100vw;
|
width: 100vw;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
||||||
|
.mobile-to-pc {
|
||||||
|
position: absolute;
|
||||||
|
left: 20px;
|
||||||
|
top: 20px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mobile-save {
|
||||||
|
position: absolute;
|
||||||
|
right: 20px;
|
||||||
|
top: 20px;
|
||||||
|
}
|
||||||
.mobile-canvas {
|
.mobile-canvas {
|
||||||
border-radius: 30px;
|
border-radius: 30px;
|
||||||
width: 370px;
|
width: 370px;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { onBeforeMount, ref, onBeforeUnmount } from 'vue'
|
import { onBeforeMount, ref, onBeforeUnmount } from 'vue'
|
||||||
|
import { useEmitt } from '@/hooks/web/useEmitt'
|
||||||
import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain'
|
import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain'
|
||||||
const dvMainStore = dvMainStoreWithOut()
|
const dvMainStore = dvMainStoreWithOut()
|
||||||
import DePreviewMobile from './MobileInPc.vue'
|
import DePreviewMobile from './MobileInPc.vue'
|
||||||
@ -16,7 +17,14 @@ const checkItemPosition = component => {
|
|||||||
const hanedleMessage = event => {
|
const hanedleMessage = event => {
|
||||||
if (event.data.type === 'panelInit') {
|
if (event.data.type === 'panelInit') {
|
||||||
const { componentData, canvasStyleData, dvInfo, canvasViewInfo } = event.data.value
|
const { componentData, canvasStyleData, dvInfo, canvasViewInfo } = event.data.value
|
||||||
dvMainStore.setComponentData(componentData.filter(ele => !!ele.inMobile))
|
componentData.forEach(ele => {
|
||||||
|
const { mx, my, mSizeX, mSizeY } = ele
|
||||||
|
ele.x = mx
|
||||||
|
ele.y = my
|
||||||
|
ele.sizeX = mSizeX
|
||||||
|
ele.sizeY = mSizeY
|
||||||
|
})
|
||||||
|
dvMainStore.setComponentData(componentData)
|
||||||
dvMainStore.setMobileInPc(true)
|
dvMainStore.setMobileInPc(true)
|
||||||
dvMainStore.setCanvasStyle(canvasStyleData)
|
dvMainStore.setCanvasStyle(canvasStyleData)
|
||||||
dvMainStore.updateCurDvInfo(dvInfo)
|
dvMainStore.updateCurDvInfo(dvInfo)
|
||||||
@ -29,13 +37,39 @@ const hanedleMessage = event => {
|
|||||||
checkItemPosition(component)
|
checkItemPosition(component)
|
||||||
dvMainStore.componentData.push(component)
|
dvMainStore.componentData.push(component)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (event.data.type === 'mobileSave') {
|
||||||
|
window.top.postMessage(
|
||||||
|
{
|
||||||
|
type: 'mobileSaveFromMobile',
|
||||||
|
value: dvMainStore.componentData.reduce((pre, next) => {
|
||||||
|
const { x, y, sizeX, sizeY, id } = next
|
||||||
|
pre[id] = { x, y, sizeX, sizeY }
|
||||||
|
return pre
|
||||||
|
}, {})
|
||||||
|
},
|
||||||
|
'*'
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onBeforeMount(() => {
|
onBeforeMount(() => {
|
||||||
window.top.postMessage({ type: 'panelInit', value: true }, '*')
|
window.top.postMessage({ type: 'panelInit', value: true }, '*')
|
||||||
window.addEventListener('message', hanedleMessage)
|
window.addEventListener('message', hanedleMessage)
|
||||||
|
useEmitt({
|
||||||
|
name: 'onMobileStatusChange',
|
||||||
|
callback: ({ type, value }) => {
|
||||||
|
mobileStatusChange(type, value)
|
||||||
|
}
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const mobileStatusChange = (type, value) => {
|
||||||
|
window.top.postMessage({ type, value }, '*')
|
||||||
|
if (type === 'delFromMobile') {
|
||||||
|
dvMainStore.setComponentData(dvMainStore.componentData.filter(ele => ele.id !== value))
|
||||||
|
}
|
||||||
|
}
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
window.removeEventListener('message', hanedleMessage)
|
window.removeEventListener('message', hanedleMessage)
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user