mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-17 18:01:26 +08:00
feat: 增加json请求超时限制 (#4065)
This commit is contained in:
@@ -27,6 +27,8 @@ namespace MaaWpfGui.Helper
|
||||
{
|
||||
public const string RequestUserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36 Edg/97.0.1072.76";
|
||||
|
||||
private const int TimeoutMs = 3000;
|
||||
|
||||
private static string s_proxy = Config.Get(Config.UpdateProxy, string.Empty);
|
||||
|
||||
public static string Proxy
|
||||
@@ -35,12 +37,18 @@ namespace MaaWpfGui.Helper
|
||||
{
|
||||
s_proxy = value;
|
||||
NormalClient = BuildNormalClient();
|
||||
NormalClient.Timeout = TimeSpan.FromMilliseconds(TimeoutMs);
|
||||
}
|
||||
}
|
||||
|
||||
#nullable enable
|
||||
public static HttpClient NormalClient { get; private set; } = BuildNormalClient();
|
||||
|
||||
static WebService()
|
||||
{
|
||||
NormalClient.Timeout = TimeSpan.FromMilliseconds(TimeoutMs);
|
||||
}
|
||||
|
||||
private static HttpClient BuildNormalClient() => new HttpClient(new HttpClientHandler()
|
||||
{
|
||||
Proxy = string.IsNullOrWhiteSpace(s_proxy) ? null : new WebProxy(s_proxy),
|
||||
|
||||
@@ -148,13 +148,7 @@ namespace MaaWpfGui
|
||||
get => _filename;
|
||||
set
|
||||
{
|
||||
if (value == _filename)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_filename = value;
|
||||
NotifyOfPropertyChange(() => Filename);
|
||||
SetAndNotify(ref _filename, value);
|
||||
ClearLog();
|
||||
UpdateFilename();
|
||||
}
|
||||
@@ -224,7 +218,6 @@ namespace MaaWpfGui
|
||||
{
|
||||
ParseJsonAndShowInfo(jsonStr);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private async Task<string> RequestCopilotServer(int copilotID)
|
||||
|
||||
Reference in New Issue
Block a user