This commit is contained in:
zhangsir
2024-05-28 17:45:06 +08:00
parent d463e896a6
commit 108c639f1a

View File

@@ -1,7 +1,7 @@
<template>
<div class="box" :class="{ incl: url.includes('projectdetails') }">
<portal-header style="background: #387DF7;" :hideSearch="true" textColor="#ffffff"></portal-header>
<iframe :src="url" style="width: 100%;height: 100%;" frameborder="0"></iframe>
<iframe :src="url" style="width: 100%;height: 100%;" frameborder="0" ref="iframe"></iframe>
<portal-footer></portal-footer>
</div>
</template>
@@ -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;
}
},
}
}
</script>