From f91f2cb75c358f4bc086b5e1714d44185cfeeb23 Mon Sep 17 00:00:00 2001 From: DavidWang19 Date: Fri, 24 Mar 2023 21:53:19 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0json=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=E8=B6=85=E6=97=B6=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MaaWpfGui/Helper/WebService.cs | 8 ++++++++ src/MaaWpfGui/Main/CopilotViewModel.cs | 9 +-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/MaaWpfGui/Helper/WebService.cs b/src/MaaWpfGui/Helper/WebService.cs index e441e51c24..19f182c1b9 100644 --- a/src/MaaWpfGui/Helper/WebService.cs +++ b/src/MaaWpfGui/Helper/WebService.cs @@ -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), diff --git a/src/MaaWpfGui/Main/CopilotViewModel.cs b/src/MaaWpfGui/Main/CopilotViewModel.cs index 5206af8f01..54d89c8ac7 100644 --- a/src/MaaWpfGui/Main/CopilotViewModel.cs +++ b/src/MaaWpfGui/Main/CopilotViewModel.cs @@ -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 RequestCopilotServer(int copilotID)