From 57683f8de88205b0cb5b0d27c3ec43ae76df6fe4 Mon Sep 17 00:00:00 2001 From: meoacgx Date: Tue, 3 Mar 2026 00:38:11 +0800 Subject: [PATCH] =?UTF-8?q?fix(export):=20=E7=A6=81=E6=AD=A2=E8=B4=A6?= =?UTF-8?q?=E5=8F=B7=E5=AF=BC=E5=87=BA=E4=B8=8B=E8=BD=BD=E7=BC=93=E5=AD=98?= =?UTF-8?q?=EF=BC=8C=E9=81=BF=E5=85=8D=E9=87=8D=E5=A4=8D=E6=8B=BF=E5=88=B0?= =?UTF-8?q?=E6=97=A7=20tdata=20=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 前端下载地址追加 ts 时间戳参数,强制每次请求唯一 URL\n- 后端 /downloads/accounts.zip 返回 no-store/no-cache 头,禁止浏览器复用旧响应\n- 修复导出后仍下载到历史坏包(旧 tdata 无法登录)的现象 --- src/TelegramPanel.Web/Components/Pages/Accounts.razor | 3 ++- src/TelegramPanel.Web/Program.cs | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/TelegramPanel.Web/Components/Pages/Accounts.razor b/src/TelegramPanel.Web/Components/Pages/Accounts.razor index 9835174..fbbb826 100644 --- a/src/TelegramPanel.Web/Components/Pages/Accounts.razor +++ b/src/TelegramPanel.Web/Components/Pages/Accounts.razor @@ -958,7 +958,8 @@ return; var qs = string.Join(",", ids); - Navigation.NavigateTo($"/downloads/accounts.zip?ids={qs}&format={format}", forceLoad: true); + var ts = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); + Navigation.NavigateTo($"/downloads/accounts.zip?ids={qs}&format={format}&ts={ts}", forceLoad: true); } private async Task SelectExportFormatAsync(int accountCount, string scopeLabel) diff --git a/src/TelegramPanel.Web/Program.cs b/src/TelegramPanel.Web/Program.cs index 463c034..b190113 100644 --- a/src/TelegramPanel.Web/Program.cs +++ b/src/TelegramPanel.Web/Program.cs @@ -864,6 +864,11 @@ var accountsZipDownload = app.MapGet("/downloads/accounts.zip", async ( var zipBytes = await exporter.BuildAccountsZipAsync(accounts, cancellationToken, format); var formatName = format == AccountExportFormat.Tdata ? "tdata" : "telethon"; var fileName = $"telegram-panel-accounts-{formatName}-{DateTime.UtcNow:yyyyMMdd-HHmmss}.zip"; + + // 下载文件禁止缓存,避免浏览器复用旧的 accounts.zip 导致“重复拿到旧导出包”。 + http.Response.Headers.CacheControl = "no-store, no-cache, must-revalidate, max-age=0"; + http.Response.Headers.Pragma = "no-cache"; + http.Response.Headers.Expires = "0"; return Results.File(zipBytes, "application/zip", fileName); }).DisableAntiforgery(); if (adminAuthEnabled)