!508 【优化】优化iframe布局

Merge pull request !508 from 半栈幼儿员/hotfix/iframe
This commit is contained in:
芋道源码
2024-08-23 11:16:05 +00:00
committed by Gitee
8 changed files with 35 additions and 30 deletions

View File

@ -7,26 +7,41 @@ const props = defineProps({
src: propTypes.string.def('')
})
const loading = ref(true)
const height = ref('')
const frameRef = ref<HTMLElement | null>(null)
const init = () => {
height.value = document.documentElement.clientHeight - 94.5 + 'px'
loading.value = false
nextTick(() => {
loading.value = true
if (!frameRef.value) return
frameRef.value.onload = () => {
loading.value = false
}
})
}
onMounted(() => {
setTimeout(() => {
init()
}, 300)
init()
})
watch(
() => props.src,
() => {
init()
}
)
</script>
<template>
<div v-loading="loading" :style="'height:' + height">
<div
v-loading="loading"
class="w-full h-[calc(100vh-var(--top-tool-height)-var(--tags-view-height)-var(--app-content-padding)-var(--app-content-padding)-2px)]"
>
<iframe
ref="frameRef"
:src="props.src"
frameborder="no"
frameborder="0"
scrolling="auto"
style="width: 100%; height: 100%"
height="100%"
width="100%"
allowfullscreen="true"
webkitallowfullscreen="true"
mozallowfullscreen="true"
></iframe>
</div>
</template>