| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- <template>
- <div :class="prefixCls" :style="getWrapStyle">
- <Spin :spinning="loading" size="large" :style="getWrapStyle">
- <iframe :src="frameSrc" :class="`${prefixCls}__main`" ref="frameRef" @load="hideLoading"></iframe>
- </Spin>
- </div>
- </template>
- <script lang="ts" setup>
- import type { CSSProperties } from 'vue';
- import { ref, unref, computed } from 'vue';
- import { Spin } from 'ant-design-vue';
- import { useWindowSizeFn } from '/@/hooks/event/useWindowSizeFn';
- import { propTypes } from '/@/utils/propTypes';
- import { useDesign } from '/@/hooks/web/useDesign';
- import { useLayoutHeight } from '/@/layouts/default/content/useContentViewHeight';
- import { useAppStore } from '/@/store/modules/app';
- defineProps({
- frameSrc: propTypes.string.def(''),
- });
- const appStore = useAppStore();
- const loading = ref(true);
- const topRef = ref(50);
- // debugger;
- const heightRef = ref(window.innerHeight / appStore.getHeightScale);
- const frameRef = ref<HTMLFrameElement>();
- const { headerHeightRef } = useLayoutHeight();
- const { prefixCls } = useDesign('iframe-page');
- useWindowSizeFn(calcHeight, 150, { immediate: true });
- const getWrapStyle = computed((): CSSProperties => {
- return {
- height: `${unref(heightRef)}px`,
- };
- });
- function calcHeight() {
- const iframe = unref(frameRef);
- if (!iframe) {
- return;
- }
- const top = headerHeightRef.value;
- topRef.value = top;
- heightRef.value = window.innerHeight / appStore.getHeightScale - top;
- const clientHeight = document.documentElement.clientHeight / appStore.getHeightScale - top;
- const clientWidth = document.documentElement.clientWidth / appStore.getWidthScale;
- iframe.style.height = `${clientHeight}px`;
- iframe.style.width = `${clientWidth}px`;
- }
- function hideLoading() {
- loading.value = false;
- calcHeight();
- }
- </script>
- <style lang="less" scoped>
- @prefix-cls: ~'@{namespace}-iframe-page';
- @ventSpace: zxm;
- .@{prefix-cls} {
- .@{ventSpace}-spin-nested-loading {
- position: relative;
- height: 100%;
- .@{ventSpace}-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;
- background-color: @component-background;
- border: 0;
- box-sizing: border-box;
- }
- }
- </style>
|