From b40dac00b971732b2dcd7de8ef1b47d7f847fbe2 Mon Sep 17 00:00:00 2001 From: RMBGAME Date: Sun, 1 Dec 2024 01:18:32 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E4=BF=AE=E5=A4=8D=E6=88=98?= =?UTF-8?q?=E7=BD=91=E5=AE=89=E8=A3=85=E6=9C=89=E5=A4=9A=E4=B8=AA=E5=AD=98?= =?UTF-8?q?=E5=9C=A8=E6=97=B6=E4=BF=9D=E5=AD=98=E8=B4=A6=E5=8F=B7=E9=97=AA?= =?UTF-8?q?=E9=80=80=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BasicPlatformSwitcher.cs | 43 ++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/src/BD.WTTS.Client.Plugins.GameAccount/Services.Implementation/BasicPlatformSwitcher.cs b/src/BD.WTTS.Client.Plugins.GameAccount/Services.Implementation/BasicPlatformSwitcher.cs index e694b3b11b6..0a80ae063ff 100644 --- a/src/BD.WTTS.Client.Plugins.GameAccount/Services.Implementation/BasicPlatformSwitcher.cs +++ b/src/BD.WTTS.Client.Plugins.GameAccount/Services.Implementation/BasicPlatformSwitcher.cs @@ -1,5 +1,6 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using System.Text.Json.Nodes; using AppResources = BD.WTTS.Client.Resources.Strings; namespace BD.WTTS.Services.Implementation; @@ -515,7 +516,47 @@ public async ValueTask CurrnetUserAdd(string name, PlatformAccount platfor if (js == null) continue; - var originalValue = js.SelectToken(selector); + JToken? originalValue = null; + + try + { + originalValue = js.SelectToken(selector); + } + catch (Exception ex) + { + Log.Error(nameof(CurrnetUserAdd), ex, $"Failed to select token: {selector}"); + } + + if (originalValue == null) + { + // 尝试以数组形式再次寻找 + try + { + var tokens = js.SelectTokens(selector); + + //暂时将就写一个临时的战网处理方法解决问题 + if (platform.Platform == ThirdpartyPlatform.BattleNet) + { + originalValue = tokens.FirstOrDefault(x => + { + var temp = x.Parent?.Parent?.Parent?.Parent?["Path"]?.Value(); + var temp2 = platform.FolderPath; + if (temp != null && temp2 != null) + return string.Equals( + temp.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar), + temp2.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar), + StringComparison.OrdinalIgnoreCase); + return false; + }); + } + originalValue ??= tokens.FirstOrDefault(); + } + catch (Exception ex) + { + Log.Error(nameof(CurrnetUserAdd), ex, $"Failed to select tokens: {selector}"); + } + } + if (originalValue == null) continue;