Skip to content

Commit 21621fd

Browse files
YunaiVgitee-org
authored andcommitted
!508 【优化】优化iframe布局
Merge pull request !508 from 半栈幼儿员/hotfix/iframe
2 parents 7ff082a + 6586ba4 commit 21621fd

File tree

8 files changed

+35
-30
lines changed

8 files changed

+35
-30
lines changed

src/components/IFrame/src/IFrame.vue

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,41 @@ const props = defineProps({
77
src: propTypes.string.def('')
88
})
99
const loading = ref(true)
10-
const height = ref('')
1110
const frameRef = ref<HTMLElement | null>(null)
1211
const init = () => {
13-
height.value = document.documentElement.clientHeight - 94.5 + 'px'
14-
loading.value = false
12+
nextTick(() => {
13+
loading.value = true
14+
if (!frameRef.value) return
15+
frameRef.value.onload = () => {
16+
loading.value = false
17+
}
18+
})
1519
}
1620
onMounted(() => {
17-
setTimeout(() => {
18-
init()
19-
}, 300)
21+
init()
2022
})
23+
watch(
24+
() => props.src,
25+
() => {
26+
init()
27+
}
28+
)
2129
</script>
2230
<template>
23-
<div v-loading="loading" :style="'height:' + height">
31+
<div
32+
v-loading="loading"
33+
class="w-full h-[calc(100vh-var(--top-tool-height)-var(--tags-view-height)-var(--app-content-padding)-var(--app-content-padding)-2px)]"
34+
>
2435
<iframe
2536
ref="frameRef"
2637
:src="props.src"
27-
frameborder="no"
38+
frameborder="0"
2839
scrolling="auto"
29-
style="width: 100%; height: 100%"
40+
height="100%"
41+
width="100%"
42+
allowfullscreen="true"
43+
webkitallowfullscreen="true"
44+
mozallowfullscreen="true"
3045
></iframe>
3146
</div>
3247
</template>

src/views/infra/druid/index.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<doc-alert title="数据库 MyBatis" url="https://doc.iocoder.cn/mybatis/" />
33
<doc-alert title="多数据源(读写分离)" url="https://doc.iocoder.cn/dynamic-datasource/" />
44

5-
<ContentWrap>
6-
<IFrame v-if="!loading" :src="url" />
5+
<ContentWrap :bodyStyle="{ padding: '0px' }" class="!mb-0">
6+
<IFrame v-if="!loading" v-loading="loading" :src="url" />
77
</ContentWrap>
88
</template>
99
<script lang="ts" setup>

src/views/infra/server/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<doc-alert title="服务监控" url="https://doc.iocoder.cn/server-monitor/" />
33

4-
<ContentWrap>
4+
<ContentWrap :bodyStyle="{ padding: '0px' }" class="!mb-0">
55
<IFrame v-if="!loading" v-loading="loading" :src="src" />
66
</ContentWrap>
77
</template>

src/views/infra/skywalking/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<doc-alert title="服务监控" url="https://doc.iocoder.cn/server-monitor/" />
33

4-
<ContentWrap>
4+
<ContentWrap :bodyStyle="{ padding: '0px' }" class="!mb-0">
55
<IFrame v-if="!loading" v-loading="loading" :src="src" />
66
</ContentWrap>
77
</template>

src/views/infra/swagger/index.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<template>
22
<doc-alert title="接口文档" url="https://doc.iocoder.cn/api-doc/" />
33

4-
<ContentWrap>
5-
<IFrame :src="src" />
4+
<ContentWrap :bodyStyle="{ padding: '0px' }" class="!mb-0">
5+
<IFrame v-if="!loading" v-loading="loading" :src="src" />
66
</ContentWrap>
77
</template>
88
<script lang="ts" setup>

src/views/mall/trade/delivery/pickUpStore/PickUpStoreForm.vue

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,8 @@
106106
<el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button>
107107
<el-button @click="dialogVisible = false">取 消</el-button>
108108
</template>
109-
<el-dialog
110-
v-model="mapDialogVisible"
111-
title="获取经纬度"
112-
append-to-body
113-
width="500px"
114-
class="mapBox"
115-
>
116-
<iframe id="mapPage" width="100%" height="100%" frameborder="0" :src="tencentLbsUrl"></iframe>
109+
<el-dialog v-model="mapDialogVisible" title="获取经纬度" append-to-body>
110+
<IFrame class="h-609px" :src="tencentLbsUrl" />
117111
</el-dialog>
118112
</Dialog>
119113
</template>
@@ -266,8 +260,3 @@ onMounted(async () => {
266260
await initTencentLbsMap()
267261
})
268262
</script>
269-
<style lang="scss">
270-
.mapBox .el-dialog__body {
271-
height: 640px !important;
272-
}
273-
</style>

src/views/report/goview/index.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<ContentWrap>
33
<doc-alert title="大屏设计器" url="https://doc.iocoder.cn/report/screen/" />
44

5+
<ContentWrap :bodyStyle="{ padding: '0px' }" class="!mb-0">
56
<IFrame :src="src" />
67
</ContentWrap>
78
</template>

src/views/report/jmreport/index.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<ContentWrap>
33
<doc-alert title="报表设计器" url="https://doc.iocoder.cn/report/" />
44

5+
<ContentWrap :bodyStyle="{ padding: '0px' }" class="!mb-0">
56
<IFrame :src="src" />
67
</ContentWrap>
78
</template>
@@ -10,6 +11,5 @@ import { getAccessToken } from '@/utils/auth'
1011
1112
defineOptions({ name: 'JimuReport' })
1213
13-
const BASE_URL = import.meta.env.VITE_BASE_URL
14-
const src = ref(BASE_URL + '/jmreport/list?token=' + getAccessToken())
14+
const src = ref(import.meta.env.VITE_BASE_URL + '/jmreport/list?token=' + getAccessToken())
1515
</script>

0 commit comments

Comments
 (0)