Commit ab87a76b authored by Cai Wei's avatar Cai Wei

feat(*): 补充跳转逻辑

parent c1670329
<template>
<div class="intermediate-page">
<iframe
ref="iframeRef"
class="iframe-box"
src="https://screen.bmetech.com/steelmakingScreen/#/ecoDashboard"
frameborder="0"
......@@ -21,6 +22,7 @@ import { ref, onMounted, computed, onUnmounted } from "vue";
const router = useRouter();
const windowHeight = ref(window.innerHeight);
const windowWidth = ref(window.innerWidth);
const iframeRef = ref(null);
// 设计稿尺寸
const DESIGN_WIDTH = 1920;
......@@ -53,14 +55,36 @@ const updateWindowSize = () => {
windowWidth.value = window.innerWidth;
};
// 处理iframe消息
const handleMessage = (event) => {
// 确保消息来源是我们的iframe
if (iframeRef.value && event.source === iframeRef.value.contentWindow) {
try {
// 如果消息是字符串,尝试解析JSON
const data = typeof event.data === 'string' ? JSON.parse(event.data) : event.data;
// 根据消息类型处理
if (data.type === 'navigation' && data.target === 'dashboard') {
handleBack();
}
} catch (error) {
console.error('Error processing iframe message:', error);
}
}
};
onMounted(() => {
window.addEventListener("resize", updateWindowSize);
// 添加消息监听器
window.addEventListener('message', handleMessage);
});
onUnmounted(() => {
window.removeEventListener("resize", updateWindowSize);
// 移除消息监听器
window.removeEventListener('message', handleMessage);
});
const handleBack = () => {
router.push("/dashboard");
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment