From 338dbd1b282a60641b471ef847dde0c778afb415 Mon Sep 17 00:00:00 2001 From: lideqin <694785430@qq.com> Date: Thu, 9 May 2024 10:22:14 +0800 Subject: [PATCH] =?UTF-8?q?[update]=20pdf=E9=A2=84=E8=A7=88=E7=A6=81?= =?UTF-8?q?=E6=AD=A2=E6=89=93=E5=BC=80=E6=8E=A7=E5=88=B6=E5=8F=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/pdfjs/web/viewer.html | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/public/pdfjs/web/viewer.html b/public/pdfjs/web/viewer.html index d2b859e9..ad4f85df 100644 --- a/public/pdfjs/web/viewer.html +++ b/public/pdfjs/web/viewer.html @@ -50,6 +50,24 @@ See https://github.com/adobe-type-tools/cmap-resources window.close() } } + // 检测是手动刷新页面 + function isPageRefresh() { + const navigationEntries = window.performance.getEntriesByType('navigation') + if (navigationEntries.length > 0) { + const lastEntry = navigationEntries[navigationEntries.length - 1] + // 如果最后一个性能条目的类型是 "reload",则表明页面可能是通过手动刷新加载的 + return lastEntry.type === 'reload' + } + return false + } + window.addEventListener('load', function() { + if (isPageRefresh()) { + console.log('页面可能是手动刷新的') + // 在这里处理页面刷新的逻辑 + window.open(window.location.href, '_blank') + window.close() + } + }) }