From 53e59bea593ee11f4bf7559d57fcee05d9ae9cf4 Mon Sep 17 00:00:00 2001
From: uye <99072975+ABA2396@users.noreply.github.com>
Date: Tue, 10 Feb 2026 00:51:49 +0800
Subject: [PATCH] =?UTF-8?q?chore:=20=E8=B0=83=E6=95=B4=E6=B8=85=E7=90=86?=
=?UTF-8?q?=E5=9B=BE=E7=89=87=E7=BC=93=E5=AD=98=E6=A0=B7=E5=BC=8F=EF=BC=8C?=
=?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8F=90=E7=A4=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
CHANGELOG.md | 3 +-
src/MaaWpfGui/Res/Localizations/en-us.xaml | 12 ++-
src/MaaWpfGui/Res/Localizations/ja-jp.xaml | 12 ++-
src/MaaWpfGui/Res/Localizations/ko-kr.xaml | 12 ++-
src/MaaWpfGui/Res/Localizations/zh-cn.xaml | 12 ++-
src/MaaWpfGui/Res/Localizations/zh-tw.xaml | 12 ++-
src/MaaWpfGui/Services/Web/MaaApiService.cs | 2 +-
.../Settings/IssueReportUserControlModel.cs | 68 ++++++++++---
.../Settings/IssueReportUserControl.xaml | 99 +++++++++----------
9 files changed, 143 insertions(+), 89 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f3e851ab4b..474e731416 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -37,7 +37,7 @@ MAA now supports the PC version of Arknights. However, due to limited maintenanc
* 界园肉鸽可选难度提高至 18 @SherkeyXD
* 芯片本支持显示库存数量 @ABA2396
* 发布时 minify resource 文件下的 json (#15567) @soundofautumn
-* WpfGui 清空缓存按钮 (#15582) @soundofautumn @Constrat @HX3N
+* wpf 增加清理图片缓存功能 @soundofautumn @Constrat @HX3N @status102 @ABA2396
* 界园肉鸽指定种子开局 (#15588) @status102 @HX3N @Manicsteiner
### 改进 | Improved
@@ -46,7 +46,6 @@ MAA now supports the PC version of Arknights. However, due to limited maintenanc
* 自动战斗不支持技能重置说明中, 干员名遵循干员名语言设置 @status102
* 移除过时的参数兼容 @status102
* 追加自定干员允许不切换技能 @status102
-* 清空缓存移动到界面设置 @status102
* 自动战斗作业列表使用相对路径代替绝对路径 @status102
* TaskQueue 任务开始&完成显示修改后的任务名 @status102
diff --git a/src/MaaWpfGui/Res/Localizations/en-us.xaml b/src/MaaWpfGui/Res/Localizations/en-us.xaml
index 556fce8c55..e0eb8dbe6f 100644
--- a/src/MaaWpfGui/Res/Localizations/en-us.xaml
+++ b/src/MaaWpfGui/Res/Localizations/en-us.xaml
@@ -1289,10 +1289,14 @@ Before use, please ensure:
Open Debug Folder
Support payload generated successfully
An error occurred while generating the support payload:
- Clear Cache
- Cache cleared successfully
- Cache directories are already empty
- An error occurred while clearing the cache:
+ Clear Image Cache
+ Manual cleanup is usually unnecessary.
+Images in the DEBUG directory have a quantity limit, and old images are automatically cleaned when exceeded.
+Manual cleanup deletes all images, which may result in missing screenshots for troubleshooting.
+Cache files (such as maps, operator avatars, etc.) need to be regenerated after clearing, which may affect user experience.
+ Image cache cleared successfully
+ Image cache is already empty
+ An error occurred while clearing the image cache:
Auto refresh 3★ Tags
diff --git a/src/MaaWpfGui/Res/Localizations/ja-jp.xaml b/src/MaaWpfGui/Res/Localizations/ja-jp.xaml
index 7759e18c53..5261e8635d 100644
--- a/src/MaaWpfGui/Res/Localizations/ja-jp.xaml
+++ b/src/MaaWpfGui/Res/Localizations/ja-jp.xaml
@@ -1290,10 +1290,14 @@ MAA Team の開発リソースが限られているため、PC 対応は専任
デバッグフォルダーを開く
サポート用ZIPの生成に成功しました
サポート用ZIPの生成中にエラーが発生しました:
- キャッシュをクリア
- キャッシュをクリアしました
- キャッシュディレクトリは既に空です
- キャッシュのクリア中にエラーが発生しました:
+ 画像キャッシュをクリア
+ 通常、手動でクリアする必要はありません。
+DEBUGディレクトリに保存される画像には数量制限があり、超過すると古い画像が自動的にクリアされます。
+手動クリアはすべての画像を削除するため、問題調査時にスクリーンショットが不足する可能性があります。
+キャッシュファイル(マップ、オペレーターアイコンなど)はクリア後に再生成が必要で、使用体験に影響する可能性があります。
+ 画像キャッシュをクリアしました
+ 画像キャッシュは既に空です
+ 画像キャッシュのクリア中にエラーが発生しました:
星3タグを自動的に更新する
diff --git a/src/MaaWpfGui/Res/Localizations/ko-kr.xaml b/src/MaaWpfGui/Res/Localizations/ko-kr.xaml
index 3e633462be..518ac79e38 100644
--- a/src/MaaWpfGui/Res/Localizations/ko-kr.xaml
+++ b/src/MaaWpfGui/Res/Localizations/ko-kr.xaml
@@ -1291,10 +1291,14 @@ MAA Team의 개발 인력이 제한되어 있어 PC 지원은 전담 관리가
로그 폴더 열기
압축 파일 생성 성공
압축 파일 생성 중 오류가 발생했습니다:
- 캐시 비우기
- 캐시 비우기 성공
- 캐시 폴더가 이미 비어 있음
- 캐시 비우기 중 오류가 발생했습니다:
+ 이미지 캐시 비우기
+ 일반적으로 수동 정리가 필요하지 않습니다.
+DEBUG 디렉토리에 저장된 이미지는 수량 제한이 있으며 초과 시 오래된 이미지가 자동으로 정리됩니다.
+수동 정리는 모든 이미지를 삭제하므로 문제 해결 시 스크린샷이 부족할 수 있습니다.
+캐시 파일(지도, 오퍼레이터 아바타 등)은 정리 후 재생성이 필요하며 사용 경험에 영향을 줄 수 있습니다.
+ 이미지 캐시 비우기 성공
+ 이미지 캐시가 이미 비어 있음
+ 이미지 캐시 비우기 중 오류가 발생했습니다:
★3 태그 자동 새로고침
diff --git a/src/MaaWpfGui/Res/Localizations/zh-cn.xaml b/src/MaaWpfGui/Res/Localizations/zh-cn.xaml
index 47c33888f9..8ecbc3cfbe 100644
--- a/src/MaaWpfGui/Res/Localizations/zh-cn.xaml
+++ b/src/MaaWpfGui/Res/Localizations/zh-cn.xaml
@@ -1290,10 +1290,14 @@ C:\\leidian\\LDPlayer9。\n
打开日志文件夹
生成压缩包成功
生成压缩包时出现问题:
- 清空缓存
- 缓存已清空
- 缓存目录为空
- 清空缓存时出现问题:
+ 清空图片缓存
+ 正常情况下无需手动清理。
+DEBUG 目录下保存的图片有数量限制,超出后会自动清理旧图片。
+手动清理会删除所有图片,可能导致问题排查时缺少截图依据。
+缓存文件(如地图、干员头像等)清理后需要重新生成,可能影响使用体验。
+ 图片缓存已清空
+ 图片缓存为空
+ 清空图片缓存时出现问题:
自动刷新 3 星 Tags
diff --git a/src/MaaWpfGui/Res/Localizations/zh-tw.xaml b/src/MaaWpfGui/Res/Localizations/zh-tw.xaml
index a2691acb02..67c86f0290 100644
--- a/src/MaaWpfGui/Res/Localizations/zh-tw.xaml
+++ b/src/MaaWpfGui/Res/Localizations/zh-tw.xaml
@@ -1290,10 +1290,14 @@ C:\\leidian\\LDPlayer9\n
打開紀錄資料夾
壓縮檔產生成功
產生壓縮檔時發生問題:
- 清空快取
- 快取已清空
- 快取內容為空
- 清空快取時發生錯誤:
+ 清空圖片快取
+ 正常情況下無需手動清理。
+DEBUG 目錄下儲存的圖片有數量限制,超出後會自動清理舊圖片。
+手動清理會刪除所有圖片,可能導致問題排查時缺少截圖依據。
+快取檔案(如地圖、幹員頭像等)清理後需要重新產生,可能影響使用體驗。
+ 圖片快取已清空
+ 圖片快取為空
+ 清空圖片快取時發生錯誤:
自動刷新 3★ Tags
diff --git a/src/MaaWpfGui/Services/Web/MaaApiService.cs b/src/MaaWpfGui/Services/Web/MaaApiService.cs
index 64ad1b6cf2..15328b20e3 100644
--- a/src/MaaWpfGui/Services/Web/MaaApiService.cs
+++ b/src/MaaWpfGui/Services/Web/MaaApiService.cs
@@ -24,7 +24,7 @@ namespace MaaWpfGui.Services.Web;
public class MaaApiService : IMaaApiService
{
- private static readonly string CacheDir = PathsHelper.BaseDir + "/cache/";
+ private static readonly string CacheDir = PathsHelper.CacheDir;
public async Task RequestMaaApiWithCache(string api, bool allowFallbackToCache = true)
{
diff --git a/src/MaaWpfGui/ViewModels/UserControl/Settings/IssueReportUserControlModel.cs b/src/MaaWpfGui/ViewModels/UserControl/Settings/IssueReportUserControlModel.cs
index 4d8b87b62a..93205f2fde 100644
--- a/src/MaaWpfGui/ViewModels/UserControl/Settings/IssueReportUserControlModel.cs
+++ b/src/MaaWpfGui/ViewModels/UserControl/Settings/IssueReportUserControlModel.cs
@@ -18,6 +18,7 @@ using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Linq;
+using System.Windows;
using HandyControl.Controls;
using HandyControl.Data;
using JetBrains.Annotations;
@@ -77,42 +78,83 @@ public class IssueReportUserControlModel : PropertyChangedBase
}
///
- /// 清空缓存 包括 cache 目录和 debug 目录
+ /// 清空图片缓存 仅删除 cache 目录和 debug 目录中的图片文件,保留文件夹结构
///
- public static void ClearCache()
+ public static void ClearImageCache()
{
+ var result = MessageBoxHelper.Show(
+ LocalizationHelper.GetString("ClearImageCacheTip"),
+ LocalizationHelper.GetString("Warning"),
+ MessageBoxButton.YesNo,
+ MessageBoxImage.Error,
+ no: LocalizationHelper.GetString("Confirm"),
+ yes: LocalizationHelper.GetString("Cancel"));
+ if (result == MessageBoxResult.Yes)
+ {
+ return;
+ }
+
try
{
- var clearedDirs = new List();
+ var imageExtensions = new HashSet(StringComparer.OrdinalIgnoreCase)
+ {
+ ".jpg", ".jpeg", ".png",
+ };
+
+ int deletedCount = 0;
if (Directory.Exists(PathsHelper.CacheDir))
{
- Directory.Delete(PathsHelper.CacheDir, recursive: true);
- clearedDirs.Add("cache");
+ deletedCount += DeleteImageFiles(PathsHelper.CacheDir, imageExtensions);
}
if (Directory.Exists(PathsHelper.DebugDir))
{
- DeleteDirectoryContentsExcept(PathsHelper.DebugDir, ["asst.log", "gui.log"]);
- clearedDirs.Add("debug");
+ deletedCount += DeleteImageFiles(PathsHelper.DebugDir, imageExtensions);
}
- if (clearedDirs.Count > 0)
+ if (deletedCount > 0)
{
- ShowGrowl(LocalizationHelper.GetString("ClearCacheSuccessful"));
+ ShowGrowl(LocalizationHelper.GetString("ClearImageCacheSuccessful"));
}
else
{
- ShowGrowl(LocalizationHelper.GetString("ClearCacheAlreadyEmpty"));
+ ShowGrowl(LocalizationHelper.GetString("ClearImageCacheAlreadyEmpty"));
}
}
catch (Exception ex)
{
- ShowGrowl($"{LocalizationHelper.GetString("ClearCacheException")}\n{ex.Message}");
- Log.Error(ex, "Failed to clear cache");
+ ShowGrowl($"{LocalizationHelper.GetString("ClearImageCacheException")}\n{ex.Message}");
+ Log.Error(ex, "Failed to clear image cache");
}
}
+ ///
+ /// 删除指定目录及其子目录中的所有图片文件。
+ ///
+ private static int DeleteImageFiles(string dir, HashSet imageExtensions)
+ {
+ int deletedCount = 0;
+ foreach (var file in Directory.EnumerateFiles(dir, "*", SearchOption.AllDirectories))
+ {
+ string extension = Path.GetExtension(file);
+ if (imageExtensions.Contains(extension))
+ {
+ try
+ {
+ File.Delete(file);
+ deletedCount++;
+ }
+ catch (Exception ex)
+ {
+ Log.Warning(ex, $"Failed to delete image file: {file}");
+ }
+ }
+ }
+
+ return deletedCount;
+ }
+
///
/// 生成日志压缩包
///
@@ -245,6 +287,7 @@ public class IssueReportUserControlModel : PropertyChangedBase
}
}
+ /*
///
/// 删除目录下的所有文件和子目录,排除指定的文件名。
///
@@ -266,6 +309,7 @@ public class IssueReportUserControlModel : PropertyChangedBase
Directory.Delete(subDir, recursive: true);
}
}
+ */
///
/// 从 sourceDir 复制文件到 targetDir,支持过滤。
diff --git a/src/MaaWpfGui/Views/UserControl/Settings/IssueReportUserControl.xaml b/src/MaaWpfGui/Views/UserControl/Settings/IssueReportUserControl.xaml
index 40e3c839e1..93805de783 100644
--- a/src/MaaWpfGui/Views/UserControl/Settings/IssueReportUserControl.xaml
+++ b/src/MaaWpfGui/Views/UserControl/Settings/IssueReportUserControl.xaml
@@ -41,67 +41,58 @@
TextWrapping="Wrap"
Visibility="{c:Binding 'NewVersionFoundInfo.Length + NewResourceFoundInfo.Length == 0',
Source={x:Static ui_vms:SettingsViewModel.VersionUpdateSettings}}" />
-
-
-
-
-
-
+
-
-
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+