Skip to content

Commit

Permalink
🐛 修复战网安装有多个存在时保存账号闪退问题
Browse files Browse the repository at this point in the history
  • Loading branch information
rmbadmin committed Nov 30, 2024
1 parent 35be6db commit b40dac0
Showing 1 changed file with 42 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -515,7 +516,47 @@ public async ValueTask<bool> 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<string>();
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;

Expand Down

0 comments on commit b40dac0

Please sign in to comment.