|
1
|
<template>
|
vben
authored
|
2
|
<div :class="prefixCls" :style="getWrapStyle">
|
|
3
|
<Spin :spinning="loading" size="large" :style="getWrapStyle">
|
|
4
5
6
7
8
9
|
<iframe
:src="frameSrc"
:class="`${prefixCls}__main`"
ref="frameRef"
@load="hideLoading"
></iframe>
|
|
10
11
12
|
</Spin>
</div>
</template>
|
vben
authored
|
13
|
<script lang="ts" setup>
|
vben
authored
|
14
|
import type { CSSProperties } from 'vue';
|
vben
authored
|
15
|
import { ref, unref, computed } from 'vue';
|
|
16
|
import { Spin } from 'ant-design-vue';
|
vben
authored
|
17
|
import { useWindowSizeFn } from '/@/hooks/event/useWindowSizeFn';
|
vben
authored
|
18
19
|
import { propTypes } from '/@/utils/propTypes';
import { useDesign } from '/@/hooks/web/useDesign';
|
|
20
|
import { useLayoutHeight } from '/@/layouts/default/content/useContentViewHeight';
|
vben
authored
|
21
|
|
vben
authored
|
22
23
24
|
defineProps({
frameSrc: propTypes.string.def(''),
});
|
vben
authored
|
25
|
|
vben
authored
|
26
27
28
29
30
|
const loading = ref(true);
const topRef = ref(50);
const heightRef = ref(window.innerHeight);
const frameRef = ref<HTMLFrameElement>();
const { headerHeightRef } = useLayoutHeight();
|
|
31
|
|
vben
authored
|
32
33
|
const { prefixCls } = useDesign('iframe-page');
useWindowSizeFn(calcHeight, 150, { immediate: true });
|
|
34
|
|
vben
authored
|
35
36
37
38
39
|
const getWrapStyle = computed((): CSSProperties => {
return {
height: `${unref(heightRef)}px`,
};
});
|
|
40
|
|
vben
authored
|
41
42
43
44
45
46
47
48
49
50
51
|
function calcHeight() {
const iframe = unref(frameRef);
if (!iframe) {
return;
}
const top = headerHeightRef.value;
topRef.value = top;
heightRef.value = window.innerHeight - top;
const clientHeight = document.documentElement.clientHeight - top;
iframe.style.height = `${clientHeight}px`;
}
|
|
52
|
|
vben
authored
|
53
54
55
56
|
function hideLoading() {
loading.value = false;
calcHeight();
}
|
|
57
58
|
</script>
<style lang="less" scoped>
|
vben
authored
|
59
60
61
|
@prefix-cls: ~'@{namespace}-iframe-page';
.@{prefix-cls} {
|
|
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
.ant-spin-nested-loading {
position: relative;
height: 100%;
.ant-spin-container {
width: 100%;
height: 100%;
padding: 10px;
}
}
&__mask {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
&__main {
width: 100%;
height: 100%;
overflow: hidden;
|
Vben
authored
|
85
|
background-color: @component-background;
|
|
86
87
88
89
90
|
border: 0;
box-sizing: border-box;
}
}
</style>
|