From ee2a27501b8e46c52b56595f08d62445e688697c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AB=98=E9=9B=84?= Date: Wed, 15 Apr 2026 14:40:41 +0800 Subject: [PATCH] =?UTF-8?q?pdf=20=E6=B7=BB=E5=8A=A0=E8=B7=A8=E5=9F=9F?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=20=E4=BF=AE=E5=A4=8Dpdf=20=E9=A1=B5=E7=A0=81?= =?UTF-8?q?=E5=92=8C=E9=AB=98=E4=BA=AE=E6=B2=A1=E5=90=AF=E7=94=A8bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/static/pdfjs/web/viewer.mjs | 38 +++++---- server/src/main/resources/web/pdf.ftl | 85 +++++++++++++------ 2 files changed, 79 insertions(+), 44 deletions(-) diff --git a/server/src/main/resources/static/pdfjs/web/viewer.mjs b/server/src/main/resources/static/pdfjs/web/viewer.mjs index 7d29b129..78f47697 100644 --- a/server/src/main/resources/static/pdfjs/web/viewer.mjs +++ b/server/src/main/resources/static/pdfjs/web/viewer.mjs @@ -23083,24 +23083,26 @@ initCom(PDFViewerApplication); } { const HOSTED_VIEWER_ORIGINS = new Set(["null", "http://mozilla.github.io", "https://mozilla.github.io"]); - var validateFileURL = function (file) { - if (!file) { - return; - } - const viewerOrigin = URL.parse(window.location)?.origin || "null"; - if (HOSTED_VIEWER_ORIGINS.has(viewerOrigin)) { - return; - } - const fileOrigin = URL.parse(file, window.location)?.origin; - if (fileOrigin === viewerOrigin) { - return; - } - const ex = new Error("file origin does not match viewer's"); - PDFViewerApplication._documentError("pdfjs-loading-error", { - message: ex.message - }); - throw ex; - }; +var validateFileURL = function (file) { + if (!file) { + return; + } + const viewerOrigin = URL.parse(window.location)?.origin || "null"; + if (HOSTED_VIEWER_ORIGINS.has(viewerOrigin)) { + return; + } + /* 注释掉跨域检查 + const fileOrigin = URL.parse(file, window.location)?.origin; + if (fileOrigin === viewerOrigin) { + return; + } + const ex = new Error("file origin does not match viewer's"); + PDFViewerApplication._documentError("pdfjs-loading-error", { + message: ex.message + }); + throw ex; + */ +}; var onFileInputChange = function (evt) { if (this.pdfViewer?.isInPresentationMode) { return; diff --git a/server/src/main/resources/web/pdf.ftl b/server/src/main/resources/web/pdf.ftl index fb2e44c5..068ef8f1 100644 --- a/server/src/main/resources/web/pdf.ftl +++ b/server/src/main/resources/web/pdf.ftl @@ -1,55 +1,88 @@ - + PDF预览 <#include "*/commonHeader.ftl"> + - + <#if pdfUrl?contains("http://") || pdfUrl?contains("https://")> <#assign finalUrl="${pdfUrl}"> <#else> <#assign finalUrl="${baseUrl}${pdfUrl}"> - + + + <#if "false" == switchDisabled> - 使用图片预览 + 使用图片预览 - - + + \ No newline at end of file