From b44b60159295eafa128e2f17ce4541ebb1a0f6ea Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Tue, 19 Aug 2025 12:59:49 +0800 Subject: [PATCH 1/4] =?UTF-8?q?doc:=20=E6=A0=BC=E5=BC=8F=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BootstrapBlazor.IP2Region/Services/IP2RegionService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/BootstrapBlazor.IP2Region/Services/IP2RegionService.cs b/src/components/BootstrapBlazor.IP2Region/Services/IP2RegionService.cs index 7717591b..ead93d90 100644 --- a/src/components/BootstrapBlazor.IP2Region/Services/IP2RegionService.cs +++ b/src/components/BootstrapBlazor.IP2Region/Services/IP2RegionService.cs @@ -9,7 +9,7 @@ namespace BootstrapBlazor.Components; /// -/// 默认 IP2Region 实现 +/// 默认 IP2Region 实现 /// class IP2RegionService : DefaultIpLocatorProvider { From c260c66fa7ef36b58a7b1373113520efc5c2f3d0 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Tue, 19 Aug 2025 13:00:04 +0800 Subject: [PATCH 2/4] =?UTF-8?q?feat:=20=E4=BD=BF=E7=94=A8=E5=BC=82?= =?UTF-8?q?=E6=AD=A5=E6=8F=90=E9=AB=98=E6=80=A7=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/IP2RegionService.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/BootstrapBlazor.IP2Region/Services/IP2RegionService.cs b/src/components/BootstrapBlazor.IP2Region/Services/IP2RegionService.cs index ead93d90..32230c36 100644 --- a/src/components/BootstrapBlazor.IP2Region/Services/IP2RegionService.cs +++ b/src/components/BootstrapBlazor.IP2Region/Services/IP2RegionService.cs @@ -31,20 +31,22 @@ public IP2RegionService(IOptions options, IOptions _options; private readonly IOptions _ipOptions; private readonly ILogger _logger; + private readonly TaskCompletionSource _tcs = new(); private Searcher? _search; /// /// /// /// - protected override Task LocateByIp(string ip) + protected override async Task LocateByIp(string ip) { + await _tcs.Task; string? result = null; if (_search != null && _options.Value.WebClientOptions.EnableIpLocator) { result = _search.Search(ip); } - return Task.FromResult(result); + return result; } private void InitSearch() @@ -60,9 +62,11 @@ private void InitSearch() { _search = new Searcher(CachePolicy.Content, xdbPath); _logger.LogInformation("IP2Region xdb file {dbPath} loaded", xdbPath); + _tcs.TrySetResult(); } catch (Exception ex) { + _tcs.TrySetException(ex); _logger.LogError(ex, "IP2Region xdb file path: {dbPath}", xdbPath); } } From e2a2c430fa2378d5a9bd352297b3843ca8bd818c Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Tue, 19 Aug 2025 13:14:43 +0800 Subject: [PATCH 3/4] chore: bump version 9.0.3 --- .../BootstrapBlazor.IP2Region/BootstrapBlazor.IP2Region.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/BootstrapBlazor.IP2Region/BootstrapBlazor.IP2Region.csproj b/src/components/BootstrapBlazor.IP2Region/BootstrapBlazor.IP2Region.csproj index 2d9ed946..20aba966 100644 --- a/src/components/BootstrapBlazor.IP2Region/BootstrapBlazor.IP2Region.csproj +++ b/src/components/BootstrapBlazor.IP2Region/BootstrapBlazor.IP2Region.csproj @@ -1,7 +1,7 @@  - 9.0.2 + 9.0.3 From f79e61a5a09a233ffc819220acd88d2c8b6926b1 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Tue, 19 Aug 2025 13:15:04 +0800 Subject: [PATCH 4/4] =?UTF-8?q?perf:=20=E4=BD=BF=E7=94=A8=E5=BC=82?= =?UTF-8?q?=E6=AD=A5=E6=8F=90=E9=AB=98=E5=88=9D=E5=A7=8B=E5=8C=96=E9=80=9F?= =?UTF-8?q?=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BootstrapBlazor.IP2Region/Services/IP2RegionService.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/BootstrapBlazor.IP2Region/Services/IP2RegionService.cs b/src/components/BootstrapBlazor.IP2Region/Services/IP2RegionService.cs index 32230c36..56fcfa0e 100644 --- a/src/components/BootstrapBlazor.IP2Region/Services/IP2RegionService.cs +++ b/src/components/BootstrapBlazor.IP2Region/Services/IP2RegionService.cs @@ -25,7 +25,7 @@ public IP2RegionService(IOptions options, IOptions _options; @@ -41,6 +41,7 @@ public IP2RegionService(IOptions options, IOptions LocateByIp(string ip) { await _tcs.Task; + string? result = null; if (_search != null && _options.Value.WebClientOptions.EnableIpLocator) {