From 18ab161d0c3d79c26f83cd1b88d9e07278329ea8 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Wed, 19 Feb 2025 18:37:39 +0800 Subject: [PATCH 1/9] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=20enableIpLocato?= =?UTF-8?q?r=20=E5=8F=82=E6=95=B0=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor/wwwroot/modules/hub.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/BootstrapBlazor/wwwroot/modules/hub.js b/src/BootstrapBlazor/wwwroot/modules/hub.js index ac0923bbd8c..95602948d2b 100644 --- a/src/BootstrapBlazor/wwwroot/modules/hub.js +++ b/src/BootstrapBlazor/wwwroot/modules/hub.js @@ -3,7 +3,7 @@ import Data from "./data.js" import EventHandler from "./event-handler.js"; export async function init(id, options) { - const { invoke, method, interval = 3000, url, connectionId } = options; + const { invoke, method, interval = 3000, url, connectionId, enableIpLocator } = options; const elKey = 'bb_hub_el_id'; if (localStorage.getItem(elKey) === null) { localStorage.setItem(elKey, id); @@ -34,7 +34,7 @@ export async function init(id, options) { } }); - const info = await getClientInfo(url); + const info = await getClientInfo(url, { enableIpLocator: enableIpLocator }); info.id = clientId; const callback = async () => { From ba712ebe000e9272848c2467920585bb05c39b5a Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Wed, 19 Feb 2025 18:38:04 +0800 Subject: [PATCH 2/9] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E7=A6=81?= =?UTF-8?q?=E6=AD=A2=E8=B0=83=E7=94=A8=20ip.axd=20=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor/wwwroot/modules/client.js | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/BootstrapBlazor/wwwroot/modules/client.js b/src/BootstrapBlazor/wwwroot/modules/client.js index a608d7b9090..73bdab42dde 100644 --- a/src/BootstrapBlazor/wwwroot/modules/client.js +++ b/src/BootstrapBlazor/wwwroot/modules/client.js @@ -1,12 +1,12 @@ import "./browser.js" import { execute } from "./ajax.js" -export async function ping(url, invoke, method) { - const data = await getClientInfo(url); +export async function ping(url, invoke, method, options) { + const data = await getClientInfo(url, options); await invoke.invokeMethodAsync(method, data) } -export async function getClientInfo(url) { +export async function getClientInfo(url, options) { const info = browser() let data = { browser: info.browser + ' ' + info.version, @@ -17,12 +17,14 @@ export async function getClientInfo(url) { os: info.system + ' ' + info.systemVersion } - const result = await execute({ - method: 'GET', - url - }); - if (result) { - data.ip = result.Ip; + if (options.enableIpLocator === true) { + const result = await execute({ + method: 'GET', + url + }); + if (result) { + data.ip = result.Ip; + } } data.id = localStorage.getItem('bb_hub_connection_id') ?? result.Id; return data; From 455466772fc3aca049f78a2e178e0b566626aad7 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Wed, 19 Feb 2025 18:38:27 +0800 Subject: [PATCH 3/9] =?UTF-8?q?refactor:=20=E5=A2=9E=E5=8A=A0=20EnableIpLo?= =?UTF-8?q?cator=20=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/ConnectionHub/ConnectionHub.cs | 3 ++- src/BootstrapBlazor/Services/WebClientService.cs | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/BootstrapBlazor/Components/ConnectionHub/ConnectionHub.cs b/src/BootstrapBlazor/Components/ConnectionHub/ConnectionHub.cs index 57114bf3447..e6961bc3989 100644 --- a/src/BootstrapBlazor/Components/ConnectionHub/ConnectionHub.cs +++ b/src/BootstrapBlazor/Components/ConnectionHub/ConnectionHub.cs @@ -51,7 +51,8 @@ protected override async Task InvokeInitAsync() Method = nameof(Callback), ConnectionId = Guid.NewGuid(), Interval = options.BeatInterval.TotalMilliseconds, - Url = "ip.axd" + Url = "ip.axd", + BootstrapBlazorOptions.Value.WebClientOptions.EnableIpLocator }); } } diff --git a/src/BootstrapBlazor/Services/WebClientService.cs b/src/BootstrapBlazor/Services/WebClientService.cs index d545a21967b..5512100f1e9 100644 --- a/src/BootstrapBlazor/Services/WebClientService.cs +++ b/src/BootstrapBlazor/Services/WebClientService.cs @@ -44,7 +44,10 @@ public async Task GetClientInfo() { _jsModule ??= await runtime.LoadModuleByName("client"); _interop ??= DotNetObjectReference.Create(this); - await _jsModule.InvokeVoidAsync("ping", "ip.axd", _interop, nameof(SetData)); + await _jsModule.InvokeVoidAsync("ping", "ip.axd", _interop, nameof(SetData), new + { + options.CurrentValue.WebClientOptions.EnableIpLocator + }); // 等待 SetData 方法执行完毕 await _taskCompletionSource.Task.WaitAsync(TimeSpan.FromSeconds(3)); From 1104e7a652621d0733164ad6bb78c98fa61d6dd1 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Wed, 19 Feb 2025 18:38:58 +0800 Subject: [PATCH 4/9] chore: bump version 9.3.1-beta23 --- src/BootstrapBlazor/BootstrapBlazor.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BootstrapBlazor/BootstrapBlazor.csproj b/src/BootstrapBlazor/BootstrapBlazor.csproj index 211ed6d61ac..86ee6197a7c 100644 --- a/src/BootstrapBlazor/BootstrapBlazor.csproj +++ b/src/BootstrapBlazor/BootstrapBlazor.csproj @@ -1,7 +1,7 @@ - 9.3.1-beta22 + 9.3.1-beta23 From c813c647603d31e17c9b9889194133dbb3200169 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Thu, 20 Feb 2025 10:34:41 +0800 Subject: [PATCH 5/9] =?UTF-8?q?refactor:=20=E4=BB=A3=E7=A0=81=E9=87=8D?= =?UTF-8?q?=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Samples/Locators.razor.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/BootstrapBlazor.Server/Components/Samples/Locators.razor.cs b/src/BootstrapBlazor.Server/Components/Samples/Locators.razor.cs index 33e2bf80f14..e23fcf5c642 100644 --- a/src/BootstrapBlazor.Server/Components/Samples/Locators.razor.cs +++ b/src/BootstrapBlazor.Server/Components/Samples/Locators.razor.cs @@ -42,11 +42,11 @@ protected override void OnInitialized() { base.OnInitialized(); - _providers = IpLocatorProviders.Select(provider => new SelectedItem + _providers = [.. IpLocatorProviders.Select(provider => new SelectedItem { Text = provider.GetType().Name, Value = provider.GetType().Name - }).ToList(); + })]; } /// From 06d07f0cb93738c2459eca0a73a7b5ab93d60334 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Thu, 20 Feb 2025 10:35:01 +0800 Subject: [PATCH 6/9] =?UTF-8?q?refactor:=20=E7=A7=BB=E9=99=A4=E4=B8=8D?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E7=9A=84=E5=91=BD=E5=90=8D=E7=A9=BA=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor.Server/Program.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/BootstrapBlazor.Server/Program.cs b/src/BootstrapBlazor.Server/Program.cs index f8cb21106db..5e9a3610256 100644 --- a/src/BootstrapBlazor.Server/Program.cs +++ b/src/BootstrapBlazor.Server/Program.cs @@ -4,7 +4,6 @@ // Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone using BootstrapBlazor.Server.Components; -using BootstrapBlazor.Server.Components.Layout; using Microsoft.AspNetCore.HttpOverrides; using Microsoft.Extensions.Options; using System.Text; From 021e135a5e10b46245f58ff01866d3bf90e4624e Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Thu, 20 Feb 2025 10:35:20 +0800 Subject: [PATCH 7/9] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E7=A6=BB?= =?UTF-8?q?=E7=BA=BF=20IP=20=E5=9C=B0=E7=90=86=E4=BD=8D=E7=BD=AE=E5=AE=9A?= =?UTF-8?q?=E4=BD=8D=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Extensions/ServiceCollectionSharedExtensions.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/BootstrapBlazor.Server/Extensions/ServiceCollectionSharedExtensions.cs b/src/BootstrapBlazor.Server/Extensions/ServiceCollectionSharedExtensions.cs index c577d8f696b..479c7981f93 100644 --- a/src/BootstrapBlazor.Server/Extensions/ServiceCollectionSharedExtensions.cs +++ b/src/BootstrapBlazor.Server/Extensions/ServiceCollectionSharedExtensions.cs @@ -79,6 +79,9 @@ public static IServiceCollection AddBootstrapBlazorServices(this IServiceCollect // 增加 Table Excel 导出服务 services.AddBootstrapBlazorTableExportService(); + // 增加离线 IP 定位服务 + services.AddBootstrapBlazorIP2RegionfService(); + // 增加 PetaPoco ORM 数据服务操作类 // 需要时打开下面代码 //services.AddPetaPoco(option => From eb4408e59ec2fe3e390c8b1af5581d573e2463c0 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Thu, 20 Feb 2025 10:35:50 +0800 Subject: [PATCH 8/9] =?UTF-8?q?chore:=20=E5=A2=9E=E5=8A=A0=20IP2Region=20?= =?UTF-8?q?=E5=8C=85=E5=BC=95=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor.Server/BootstrapBlazor.Server.csproj | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/BootstrapBlazor.Server/BootstrapBlazor.Server.csproj b/src/BootstrapBlazor.Server/BootstrapBlazor.Server.csproj index 992c3ce45b3..9e9a9b32164 100644 --- a/src/BootstrapBlazor.Server/BootstrapBlazor.Server.csproj +++ b/src/BootstrapBlazor.Server/BootstrapBlazor.Server.csproj @@ -1,4 +1,4 @@ - + true @@ -31,7 +31,7 @@ - + @@ -41,6 +41,7 @@ + From 8b8118790a649bc7313116566f3bb1b818b6efbb Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Thu, 20 Feb 2025 11:53:10 +0800 Subject: [PATCH 9/9] =?UTF-8?q?doc:=20=E6=9B=B4=E6=96=B0=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor.Server/Locales/en-US.json | 2 +- src/BootstrapBlazor.Server/Locales/zh-CN.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/BootstrapBlazor.Server/Locales/en-US.json b/src/BootstrapBlazor.Server/Locales/en-US.json index f1137fb0d1f..fae7a9e2562 100644 --- a/src/BootstrapBlazor.Server/Locales/en-US.json +++ b/src/BootstrapBlazor.Server/Locales/en-US.json @@ -4142,7 +4142,7 @@ "LocatorsNormalInputText": "IpAddress", "LocatorsNormalDisplayText": "Geographical location", "LocatorsNormalButtonText": "Locating", - "LocatorsProviderDesc": "The component library has two built-in geolocation locators: BaiduIpLocatorProvider BaiduIpLocatorProviderV2" + "LocatorsProviderDesc": "

The component library has two built-in free online geolocation locators, BaiduIpLocatorProvider BaiduIpLocatorProviderV2

The component library has a built-in paid online geolocation locator JuHeIpLocatorProvider Official website address

The component library has a built-in free offline geolocation locator BootstrapBlazor.IP2Region Nuget package

" }, "BootstrapBlazor.Server.Components.Samples.Print": { "PrintsTitle": "Print", diff --git a/src/BootstrapBlazor.Server/Locales/zh-CN.json b/src/BootstrapBlazor.Server/Locales/zh-CN.json index 30780cc1212..dbbb087a331 100644 --- a/src/BootstrapBlazor.Server/Locales/zh-CN.json +++ b/src/BootstrapBlazor.Server/Locales/zh-CN.json @@ -4142,7 +4142,7 @@ "LocatorsNormalInputText": "Ip 地址", "LocatorsNormalDisplayText": "地理位置", "LocatorsNormalButtonText": "定位", - "LocatorsProviderDesc": "组件库内置两个地理位置定位器分别为 BaiduIpLocatorProvider BaiduIpLocatorProviderV2" + "LocatorsProviderDesc": "

组件库内置两个免费在线地理位置定位器分别为 BaiduIpLocatorProvider BaiduIpLocatorProviderV2

组件库内置一个收费在线地理位置定位器 JuHeIpLocatorProvider 官网地址

组件库内置一个免费离线地理位置定位器 BootstrapBlazor.IP2Region Nuget 包

" }, "BootstrapBlazor.Server.Components.Samples.Print": { "PrintsTitle": "Print 打印按钮",