From 8122a65e86fdbec7bbeed72b21703484e2ea38c4 Mon Sep 17 00:00:00 2001 From: camileko Date: Sun, 13 Sep 2026 23:50:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BD=BF=E7=94=A8=E4=B8=AD?= =?UTF-8?q?=E6=96=87=E6=90=9C=E7=B4=A2=20Mod=E3=80=81=E5=90=8C=E6=97=B6?= =?UTF-8?q?=E6=8C=87=E5=AE=9A=E7=89=88=E6=9C=AC=E5=92=8C=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=E5=99=A8=E6=97=B6=EF=BC=8CModrinth=20=E5=8F=AF=E8=83=BD?= =?UTF-8?q?=E5=87=BA=E7=8E=B0=E5=88=86=E5=88=AB=E5=8C=B9=E9=85=8D=E4=BD=86?= =?UTF-8?q?=E5=AE=9E=E9=99=85=E4=B8=8A=E6=B2=A1=E6=9C=89=E5=AF=B9=E5=BA=94?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E7=9A=84=E7=BB=93=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Modules/Resource/ResourceSearcher.vb | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/Plain Craft Launcher 2/Modules/Resource/ResourceSearcher.vb b/Plain Craft Launcher 2/Modules/Resource/ResourceSearcher.vb index 263be2f..c7734ca 100644 --- a/Plain Craft Launcher 2/Modules/Resource/ResourceSearcher.vb +++ b/Plain Craft Launcher 2/Modules/Resource/ResourceSearcher.vb @@ -378,12 +378,23 @@ NextPage: If Request.Type <> ResourceTypes.Any AndAlso Not Project.Types.HasFlagF(Request.Type) Then Continue For If Not String.IsNullOrEmpty(Request.Tag) AndAlso Not JsonEntry("categories").Any(Function(c) c.ToString = Request.Tag.AfterLast("/")) Then Continue For 'Project.Tags 已经转换成中文了,只能从 json 判 - If Request.ModLoaders <> ModLoaders.None AndAlso Not IgnoreModLoaderFilter AndAlso - Not Project.ModLoaders.Flags.Intersect(Request.ModLoaders.Flags).Any() Then Continue For - If Not String.IsNullOrEmpty(Request.GameVersion) AndAlso - Not Project.UnsafeGameVersions.Any(Function(d) d = Request.GameVersion) Then Continue For ProjectList.Add(Project) Next + Dim Facets As New List(Of String) + If Request.ModLoaders <> ModLoaders.None AndAlso Not IgnoreModLoaderFilter Then + Facets.Add($"[""categories:'{Request.ModLoaders.Flags.Select(Function(f) f.ToString.Lower).Join("'"",""categories:'")}'""]") + End If + If Not String.IsNullOrEmpty(Request.GameVersion) Then Facets.Add($"[""versions:'{Request.GameVersion}'""]") + If ProjectList.Any AndAlso Facets.Any Then + Facets.Add("[""project_id:" & ProjectList.Select(Function(p) p.Id).Join(""",""project_id:") & """]") + Dim FilterUrl As String = $"https://api.modrinth.com/v2/search?limit={Math.Min(ProjectList.Count, 100)}&facets=[" & String.Join(",", Facets) & "]" + Logger.Info($"开始 Modrinth 直接获取筛选:{FilterUrl}") + Dim MatchedIds As New List(Of String) + For Each JsonEntry As JObject In DlModRequest(FilterUrl)("hits") + MatchedIds.Add(JsonEntry("project_id").ToString) + Next + ProjectList.KeepIf(Function(p) MatchedIds.Contains(p.Id)) + End If '更新结果 ProjectList.ForEach(Sub(p) SearchResults.Add(p)) Logger.Info($"从 Modrinth 直接获取到了 {ProjectList.Count} 个工程")