From 68c8ff73f82b67c8f9c080cd990c1fcf0d119ebe Mon Sep 17 00:00:00 2001 From: uye <99072975+ABA2396@users.noreply.github.com> Date: Fri, 4 Jul 2025 19:18:52 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=9B=A0=E9=87=8D?= =?UTF-8?q?=E5=AE=9A=E5=90=91=E5=AF=BC=E8=87=B4=20ETag=20=E7=BC=93?= =?UTF-8?q?=E5=AD=98=E4=B8=8E=E5=8E=9F=E5=A7=8B=E5=9C=B0=E5=9D=80=E4=B8=8D?= =?UTF-8?q?=E7=AC=A6=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MaaWpfGui/Helper/ETagCache.cs | 4 ++-- src/MaaWpfGui/Services/Web/MaaApiService.cs | 2 +- src/MaaWpfGui/ViewModels/UI/AnnouncementViewModel.cs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/MaaWpfGui/Helper/ETagCache.cs b/src/MaaWpfGui/Helper/ETagCache.cs index ed32614cae..ac3235644a 100644 --- a/src/MaaWpfGui/Helper/ETagCache.cs +++ b/src/MaaWpfGui/Helper/ETagCache.cs @@ -73,10 +73,10 @@ namespace MaaWpfGui.Helper Save(); } - public static void Set(HttpResponseMessage? response) + // UPDATE: 重定向会导致 uri 变成其他地址,导致存的 ETag 无法匹配原始地址,所以要传入原始地址 + public static void Set(HttpResponseMessage? response, string uri) { var etag = response?.Headers.ETag?.Tag; - var uri = response?.RequestMessage?.RequestUri?.ToString(); if (string.IsNullOrEmpty(uri) || string.IsNullOrEmpty(etag)) { return; diff --git a/src/MaaWpfGui/Services/Web/MaaApiService.cs b/src/MaaWpfGui/Services/Web/MaaApiService.cs index 7676f6d7c7..2ccad878b6 100644 --- a/src/MaaWpfGui/Services/Web/MaaApiService.cs +++ b/src/MaaWpfGui/Services/Web/MaaApiService.cs @@ -57,7 +57,7 @@ namespace MaaWpfGui.Services.Web await File.WriteAllTextAsync(cache, body); - ETagCache.Set(response); + ETagCache.Set(response, url); return json; } diff --git a/src/MaaWpfGui/ViewModels/UI/AnnouncementViewModel.cs b/src/MaaWpfGui/ViewModels/UI/AnnouncementViewModel.cs index 6881079305..cb811b6a80 100644 --- a/src/MaaWpfGui/ViewModels/UI/AnnouncementViewModel.cs +++ b/src/MaaWpfGui/ViewModels/UI/AnnouncementViewModel.cs @@ -257,7 +257,7 @@ namespace MaaWpfGui.ViewModels.UI DoNotRemindThisAnnouncementAgain = false; } - ETagCache.Set(response); + ETagCache.Set(response, url); ETagCache.Save(); }