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(),