chore: 更改postMessage参数
This commit is contained in:
parent
ada0a7edf6
commit
f56ba6ba33
@ -23,6 +23,7 @@ import {
|
||||
TabPane,
|
||||
Tabs,
|
||||
} from 'ant-design-vue';
|
||||
import { isObject } from 'lodash-es';
|
||||
|
||||
import {
|
||||
cancelProcessApply,
|
||||
@ -95,17 +96,19 @@ const loading = ref(false);
|
||||
const iframeLoaded = ref(false);
|
||||
const iframeHeight = ref(300);
|
||||
useEventListener('message', (event) => {
|
||||
const data = event.data as { [key: string]: any; type: string };
|
||||
if (!isObject(data)) return;
|
||||
/**
|
||||
* iframe通信 加载完毕后才显示表单 解决卡顿问题
|
||||
*/
|
||||
if (event.data === 'mounted') {
|
||||
if (data.type === 'mounted') {
|
||||
iframeLoaded.value = true;
|
||||
}
|
||||
/**
|
||||
* 高度与表单高度保持一致
|
||||
*/
|
||||
if (event.data.includes('height')) {
|
||||
const height = event.data.split('height:')[1];
|
||||
if (data.type === 'height') {
|
||||
const height = data.height;
|
||||
iframeHeight.value = height;
|
||||
}
|
||||
});
|
||||
|
@ -60,14 +60,14 @@ onMounted(async () => {
|
||||
*/
|
||||
if (readonly) {
|
||||
// 渲染完毕才显示表单
|
||||
window.parent.postMessage('mounted', '*');
|
||||
window.parent.postMessage({ type: 'mounted' }, '*');
|
||||
// 获取表单高度 内嵌时保持一致
|
||||
setTimeout(() => {
|
||||
const el = cardRef.value?.$el as HTMLDivElement;
|
||||
// 获取高度
|
||||
const height = el?.offsetHeight ?? 0;
|
||||
if (height) {
|
||||
window.parent.postMessage(`height:${height}`, '*');
|
||||
window.parent.postMessage({ type: 'height', height }, '*');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user