From f4490c3395246218ee084013a32e2a2394b35a7b Mon Sep 17 00:00:00 2001 From: Argo-Tianyi Date: Sun, 23 Jan 2022 20:50:59 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E5=9C=B0=E7=90=86?= =?UTF-8?q?=E4=BD=8D=E7=BD=AE=E5=AE=9A=E4=BD=8D=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BootstrapAdmin.DataAccess.PetaPoco.csproj | 2 +- .../Extensions/ServiceCollectionExtensions.cs | 3 +++ .../BootstrapAdmin.Web/Pages/Admin/Settings.razor.cs | 8 +++++++- .../admin/BootstrapAdmin.Web/Shared/MainLayout.razor.cs | 2 +- .../admin/BootstrapAdmin.Web/Utils/LocatorHelper.cs | 1 - 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/blazor/admin/BootstrapAdmin.DataAccess.PetaPoco/BootstrapAdmin.DataAccess.PetaPoco.csproj b/src/blazor/admin/BootstrapAdmin.DataAccess.PetaPoco/BootstrapAdmin.DataAccess.PetaPoco.csproj index e14370e1..3bb7fe42 100644 --- a/src/blazor/admin/BootstrapAdmin.DataAccess.PetaPoco/BootstrapAdmin.DataAccess.PetaPoco.csproj +++ b/src/blazor/admin/BootstrapAdmin.DataAccess.PetaPoco/BootstrapAdmin.DataAccess.PetaPoco.csproj @@ -1,7 +1,7 @@  - + diff --git a/src/blazor/admin/BootstrapAdmin.Web/Extensions/ServiceCollectionExtensions.cs b/src/blazor/admin/BootstrapAdmin.Web/Extensions/ServiceCollectionExtensions.cs index 95f372d9..e35f3e54 100644 --- a/src/blazor/admin/BootstrapAdmin.Web/Extensions/ServiceCollectionExtensions.cs +++ b/src/blazor/admin/BootstrapAdmin.Web/Extensions/ServiceCollectionExtensions.cs @@ -36,6 +36,9 @@ namespace Microsoft.Extensions.DependencyInjection // 增加 BootstrapBlazor 组件 services.AddBootstrapBlazor(); + // 配置地理位置定位器 + services.ConfigureIPLocatorOption(op => op.LocatorFactory = LocatorHelper.CreateLocator); + // 增加手机短信服务 services.AddSingleton(); diff --git a/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Settings.razor.cs b/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Settings.razor.cs index 8ebe82dc..9189019f 100644 --- a/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Settings.razor.cs +++ b/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Settings.razor.cs @@ -174,5 +174,11 @@ public partial class Settings await ShowToast(ret, "日志缓存"); } - private Task RenderLayout(string key) => Layout.OnUpdate(key); + private async Task RenderLayout(string key) + { + if (Layout.OnUpdate != null) + { + await Layout.OnUpdate(key); + } + } } diff --git a/src/blazor/admin/BootstrapAdmin.Web/Shared/MainLayout.razor.cs b/src/blazor/admin/BootstrapAdmin.Web/Shared/MainLayout.razor.cs index 088cadad..38e49370 100644 --- a/src/blazor/admin/BootstrapAdmin.Web/Shared/MainLayout.razor.cs +++ b/src/blazor/admin/BootstrapAdmin.Web/Shared/MainLayout.razor.cs @@ -100,7 +100,7 @@ namespace BootstrapAdmin.Web.Shared var city = "XX XX"; if (!string.IsNullOrEmpty(clientInfo.Ip)) { - city = await IPLocatorProvider.Locate(clientInfo.Ip); + city = await IPLocatorProvider.Locate(clientInfo.Ip) ?? "None"; } TraceService.Log(new Trace { diff --git a/src/blazor/admin/BootstrapAdmin.Web/Utils/LocatorHelper.cs b/src/blazor/admin/BootstrapAdmin.Web/Utils/LocatorHelper.cs index b647d05f..92f68ad0 100644 --- a/src/blazor/admin/BootstrapAdmin.Web/Utils/LocatorHelper.cs +++ b/src/blazor/admin/BootstrapAdmin.Web/Utils/LocatorHelper.cs @@ -10,7 +10,6 @@ static class LocatorHelper var providerName = dictService.GetIpLocatorName(); var providerUrl = dictService.GetIpLocatorUrl(providerName ?? string.Empty); - // TODO: 稍后完善 其余地理位置定位服务 return providerName switch { "BaiDuIPSvr" => new BaiDuIPLocator(),