From b872e973fee736ee39d3a40839b932660952de8d Mon Sep 17 00:00:00 2001 From: zdAnQi <131591012+zaodonganqi@users.noreply.github.com> Date: Wed, 23 Jul 2025 21:47:04 +0800 Subject: [PATCH] =?UTF-8?q?=E7=88=B6=E8=8A=82=E7=82=B9=E5=AD=98=E5=9C=A8?= =?UTF-8?q?=E6=80=A7=E6=A3=80=E6=B5=8B=20(#1897)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Core/Script/ScriptRepoUpdater.cs | 47 ++++++++++++------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/BetterGenshinImpact/Core/Script/ScriptRepoUpdater.cs b/BetterGenshinImpact/Core/Script/ScriptRepoUpdater.cs index d2df6d97..2dba6ff6 100644 --- a/BetterGenshinImpact/Core/Script/ScriptRepoUpdater.cs +++ b/BetterGenshinImpact/Core/Script/ScriptRepoUpdater.cs @@ -620,24 +620,38 @@ public class ScriptRepoUpdater : Singleton var scriptConfig = TaskContext.Instance().Config.ScriptConfig; var validRoots = PathMapper.Keys.ToHashSet(); - // 过滤并保留有效路径 - scriptConfig.SubscribedScriptPaths = scriptConfig.SubscribedScriptPaths + var allPaths = scriptConfig.SubscribedScriptPaths .Distinct() - .Where(path => + .OrderBy(path => path) + .ToList(); + + var pathsToKeep = new HashSet(); + + foreach (var path in allPaths) + { + if (string.IsNullOrEmpty(path) || !path.Contains('/')) + continue; + + var root = path.Split('/')[0]; + if (!validRoots.Contains(root)) + continue; + + var (_, remainingPath) = GetFirstFolderAndRemainingPath(path); + var userPath = Path.Combine(PathMapper[root], remainingPath); + if (!Directory.Exists(userPath) && !File.Exists(userPath)) + continue; + + // 检查是否已被父路径覆盖 + bool isCoveredByParent = pathsToKeep.Any(p => + path.StartsWith(p + "/") || path == p); + + if (!isCoveredByParent) { - if (string.IsNullOrEmpty(path) || !path.Contains('/')) - return false; + pathsToKeep.Add(path); + } + } - var root = path.Split('/')[0]; - - if (!validRoots.Contains(root)) - return false; - - var (_, remainingPath) = GetFirstFolderAndRemainingPath(path); - var userPath = Path.Combine(PathMapper[root], remainingPath); - - return Directory.Exists(userPath) || File.Exists(userPath); - }) + scriptConfig.SubscribedScriptPaths = pathsToKeep .OrderBy(path => path) .ToList(); } @@ -684,6 +698,7 @@ public class ScriptRepoUpdater : Singleton public void OpenLocalRepoInWebView() { + UpdateSubscribedScriptPaths(); if (_webWindow is not { IsVisible: true }) { _webWindow = new WebpageWindow @@ -746,4 +761,4 @@ public class ScriptRepoUpdater : Singleton } } } -} \ No newline at end of file +}