|
@@ -2648,9 +2648,25 @@ const handleRefreshPage = () => {
|
|
|
|
|
|
|
|
let refreshedCount = 0
|
|
let refreshedCount = 0
|
|
|
|
|
|
|
|
|
|
+ // 当前页的 frame 元素列表,用于判断对应 iframe 是否已 isDone
|
|
|
|
|
+ const frameElements = elementList.value.filter((i: any) => i.type === 'frame')
|
|
|
|
|
+
|
|
|
// 遍历所有iframe并刷新
|
|
// 遍历所有iframe并刷新
|
|
|
for (let i = 0; i < iframes.length; i++) {
|
|
for (let i = 0; i < iframes.length; i++) {
|
|
|
const iframe = iframes[i] as HTMLIFrameElement
|
|
const iframe = iframes[i] as HTMLIFrameElement
|
|
|
|
|
+ // 找到该 iframe 对应的 frame 元素:src 场景按 url 匹配,srcdoc 场景按 isHTML 匹配
|
|
|
|
|
+ const matchedElement = frameElements.find((el: any) => {
|
|
|
|
|
+ if (iframe.src && el.url && !el.isHTML) {
|
|
|
|
|
+ return iframe.src === el.url || iframe.src.includes(el.url) || el.url.includes(iframe.src)
|
|
|
|
|
+ }
|
|
|
|
|
+ if (iframe.srcdoc && el.isHTML) return true
|
|
|
|
|
+ return false
|
|
|
|
|
+ })
|
|
|
|
|
+ // 元素存在但未 isDone(加载/抓取未完成)时不刷新,避免打断进行中的加载
|
|
|
|
|
+ if (matchedElement && matchedElement.isDone !== true) {
|
|
|
|
|
+ console.log('跳过未 isDone 的 iframe:', matchedElement.id)
|
|
|
|
|
+ continue
|
|
|
|
|
+ }
|
|
|
// 优化刷新方式,避免闪烁和兼容 srcdoc 场景
|
|
// 优化刷新方式,避免闪烁和兼容 srcdoc 场景
|
|
|
if (iframe.src) {
|
|
if (iframe.src) {
|
|
|
// 仅当有src属性时刷新
|
|
// 仅当有src属性时刷新
|