From 8075610836b9d283aac3695efd0f8c64f4eccbc9 Mon Sep 17 00:00:00 2001 From: Wei Lin Date: Mon, 7 Sep 2026 13:04:30 +0800 Subject: [PATCH] feat(web): show deployed MiniPdf version --- .github/workflows/pages.yml | 15 ++++++++++++++- .../MiniPdf.Web.Client/Pages/Converter.razor | 8 ++++++++ MiniPdf.Web/MiniPdf.Web.Client/wwwroot/app.css | 18 ++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 3d2f1fce..2bcabdd0 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -38,8 +38,21 @@ jobs: curl -L -o MiniPdf.Web/MiniPdf.Web.Client/wwwroot/fonts/NotoSansSC-Regular.ttf \ "https://github.com/google/fonts/raw/main/ofl/notosanssc/NotoSansSC%5Bwght%5D.ttf" + - name: Resolve MiniPdf NuGet version + id: minipdf-version + shell: pwsh + run: | + $index = Invoke-RestMethod 'https://api.nuget.org/v3-flatcontainer/minipdf/index.json' + $version = $index.versions | + Where-Object { $_ -notmatch '-' } | + Select-Object -Last 1 + if (-not $version) { + throw 'Could not resolve the latest stable MiniPdf version from NuGet.' + } + "version=$version" >> $env:GITHUB_OUTPUT + - name: Publish Blazor WASM - run: dotnet publish MiniPdf.Web/MiniPdf.Web.Client/MiniPdf.Web.Client.csproj -c Release -o publish + run: dotnet publish MiniPdf.Web/MiniPdf.Web.Client/MiniPdf.Web.Client.csproj -c Release -o publish -p:Version=${{ steps.minipdf-version.outputs.version }} - name: Remove pre-compressed files (GitHub Pages does not support content negotiation) run: find publish/wwwroot -name '*.br' -o -name '*.gz' | xargs rm -f diff --git a/MiniPdf.Web/MiniPdf.Web.Client/Pages/Converter.razor b/MiniPdf.Web/MiniPdf.Web.Client/Pages/Converter.razor index 5d898d5d..f585011a 100644 --- a/MiniPdf.Web/MiniPdf.Web.Client/Pages/Converter.razor +++ b/MiniPdf.Web/MiniPdf.Web.Client/Pages/Converter.razor @@ -25,6 +25,7 @@

MiniPdf

+ NuGet v@(MiniPdfVersion)

@L.T("Subtitle") — @L.T("PoweredBy") MiniPdf

@@ -307,6 +308,13 @@ private const string ApiStatusUrl = ApiBaseUrl + "/api/status"; private const string ApiStatsUrl = ApiBaseUrl + "/api/stats"; private const string DefaultFontCacheKey = "NotoSansSC-Regular.ttf"; + private static readonly string MiniPdfVersion = + typeof(MiniSoftware.MiniPdf).Assembly + .GetCustomAttributes(typeof(System.Reflection.AssemblyInformationalVersionAttribute), false) + .OfType() + .FirstOrDefault()?.InformationalVersion.Split('+')[0] + ?? typeof(MiniSoftware.MiniPdf).Assembly.GetName().Version?.ToString(3) + ?? "unknown"; private IBrowserFile? selectedFile; private bool isConverting; diff --git a/MiniPdf.Web/MiniPdf.Web.Client/wwwroot/app.css b/MiniPdf.Web/MiniPdf.Web.Client/wwwroot/app.css index f3fa82c4..b0a861d1 100644 --- a/MiniPdf.Web/MiniPdf.Web.Client/wwwroot/app.css +++ b/MiniPdf.Web/MiniPdf.Web.Client/wwwroot/app.css @@ -101,6 +101,24 @@ h1:focus { outline: none; } letter-spacing: -.02em; } +.package-version { + padding: .2rem .45rem; + border: 1px solid var(--border); + border-radius: 6px; + color: var(--text-secondary); + font-size: .68rem; + font-weight: 600; + line-height: 1; + text-decoration: none; + transition: border-color var(--transition), color var(--transition), background var(--transition); +} + +.package-version:hover { + border-color: var(--accent); + background: var(--accent-light); + color: var(--accent); +} + .subtitle { color: var(--text-secondary); font-size: .9rem;