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; + } + }, } }