From 8f7f2a8143e3db1f74e21fb2739751d986b2937b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=A8=9C?= Date: Wed, 23 Apr 2025 16:18:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=87=E6=8D=A2=E8=B7=AF=E7=94=B1iframe?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98=E5=B0=9D=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 25 ------------- src/views/dialogue/dialogueView.vue | 6 ++-- src/views/tools/index.vue | 54 ++++++++++++++++++++++++++++- 3 files changed, 56 insertions(+), 29 deletions(-) diff --git a/src/App.vue b/src/App.vue index 575a47f3..46439d73 100644 --- a/src/App.vue +++ b/src/App.vue @@ -3,31 +3,6 @@ import { qiankunWindow } from 'vite-plugin-qiankun/dist/helper'; import '@vue-flow/core/dist/style.css'; import '@vue-flow/core/dist/theme-default.css'; import DialogueView from 'src/views/dialogue/dialogueView.vue'; -import { watch } from 'vue'; -import { useRouter } from 'vue-router'; -const router = useRouter(); - -// 监听路由变化,控制iframe内容的活动状态 -watch( - () => router.currentRoute.value.path, - (newPath) => { - const iframe = document.getElementById('my-iframe'); - const isWitchaindRoute = newPath === '/witchainD'; - if (!iframe) { - console.warn('未找到iframe元素'); - return; - } - if (!iframe.contentWindow) { - console.warn('iframe.contentWindow不可用'); - return; - } - const message = { StopActive: !isWitchaindRoute }; - // 向iframe发送消息,控制其活动状态 StopActive为false表示激活,为true表示停止 - let target = `${window.location.origin}/witchaind`; - iframe.contentWindow.postMessage(message, target); - }, - { immediate: true } // 初始化时也执行 -);