From 85df2a405906e3ebfecb392a7b48ba10e8a85efb Mon Sep 17 00:00:00 2001 From: soundofautumn <62000745+soundofautumn@users.noreply.github.com> Date: Thu, 5 Feb 2026 15:36:07 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20WpfGui=E6=B8=85=E7=A9=BA=E7=BC=93?= =?UTF-8?q?=E5=AD=98=E6=8C=89=E9=92=AE=20(#15582)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: 清空缓存按钮 * feat: 排除asst.log和gui.log * i18n: EN * i18n: KR * i18n: zh-tw --------- Co-authored-by: Constrat <56174894+Constrat@users.noreply.github.com> Co-authored-by: HX3N Co-authored-by: HY <45387477+momomochi987@users.noreply.github.com> --- src/MaaWpfGui/Res/Localizations/en-us.xaml | 4 ++ src/MaaWpfGui/Res/Localizations/ja-jp.xaml | 4 ++ src/MaaWpfGui/Res/Localizations/ko-kr.xaml | 4 ++ src/MaaWpfGui/Res/Localizations/zh-cn.xaml | 4 ++ src/MaaWpfGui/Res/Localizations/zh-tw.xaml | 4 ++ .../Settings/IssueReportUserControlModel.cs | 59 +++++++++++++++++++ .../Settings/IssueReportUserControl.xaml | 8 +++ 7 files changed, 87 insertions(+) diff --git a/src/MaaWpfGui/Res/Localizations/en-us.xaml b/src/MaaWpfGui/Res/Localizations/en-us.xaml index 05884274cf..aa05b75603 100644 --- a/src/MaaWpfGui/Res/Localizations/en-us.xaml +++ b/src/MaaWpfGui/Res/Localizations/en-us.xaml @@ -1288,6 +1288,10 @@ 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 cache: Auto refresh 3★ Tags diff --git a/src/MaaWpfGui/Res/Localizations/ja-jp.xaml b/src/MaaWpfGui/Res/Localizations/ja-jp.xaml index 40d63cffff..c8983a336b 100644 --- a/src/MaaWpfGui/Res/Localizations/ja-jp.xaml +++ b/src/MaaWpfGui/Res/Localizations/ja-jp.xaml @@ -1289,6 +1289,10 @@ MAA Team の開発リソースが限られているため、PC 対応は専任 デバッグフォルダーを開く サポート用ZIPの生成に成功しました サポート用ZIPの生成中にエラーが発生しました: + キャッシュをクリア + キャッシュをクリアしました + キャッシュディレクトリは既に空です + キャッシュのクリア中にエラーが発生しました: 星3タグを自動的に更新する diff --git a/src/MaaWpfGui/Res/Localizations/ko-kr.xaml b/src/MaaWpfGui/Res/Localizations/ko-kr.xaml index 03b781e375..cd8d3b6d0e 100644 --- a/src/MaaWpfGui/Res/Localizations/ko-kr.xaml +++ b/src/MaaWpfGui/Res/Localizations/ko-kr.xaml @@ -1290,6 +1290,10 @@ MAA Team의 개발 인력이 제한되어 있어 PC 지원은 전담 관리가 로그 폴더 열기 압축 파일 생성 성공 압축 파일 생성 중 오류가 발생했습니다: + 캐시 비우기 + 캐시 비우기 성공 + 캐시 폴더가 이미 비어 있음 + 캐시 비우기 중 오류가 발생했습니다: ★3 태그 자동 새로고침 diff --git a/src/MaaWpfGui/Res/Localizations/zh-cn.xaml b/src/MaaWpfGui/Res/Localizations/zh-cn.xaml index 916faa54c3..01dec11531 100644 --- a/src/MaaWpfGui/Res/Localizations/zh-cn.xaml +++ b/src/MaaWpfGui/Res/Localizations/zh-cn.xaml @@ -1289,6 +1289,10 @@ C:\\leidian\\LDPlayer9。\n 打开日志文件夹 生成压缩包成功 生成压缩包时出现问题: + 清空缓存 + 缓存已清空 + 缓存目录为空 + 清空缓存时出现问题: 自动刷新 3 星 Tags diff --git a/src/MaaWpfGui/Res/Localizations/zh-tw.xaml b/src/MaaWpfGui/Res/Localizations/zh-tw.xaml index cb061f9f9f..1cac9de6c4 100644 --- a/src/MaaWpfGui/Res/Localizations/zh-tw.xaml +++ b/src/MaaWpfGui/Res/Localizations/zh-tw.xaml @@ -1289,6 +1289,10 @@ C:\\leidian\\LDPlayer9\n 打開紀錄資料夾 壓縮檔產生成功 產生壓縮檔時發生問題: + 清空快取 + 快取已清空 + 快取內容為空 + 清空快取時發生錯誤: 自動刷新 3★ Tags diff --git a/src/MaaWpfGui/ViewModels/UserControl/Settings/IssueReportUserControlModel.cs b/src/MaaWpfGui/ViewModels/UserControl/Settings/IssueReportUserControlModel.cs index 63761016b3..a16519b5af 100644 --- a/src/MaaWpfGui/ViewModels/UserControl/Settings/IssueReportUserControlModel.cs +++ b/src/MaaWpfGui/ViewModels/UserControl/Settings/IssueReportUserControlModel.cs @@ -76,6 +76,43 @@ public class IssueReportUserControlModel : PropertyChangedBase } } + /// + /// 清空缓存 包括cache目录和debug目录 + /// + public void ClearCache() + { + try + { + var clearedDirs = new List(); + + if (Directory.Exists(PathsHelper.CacheDir)) + { + Directory.Delete(PathsHelper.CacheDir, recursive: true); + clearedDirs.Add("cache"); + } + + if (Directory.Exists(PathsHelper.DebugDir)) + { + DeleteDirectoryContentsExcept(PathsHelper.DebugDir, ["asst.log", "gui.log"]); + clearedDirs.Add("debug"); + } + + if (clearedDirs.Count > 0) + { + ShowGrowl(LocalizationHelper.GetString("ClearCacheSuccessful")); + } + else + { + ShowGrowl(LocalizationHelper.GetString("ClearCacheAlreadyEmpty")); + } + } + catch (Exception ex) + { + ShowGrowl($"{LocalizationHelper.GetString("ClearCacheException")}\n{ex.Message}"); + Log.Error(ex, "Failed to clear cache"); + } + } + /// /// 生成日志压缩包 /// @@ -208,6 +245,28 @@ public class IssueReportUserControlModel : PropertyChangedBase } } + /// + /// 删除目录下的所有文件和子目录,排除指定的文件名。 + /// + private static void DeleteDirectoryContentsExcept(string dir, IEnumerable excludeFileNames) + { + var excludeSet = excludeFileNames.ToHashSet(StringComparer.OrdinalIgnoreCase); + foreach (var file in Directory.EnumerateFiles(dir)) + { + if (excludeSet.Contains(Path.GetFileName(file))) + { + continue; + } + + File.Delete(file); + } + + foreach (var subDir in Directory.EnumerateDirectories(dir)) + { + 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 f07a6a4863..bc34b49023 100644 --- a/src/MaaWpfGui/Views/UserControl/Settings/IssueReportUserControl.xaml +++ b/src/MaaWpfGui/Views/UserControl/Settings/IssueReportUserControl.xaml @@ -45,6 +45,7 @@ + @@ -93,6 +94,13 @@ Margin="5,2" Command="{s:Action OpenDebugFolder}" Content="{DynamicResource OpenDebugFolder}" /> +