Files
aiot-platform-ui/packages/effects/common-ui/src/components/iframe/iframe.vue

39 lines
783 B
Vue
Raw Normal View History

2025-04-06 21:32:44 +08:00
<script setup lang="ts">
2025-04-22 22:10:33 +08:00
import { onMounted, ref } from 'vue';
2025-04-06 21:32:44 +08:00
interface IFrameProps {
2025-04-22 22:10:33 +08:00
/** iframe 的源地址 */
src: string;
2025-04-06 21:32:44 +08:00
}
2025-04-22 22:10:33 +08:00
const props = defineProps<IFrameProps>();
2025-04-06 21:32:44 +08:00
2025-04-22 22:10:33 +08:00
const loading = ref(true);
const height = ref('');
const frameRef = ref<HTMLElement | null>(null);
2025-04-06 21:32:44 +08:00
function init() {
2025-04-22 22:10:33 +08:00
height.value = `${document.documentElement.clientHeight - 94.5}px`;
loading.value = false;
2025-04-06 21:32:44 +08:00
}
onMounted(() => {
setTimeout(() => {
2025-04-22 22:10:33 +08:00
init();
}, 300);
});
2025-04-06 21:32:44 +08:00
// TODO @芋艿:优化:未来使用 vben 自带的内链实现
</script>
<template>
<div v-loading="loading" :style="`height:${height}`">
2025-04-22 22:10:33 +08:00
<iframe
ref="frameRef"
:src="props.src"
style="width: 100%; height: 100%"
frameborder="no"
scrolling="auto"
></iframe>
2025-04-06 21:32:44 +08:00
</div>
</template>