From 6ebb7fc4616ca0a0c06b091af8c107112d7a01ef Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sat, 13 Dec 2025 16:21:51 +0800 Subject: [PATCH 1/5] =?UTF-8?q?refactor:=20=E4=BF=AE=E5=A4=8D=E7=BB=99?= =?UTF-8?q?=E5=B8=B8=E9=87=8F=E8=B5=8B=E5=80=BC=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/BootstrapBlazor.PdfReader/PdfReader.razor.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/components/BootstrapBlazor.PdfReader/PdfReader.razor.js b/src/components/BootstrapBlazor.PdfReader/PdfReader.razor.js index acc5d0a2..ffec24ed 100644 --- a/src/components/BootstrapBlazor.PdfReader/PdfReader.razor.js +++ b/src/components/BootstrapBlazor.PdfReader/PdfReader.razor.js @@ -139,10 +139,7 @@ const loadPdf = async pdf => { if (bar) { const val = loaded / total * 100; - if (val > 100) { - val = 100; - } - bar.style.setProperty('--bb-view-progress-val', `${val}%`); + bar.style.setProperty('--bb-view-progress-val', `${Math.min(val, 100)}%`); if (progressHandler === null) { progressHandler = setTimeout(() => { From 0986dc3d6dfec1742ca952d56a3f4c1c6eb8c032 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sat, 13 Dec 2025 16:22:13 +0800 Subject: [PATCH 2/5] =?UTF-8?q?refactor:=20=E9=87=8D=E7=BD=AE=E6=B5=81?= =?UTF-8?q?=E9=95=BF=E5=BA=A6=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/BootstrapBlazor.PdfReader/PdfReader.razor.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/BootstrapBlazor.PdfReader/PdfReader.razor.cs b/src/components/BootstrapBlazor.PdfReader/PdfReader.razor.cs index 82520689..d9323302 100644 --- a/src/components/BootstrapBlazor.PdfReader/PdfReader.razor.cs +++ b/src/components/BootstrapBlazor.PdfReader/PdfReader.razor.cs @@ -200,6 +200,7 @@ protected override async Task OnAfterRenderAsync(bool firstRender) { _url = Url; _lastStreamHash = string.Empty; + _lastStreamLength = 0; await InvokeVoidAsync("setUrl", Id, _url); } if (_currentPage != CurrentPage) From 9b8467f5e14e16860b277000ed4d9c03072a4f01 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sat, 13 Dec 2025 16:22:55 +0800 Subject: [PATCH 3/5] =?UTF-8?q?refactor:=20=E7=A7=BB=E9=99=A4=20createObje?= =?UTF-8?q?ctURL=20=E6=96=B9=E6=B3=95=E7=B2=BE=E7=AE=80=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PdfReader.razor.js | 24 +------------------ 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/src/components/BootstrapBlazor.PdfReader/PdfReader.razor.js b/src/components/BootstrapBlazor.PdfReader/PdfReader.razor.js index ffec24ed..76446c01 100644 --- a/src/components/BootstrapBlazor.PdfReader/PdfReader.razor.js +++ b/src/components/BootstrapBlazor.PdfReader/PdfReader.razor.js @@ -47,31 +47,12 @@ export async function setData(id, data) { return; } - const objectUrl = createObjectURLFromByte(data); - pdf.objectUrl = objectUrl; - const { options } = pdf; options.url = objectUrl; options.data = null; await loadPdf(pdf); } -const createObjectURLFromBase64 = base64Data => { - const binaryString = atob(base64Data); - const bytes = new Uint8Array(binaryString.length); - for (let i = 0; i < binaryString.length; i++) { - bytes[i] = binaryString.charCodeAt(i); - } - - const blob = new Blob([bytes], { type: 'application/pdf' }); - return URL.createObjectURL(blob); -} - -const createObjectURLFromByte = bytes => { - const blob = new Blob([bytes], { type: 'application/pdf' }); - return URL.createObjectURL(blob); -} - export function setScaleValue(id, value) { const { pdfViewer } = Data.get(id); if (pdfViewer) { @@ -182,10 +163,7 @@ const loadPdf = async pdf => { } const disposePdf = pdf => { - const { el, observer, loadingTask, objectUrl } = pdf; - if (objectUrl) { - URL.revokeObjectURL(objectUrl); - } + const { el, observer, loadingTask } = pdf; if (observer) { observer.disconnect(); From 51eee05b31b54efea2758de5495b366456074c89 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sat, 13 Dec 2025 16:23:17 +0800 Subject: [PATCH 4/5] =?UTF-8?q?refactor:=20=E9=87=8D=E6=9E=84=20url=20data?= =?UTF-8?q?=20=E5=8F=98=E9=87=8F=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BootstrapBlazor.PdfReader/PdfReader.razor.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/components/BootstrapBlazor.PdfReader/PdfReader.razor.js b/src/components/BootstrapBlazor.PdfReader/PdfReader.razor.js index 76446c01..c0c34db0 100644 --- a/src/components/BootstrapBlazor.PdfReader/PdfReader.razor.js +++ b/src/components/BootstrapBlazor.PdfReader/PdfReader.razor.js @@ -36,6 +36,7 @@ export async function setUrl(id, url) { const { options } = pdf; options.url = url; + options.data = null; await loadPdf(pdf); } @@ -48,8 +49,8 @@ export async function setData(id, data) { } const { options } = pdf; - options.url = objectUrl; - options.data = null; + options.url = null; + options.data = data;; await loadPdf(pdf); } @@ -178,7 +179,10 @@ const disposePdf = pdf => { const viewContainer = el.querySelector(".bb-view-container"); if (viewContainer) { [...viewContainer.children].forEach(i => { - if (!i.classList.contains("pdfViewer")) { + if (i.classList.contains("pdfViewer")) { + i.innerHTML = ""; + } + else { i.remove(); } }) From 6c91642b61e5bbd8003649cea8f10b47d21ae2e3 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sat, 13 Dec 2025 16:23:52 +0800 Subject: [PATCH 5/5] chore: bump version 10.0.15 --- .../BootstrapBlazor.PdfReader/BootstrapBlazor.PdfReader.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/BootstrapBlazor.PdfReader/BootstrapBlazor.PdfReader.csproj b/src/components/BootstrapBlazor.PdfReader/BootstrapBlazor.PdfReader.csproj index c0f89e1e..d06ffdaa 100644 --- a/src/components/BootstrapBlazor.PdfReader/BootstrapBlazor.PdfReader.csproj +++ b/src/components/BootstrapBlazor.PdfReader/BootstrapBlazor.PdfReader.csproj @@ -1,7 +1,7 @@  - 10.0.14 + 10.0.15