Skip to content

Conversation

tinysimple
Copy link
Contributor

修改重新加载时frame组件控制iframe的方式,防止出现两次拦截确认导致的问题。

@xiaoxian521 xiaoxian521 added nice pr 非常好的pr CodeReview::Waiting 等待代码审查 labels Sep 28, 2025
@xiaoxian521 xiaoxian521 added test:waiting 等待测试 and removed CodeReview::Waiting 等待代码审查 labels Sep 28, 2025
@xiaoxian521
Copy link
Member

@tinysimple 我看了下 复现环境需要是线上环境 我看你部署了下 麻烦再测试下吧 ❤️

@tinysimple
Copy link
Contributor Author

@xiaoxian521 好的,我来测试一下。

本地也能进行测试,测试步骤如下:
1、全局安装whistle,使用命令w2 start启动,再w2 proxy on设置为系统代理。
2、打开http://localhost:8899,进入Rules选项卡,增加两条规则,内容如下:
http://abcxxxx.com/vue-pure-admin-external-website https://tinysimple.github.io/vue-pure-admin-external-website http://abcxxxx.com/ http://127.0.0.1:8848/
3、修改项目中任何一个路由文件中的frameSrc(示例:src/router/modules/board.ts)为
http://abcxxxx.com/vue-pure-admin-external-website
4、直接访问http://abcxxxx.com/#/board/index即可进行测试。

ps:如果重新加载frame路由tag时不弹出浏览器拦截框,可以看到控制台中有报错信息如下:
[Intervention] Blocked attempt to show a 'beforeunload' confirmation panel for a frame that never had a user gesture since its load. https://www.chromestatus.com/feature/5082396709879808
解决方案为:鼠标在iframe中点击一下,再点击重新加载,即可触发浏览器拦截窗口。

@tinysimple
Copy link
Contributor Author

tinysimple commented Sep 28, 2025

@xiaoxian521 在点击重新加载时,弹出浏览器确认弹窗,等2s后,loading消失;再点击“离开”,此时不会有loading出现,白屏一段时间。
(ps:同源网站(https://tinysimple.github.io/vue-pure-admin-external-website)增加了5s的阻塞时间,用来延迟onload事件的触发。)
GIF 2025-09-28 14-04-25

@xiaoxian521 xiaoxian521 added test:pass 测试通过 and removed test:waiting 等待测试 labels Sep 28, 2025
@xiaoxian521 xiaoxian521 changed the title fix: 修复重新加载frame时同源网站在注册了beforeunload事件后两次拦截确认的问题 fix: 修复在内嵌同源iframe页面中,当其注册了beforeunload事件时,右键标签页点击重新加载导致浏览器弹出两次确认拦截的问题 Sep 28, 2025
@xiaoxian521 xiaoxian521 merged commit fa606b4 into pure-admin:main Sep 28, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
nice pr 非常好的pr test:pass 测试通过
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants