From 108c639f1a5a63065ff18406e97ee101aa488320 Mon Sep 17 00:00:00 2001 From: zhangsir Date: Tue, 28 May 2024 17:45:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/Forward.vue | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/views/Forward.vue b/src/views/Forward.vue index 3010e2cf..3097ca9c 100644 --- a/src/views/Forward.vue +++ b/src/views/Forward.vue @@ -1,7 +1,7 @@ @@ -27,9 +27,29 @@ import portalFooter from "@/components/PortalFooter.vue"; if(params){ this.url=this.url+'?'+params; } + window.addEventListener('hashchange', this.handleHashChange); + window.addEventListener('popstate', this.handlePopState); }, + beforeDestroy() { + window.removeEventListener('hashchange', this.handleHashChange); + window.removeEventListener('popstate', this.handlePopState); + }, methods:{ - + handleHashChange() { + this.navigate(); + }, + handlePopState() { + this.navigate(); + }, + navigate() { + const navigatePath = new URLSearchParams(window.location.search).get('navigate'); + if (navigatePath) { + // 清除查询参数 + window.history.replaceState({}, '', location.pathname); + // 导航 + this.$refs.iframe.src = navigatePath; + } + }, } }