From eb9a9257dee3ca109e68fdd1c6ff1cb0aa9f3513 Mon Sep 17 00:00:00 2001 From: preschooler Date: Wed, 21 Aug 2024 13:29:15 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=88=20perf:=E4=BC=98=E5=8C=96iframe?= =?UTF-8?q?=E5=B8=83=E5=B1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/IFrame/src/IFrame.vue | 33 ++++++++++++++----- src/views/infra/druid/index.vue | 4 +-- src/views/infra/server/index.vue | 2 +- src/views/infra/skywalking/index.vue | 2 +- src/views/infra/swagger/index.vue | 4 +-- .../delivery/pickUpStore/PickUpStoreForm.vue | 15 ++------- src/views/report/goview/index.vue | 1 + src/views/report/jmreport/index.vue | 4 +-- 8 files changed, 35 insertions(+), 30 deletions(-) diff --git a/src/components/IFrame/src/IFrame.vue b/src/components/IFrame/src/IFrame.vue index 19de51a3..64ffc0e5 100644 --- a/src/components/IFrame/src/IFrame.vue +++ b/src/components/IFrame/src/IFrame.vue @@ -7,26 +7,41 @@ const props = defineProps({ src: propTypes.string.def('') }) const loading = ref(true) -const height = ref('') const frameRef = ref(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() + } +) diff --git a/src/views/infra/druid/index.vue b/src/views/infra/druid/index.vue index bc047d76..2ac99d23 100644 --- a/src/views/infra/druid/index.vue +++ b/src/views/infra/druid/index.vue @@ -2,8 +2,8 @@ - - + +