From 4c71a320d12dfd1930bba698c4d87331dbb3026d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=A8=9C?= Date: Tue, 10 Jun 2025 11:16:08 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=9B=B4=E6=96=B0=20iframe=20=E7=9B=AE?= =?UTF-8?q?=E6=A0=87=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/dialogue/components/TitleBar.vue | 11 ++++++++--- src/views/dialogue/dialogueView.vue | 11 ++++++++--- src/views/tools/index.vue | 9 ++++++++- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/views/dialogue/components/TitleBar.vue b/src/views/dialogue/components/TitleBar.vue index 4ce5d02..99671af 100644 --- a/src/views/dialogue/components/TitleBar.vue +++ b/src/views/dialogue/components/TitleBar.vue @@ -23,9 +23,14 @@ onMounted(async () => { const baseUrl = await getBaseUrl(); const origin = window.location.origin; const isElectron = window.navigator.userAgent.includes('Electron'); - iframeTarget.value = isElectron - ? `${baseUrl}/witchaind` - : `${origin}/witchaind`; + const isLocalHost = + window.location.origin.includes('localhost') || + window.location.origin.includes('127.0.0.1'); + iframeTarget.value = isLocalHost + ? 'http://127.0.0.1:9888/witchaind' + : isElectron + ? `${baseUrl}/witchaind` + : `${origin}/witchaind`; }); const changeLanguagefun = (lang: 'zh_cn' | 'en') => { diff --git a/src/views/dialogue/dialogueView.vue b/src/views/dialogue/dialogueView.vue index b968bf5..b065bb0 100644 --- a/src/views/dialogue/dialogueView.vue +++ b/src/views/dialogue/dialogueView.vue @@ -170,9 +170,14 @@ onMounted(async () => { const baseUrl = await getBaseUrl(); const origin = window.location.origin; const isElectron = window.navigator.userAgent.includes('Electron'); - const iframeTarget = isElectron - ? `${baseUrl}/witchaind` - : `${origin}/witchaind`; + const isLocalHost = + window.location.origin.includes('localhost') || + window.location.origin.includes('127.0.0.1'); + const iframeTarget = isLocalHost + ? 'http://127.0.0.1:9888/witchaind' + : isElectron + ? `${baseUrl}/witchaind` + : `${origin}/witchaind`; if (localStorage.getItem('theme')) { // document.body.setAttribute( diff --git a/src/views/tools/index.vue b/src/views/tools/index.vue index 7f5fe2c..0e826ae 100644 --- a/src/views/tools/index.vue +++ b/src/views/tools/index.vue @@ -33,7 +33,14 @@ async function getIframeTarget() { const origin = window.location.origin; // Electron 环境的判断 const isElectron = window.navigator.userAgent.includes('Electron'); - const target = isElectron ? `${baseUrl}/witchaind` : `${origin}/witchaind`; + const isLocalHost = + window.location.origin.includes('localhost') || + window.location.origin.includes('127.0.0.1'); + const target = isLocalHost + ? 'http://127.0.0.1:9888/witchaind' + : isElectron + ? `${baseUrl}/witchaind` + : `${origin}/witchaind`; return target; } -- Gitee