From df1ca11251dbe5cba4596492404857b383a027b8 Mon Sep 17 00:00:00 2001 From: Joseph Cheung Date: Mon, 6 Mar 2023 01:22:55 +0800 Subject: [PATCH] v --- searx/webapp.py | 9 +++++++++ searx/webapp1.py | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/searx/webapp.py b/searx/webapp.py index 9d473a383..4e0e2cb82 100755 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -1321,6 +1321,14 @@ function modal_open(url, num) var iframe = document.querySelector("#iframe-wrapper > iframe"); if(num=='pdf') { + new Promise((resolve, reject) => { + const interval = setInterval(() => { + if (numPages !== null) { + clearInterval(interval); + resolve(numPages); + } + }, 1000); // 定期检查 numPages 是否不为 null,这里是每隔1秒检查一次 + }).then( function foo(){ var pdf = iframe.contentWindow.PDFViewerApplication.pdfDocument; var numPages = pdf.numPages; //获取总页数 var promises = []; //用来存放每一页的Promise对象 @@ -1477,6 +1485,7 @@ function modal_open(url, num) sentencesContent += sentences[i][1]; } article = {'textContent':sentencesContent,'title':iframe.contentWindow.PDFViewerApplication._title} + }) } else { diff --git a/searx/webapp1.py b/searx/webapp1.py index 9d473a383..4e0e2cb82 100644 --- a/searx/webapp1.py +++ b/searx/webapp1.py @@ -1321,6 +1321,14 @@ function modal_open(url, num) var iframe = document.querySelector("#iframe-wrapper > iframe"); if(num=='pdf') { + new Promise((resolve, reject) => { + const interval = setInterval(() => { + if (numPages !== null) { + clearInterval(interval); + resolve(numPages); + } + }, 1000); // 定期检查 numPages 是否不为 null,这里是每隔1秒检查一次 + }).then( function foo(){ var pdf = iframe.contentWindow.PDFViewerApplication.pdfDocument; var numPages = pdf.numPages; //获取总页数 var promises = []; //用来存放每一页的Promise对象 @@ -1477,6 +1485,7 @@ function modal_open(url, num) sentencesContent += sentences[i][1]; } article = {'textContent':sentencesContent,'title':iframe.contentWindow.PDFViewerApplication._title} + }) } else {