forked from github/dataease
refactor(嵌入式): 图表嵌入式消息发送优化
This commit is contained in:
parent
2ed0a2b36a
commit
091a7d6673
@ -83,7 +83,7 @@ const { config, showPosition, index, canvasStyleData, canvasViewInfo, dvInfo, se
|
|||||||
toRefs(props)
|
toRefs(props)
|
||||||
let currentInstance
|
let currentInstance
|
||||||
const component = ref(null)
|
const component = ref(null)
|
||||||
const emits = defineEmits(['userViewEnlargeOpen'])
|
const emits = defineEmits(['userViewEnlargeOpen', 'onPointClick'])
|
||||||
|
|
||||||
const htmlToImage = () => {
|
const htmlToImage = () => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@ -180,6 +180,10 @@ const commonBackgroundSvgInner = computed(() => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const onPointClick = param => {
|
||||||
|
emits('onPointClick', param)
|
||||||
|
}
|
||||||
|
|
||||||
const deepScale = computed(() => scale.value / 100)
|
const deepScale = computed(() => scale.value / 100)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -234,6 +238,7 @@ const deepScale = computed(() => scale.value / 100)
|
|||||||
:scale="deepScale"
|
:scale="deepScale"
|
||||||
:disabled="true"
|
:disabled="true"
|
||||||
:is-edit="false"
|
:is-edit="false"
|
||||||
|
@onPointClick="onPointClick"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -13,9 +13,10 @@ import { isMainCanvas } from '@/utils/canvasUtils'
|
|||||||
import { activeWatermark } from '@/components/watermark/watermark'
|
import { activeWatermark } from '@/components/watermark/watermark'
|
||||||
import { personInfoApi } from '@/api/user'
|
import { personInfoApi } from '@/api/user'
|
||||||
import router from '@/router'
|
import router from '@/router'
|
||||||
|
import { XpackComponent } from '@/components/plugin'
|
||||||
const dvMainStore = dvMainStoreWithOut()
|
const dvMainStore = dvMainStoreWithOut()
|
||||||
const { pcMatrixCount, curComponent, mobileInPc } = storeToRefs(dvMainStore)
|
const { pcMatrixCount, curComponent, mobileInPc } = storeToRefs(dvMainStore)
|
||||||
|
const openHandler = ref(null)
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
canvasStyleData: {
|
canvasStyleData: {
|
||||||
type: Object,
|
type: Object,
|
||||||
@ -281,6 +282,32 @@ const userViewEnlargeOpen = (opt, item) => {
|
|||||||
const handleMouseDown = () => {
|
const handleMouseDown = () => {
|
||||||
dvMainStore.setCurComponent({ component: null, index: null })
|
dvMainStore.setCurComponent({ component: null, index: null })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const onPointClick = param => {
|
||||||
|
try {
|
||||||
|
console.info('de_inner_params send')
|
||||||
|
if (window['dataease-embedded-host'] && openHandler?.value) {
|
||||||
|
const pm = {
|
||||||
|
methodName: 'embeddedInteractive',
|
||||||
|
args: {
|
||||||
|
eventName: 'de_inner_params',
|
||||||
|
args: param
|
||||||
|
}
|
||||||
|
}
|
||||||
|
openHandler.value.invokeMethod(pm)
|
||||||
|
} else {
|
||||||
|
console.info('de_inner_params send to host')
|
||||||
|
const targetPm = {
|
||||||
|
type: 'dataease-embedded-interactive',
|
||||||
|
eventName: 'de_inner_params',
|
||||||
|
args: param
|
||||||
|
}
|
||||||
|
window.parent.postMessage(targetPm, '*')
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.warn('de_inner_params send error')
|
||||||
|
}
|
||||||
|
}
|
||||||
defineExpose({
|
defineExpose({
|
||||||
restore
|
restore
|
||||||
})
|
})
|
||||||
@ -316,9 +343,11 @@ defineExpose({
|
|||||||
:scale="mobileInPc ? 100 : scaleWidth"
|
:scale="mobileInPc ? 100 : scaleWidth"
|
||||||
:is-selector="props.isSelector"
|
:is-selector="props.isSelector"
|
||||||
@userViewEnlargeOpen="userViewEnlargeOpen($event, item)"
|
@userViewEnlargeOpen="userViewEnlargeOpen($event, item)"
|
||||||
|
@onPointClick="onPointClick"
|
||||||
/>
|
/>
|
||||||
<user-view-enlarge ref="userViewEnlargeRef"></user-view-enlarge>
|
<user-view-enlarge ref="userViewEnlargeRef"></user-view-enlarge>
|
||||||
</div>
|
</div>
|
||||||
|
<XpackComponent ref="openHandler" jsname="L2NvbXBvbmVudC9lbWJlZGRlZC1pZnJhbWUvT3BlbkhhbmRsZXI=" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
|
@ -71,6 +71,11 @@ const autoStyle = computed(() => {
|
|||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
const emits = defineEmits(['onPointClick'])
|
||||||
|
|
||||||
|
const onPointClick = param => {
|
||||||
|
emits('onPointClick', param)
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@ -83,6 +88,7 @@ const autoStyle = computed(() => {
|
|||||||
:show-position="showPosition"
|
:show-position="showPosition"
|
||||||
:search-count="searchCount"
|
:search-count="searchCount"
|
||||||
:disabled="disabled"
|
:disabled="disabled"
|
||||||
|
@onPointClick="onPointClick"
|
||||||
></chart>
|
></chart>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -9,6 +9,7 @@ import { getOuterParamsInfo } from '@/api/visualization/outerParams'
|
|||||||
import { ElMessage } from 'element-plus-secondary'
|
import { ElMessage } from 'element-plus-secondary'
|
||||||
import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain'
|
import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain'
|
||||||
import { useI18n } from '@/hooks/web/useI18n'
|
import { useI18n } from '@/hooks/web/useI18n'
|
||||||
|
import { XpackComponent } from '@/components/plugin'
|
||||||
const { wsCache } = useCache()
|
const { wsCache } = useCache()
|
||||||
const interactiveStore = interactiveStoreWithOut()
|
const interactiveStore = interactiveStoreWithOut()
|
||||||
const embeddedStore = useEmbedded()
|
const embeddedStore = useEmbedded()
|
||||||
@ -17,7 +18,7 @@ const viewInfo = ref()
|
|||||||
const userViewEnlargeRef = ref()
|
const userViewEnlargeRef = ref()
|
||||||
const dvMainStore = dvMainStoreWithOut()
|
const dvMainStore = dvMainStoreWithOut()
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
|
const openHandler = ref(null)
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
canvasDataPreview: null,
|
canvasDataPreview: null,
|
||||||
canvasStylePreview: null,
|
canvasStylePreview: null,
|
||||||
@ -124,6 +125,32 @@ onBeforeMount(async () => {
|
|||||||
const userViewEnlargeOpen = () => {
|
const userViewEnlargeOpen = () => {
|
||||||
userViewEnlargeRef.value.dialogInit(state.canvasStylePreview, viewInfo.value, config.value)
|
userViewEnlargeRef.value.dialogInit(state.canvasStylePreview, viewInfo.value, config.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const onPointClick = param => {
|
||||||
|
try {
|
||||||
|
console.info('de_inner_params send')
|
||||||
|
if (window['dataease-embedded-host'] && openHandler?.value) {
|
||||||
|
const pm = {
|
||||||
|
methodName: 'embeddedInteractive',
|
||||||
|
args: {
|
||||||
|
eventName: 'de_inner_params',
|
||||||
|
args: param
|
||||||
|
}
|
||||||
|
}
|
||||||
|
openHandler.value.invokeMethod(pm)
|
||||||
|
} else {
|
||||||
|
console.info('de_inner_params send to host')
|
||||||
|
const targetPm = {
|
||||||
|
type: 'dataease-embedded-interactive',
|
||||||
|
eventName: 'de_inner_params',
|
||||||
|
args: param
|
||||||
|
}
|
||||||
|
window.parent.postMessage(targetPm, '*')
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.warn('de_inner_params send error')
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@ -136,9 +163,11 @@ const userViewEnlargeOpen = () => {
|
|||||||
:dv-info="state.dvInfo"
|
:dv-info="state.dvInfo"
|
||||||
:canvas-view-info="state.canvasViewInfoPreview"
|
:canvas-view-info="state.canvasViewInfoPreview"
|
||||||
@userViewEnlargeOpen="userViewEnlargeOpen"
|
@userViewEnlargeOpen="userViewEnlargeOpen"
|
||||||
|
@onPointClick="onPointClick"
|
||||||
/>
|
/>
|
||||||
<user-view-enlarge ref="userViewEnlargeRef"></user-view-enlarge>
|
<user-view-enlarge ref="userViewEnlargeRef"></user-view-enlarge>
|
||||||
</div>
|
</div>
|
||||||
|
<XpackComponent ref="openHandler" jsname="L2NvbXBvbmVudC9lbWJlZGRlZC1pZnJhbWUvT3BlbkhhbmRsZXI=" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
|
@ -50,7 +50,8 @@ const dvMainStore = dvMainStoreWithOut()
|
|||||||
let innerRefreshTimer = null
|
let innerRefreshTimer = null
|
||||||
const appStore = useAppStoreWithOut()
|
const appStore = useAppStoreWithOut()
|
||||||
const isDataEaseBi = computed(() => appStore.getIsDataEaseBi)
|
const isDataEaseBi = computed(() => appStore.getIsDataEaseBi)
|
||||||
const isIframe = computed(() => appStore.getIsIframe)
|
|
||||||
|
const emit = defineEmits(['onPointClick'])
|
||||||
|
|
||||||
const { nowPanelJumpInfo, publicLinkStatus, dvInfo, curComponent, canvasStyleData, mobileInPc } =
|
const { nowPanelJumpInfo, publicLinkStatus, dvInfo, curComponent, canvasStyleData, mobileInPc } =
|
||||||
storeToRefs(dvMainStore)
|
storeToRefs(dvMainStore)
|
||||||
@ -286,17 +287,12 @@ const drillJump = (index: number) => {
|
|||||||
|
|
||||||
const onPointClick = param => {
|
const onPointClick = param => {
|
||||||
try {
|
try {
|
||||||
console.info('de_inner_params send')
|
|
||||||
const msg = {
|
const msg = {
|
||||||
type: 'de_inner_params',
|
|
||||||
sourceDvId: dvInfo.value.id,
|
sourceDvId: dvInfo.value.id,
|
||||||
sourceViewId: view.value.id,
|
sourceViewId: view.value.id,
|
||||||
message: Base64.encode(JSON.stringify(param))
|
message: Base64.encode(JSON.stringify(param))
|
||||||
}
|
}
|
||||||
if (window['dataease-embedded-host']) {
|
emit('onPointClick', msg)
|
||||||
console.info('de_inner_params send to host')
|
|
||||||
window['dataease-embedded-host'].postMessage(msg, '*')
|
|
||||||
}
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn('de_inner_params send error')
|
console.warn('de_inner_params send error')
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user