refactor(ProjectManage): 优化 iframe 内 window.open 方法的重写逻辑
- 修改了 iframe 内 window.open 方法的实现,使其能够根据 URL 中的参数进行路由跳转 - 新增了对 URL 中其他参数和 sceneCode 参数的处理,提高了跳转的灵活性和可扩展性 - 优化了代码结构,去除了不必要的注释和示例代码,使代码更加清晰和可维护
This commit is contained in:
@@ -666,20 +666,14 @@ function onIframeLoad() {
|
||||
// 覆盖 window.open 方法
|
||||
iframeWindow.open = function (url, target, features) {
|
||||
console.log('拦截到 window.open:', { url, target, features })
|
||||
|
||||
// 自定义逻辑,例如:
|
||||
// return window.open(url, '_blank') // 继续用当前窗口打开
|
||||
// 或者阻止打开
|
||||
// return null
|
||||
|
||||
// 示例:用主窗口打开链接
|
||||
router.push({
|
||||
path:'/survey/planet/design',
|
||||
path:url,
|
||||
query:{
|
||||
sn: url.split('sn=')[1]
|
||||
sn: url.split('sn=')[1],
|
||||
other: url.indexOf('other')!==-1?url.split('other=')[1]:'',
|
||||
sceneCode: url.indexOf('sceneCode')!==-1? url.split('sceneCode=')[1]:''
|
||||
}
|
||||
})
|
||||
// window.open(url, '_blank')
|
||||
return null // 阻止 iframe 的 window.open
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user