Skip to content

Commit 7441314

Browse files
authored
doc(WebClientService): add IpLocator function documentation (#6403)
* doc: 增加内置定位器描述说明 * doc: 更新客户端连接信息服务文档
1 parent 146778f commit 7441314

File tree

4 files changed

+44
-14
lines changed

4 files changed

+44
-14
lines changed

src/BootstrapBlazor.Server/Components/Samples/Client.razor

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66
<h4>@Localizer["SubTitle"]</h4>
77

88
<DemoBlock Title="@Localizer["BasicUsageTitle"]" Introduction="@Localizer["BasicUsageIntro"]" Name="Normal">
9-
<p>@Localizer["BasicUsageP1"]</p>
10-
<div class="mb-3">
9+
<section ignore>
10+
<p>@Localizer["BasicUsageP1"]</p>
1111
<p class="code-label">@((MarkupString)Localizer["BasicUsageP2"].Value)</p>
1212
<Pre>public void Configure(IApplicationBuilder app)
1313
{
1414
// ...
1515
// 增加下面这一行
16+
// add this line
1617
app.UseBootstrapBlazor();
1718
app.UseEndpoints(endpoints =>
1819
{
@@ -21,13 +22,11 @@
2122
endpoints.MapFallbackToPage("/_Host");
2223
});
2324
}</Pre>
24-
</div>
2525

26-
<Tips>
27-
<p>@((MarkupString)Localizer["BasicUsageTips"].Value)</p>
28-
</Tips>
26+
<Tips>
27+
<p>@((MarkupString)Localizer["BasicUsageTips"].Value)</p>
28+
</Tips>
2929

30-
<div class="mb-3">
3130
<p class="code-label">@((MarkupString)Localizer["BasicUsageP3"].Value)</p>
3231
<Pre>[Inject]
3332
[NotNull]
@@ -44,9 +43,29 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
4443
ClientInfo = await ClientService.GetClientInfo();
4544
StateHasChanged();
4645
}
47-
}
48-
</Pre>
49-
</div>
46+
}</Pre>
47+
48+
<p class="code-label">@((MarkupString)Localizer["BasicUsageP4"].Value)</p>
49+
<p>@((MarkupString)Localizer["LocatorsProviderOptions"].Value)</p>
50+
<p>@((MarkupString)Localizer["LocatorsProviderDesc1"].Value)</p>
51+
<Pre>{
52+
"BootstrapBlazorOptions": {
53+
"WebClientOptions": {
54+
"EnableIpLocator": true
55+
}
56+
}</Pre>
57+
<p>@((MarkupString)Localizer["LocatorsProviderDesc2"].Value)</p>
58+
<Pre>services.AddBootstrapBlazor(op =>
59+
{
60+
op.WebClientOptions.EnableIpLocator = true;
61+
});</Pre>
62+
<p>@((MarkupString)Localizer["LocatorsProviderDesc3"].Value)</p>
63+
<Pre>services.Configure&lt;BootstrapBlazorOptions&gt;(op =>
64+
{
65+
op.WebClientOptions.EnableIpLocator = true;
66+
});</Pre>
67+
68+
</section>
5069
<GroupBox Title="@Localizer["GroupBoxTitle"]">
5170
<p class="code-label">@Localizer["IpLocatorFactoryDesc"] <a href="locator" target="_blank">IpLocatorFactory</a></p>
5271

src/BootstrapBlazor.Server/Components/Samples/Locators.razor

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ Location = await provider.Locate(Ip);</Pre>
4040
<p><code>183.160.236.53</code> @Localizer["LocatorsNormalTips4"]</p>
4141

4242
<DemoBlock Title="@Localizer["LocatorsNormalTitle"]" Introduction="@Localizer["LocatorsNormalIntro"]" Name="Normal">
43+
<section ignore>
44+
@((MarkupString)Localizer["LocatorsProviderDesc"].Value)
45+
</section>
4346
<div class="row g-3 form-inline">
4447
<div class="col-12 col-sm-6">
4548
<Select Items="_providers" Value="@ProviderName" OnValueChanged="OnProviderNameChanged" ShowLabel="true" DisplayText="LocatorProvider">

src/BootstrapBlazor.Server/Locales/en-US.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3809,6 +3809,11 @@
38093809
"BasicUsageP2": "1. The <code>UseBootstrapBlazor</code> middleware in the <b>Startup.cs</b> file that client information collection is performed.",
38103810
"BasicUsageTips": "<code>app.UseBootstrapBlazor</code> Middleware is located assembly <code>BootstrapBlazor.Middleware</code>, please refer to this package yourself for proper use",
38113811
"BasicUsageP3": "2. The component uses the injection service <code>WebClientService</code> to call the <code>GetClientInfo</code> method.",
3812+
"BasicUsageP4": "3. Turn on IP geolocation",
3813+
"LocatorsProviderOptions": "<code>BootstrapBlazorOptions</code> section <code>WebClientOptions</code> By default it is <code>false</code>, which means the IP address location function is not enabled. Please change it to <code>true</code> in the configuration file or code.",
3814+
"LocatorsProviderDesc1": "Update the <code>appsetting.json</code> project configuration file",
3815+
"LocatorsProviderDesc2": "Or use the code to open",
3816+
"LocatorsProviderDesc3": "Or enable this function through configuration",
38123817
"GroupBoxTitle": "Connection information",
38133818
"IpLocatorFactoryDesc": "This service has built-in IP geolocation function. For detailed configuration and documentation, please refer to",
38143819
"Id": "Connection ID",
@@ -4103,8 +4108,7 @@
41034108
"LocatorsNormalInputText": "IpAddress",
41044109
"LocatorsNormalDisplayText": "Geographical location",
41054110
"LocatorsNormalButtonText": "Locating",
4106-
"LocatorsProviderDesc": "<p>The component library has two built-in free online geolocation locators, <code>BaiduIpLocatorProvider</code> <code>BaiduIpLocatorProviderV2</code><p><p>The component library has a built-in paid online geolocation locator <code>BootstrapBlazor.JuHeIpLocatorProvider</code> <a href=\"https://www.nuget.org/packages/BootstrapBlazor.JuHeIpLocatorProvider\" target=\"_blank\">Nuget package</a> <a href=\"https://juhe.cn\" target=\"_blank\">Official website address</a></p><p>The component library has a built-in free offline geolocation locator <code>BootstrapBlazor.IP2Region</code> <a href=\"https://www.nuget.org/packages/BootstrapBlazor.IP2Region\" target=\"_blank\">Nuget package</a></p>",
4107-
"LocatorsProviderOptions": "<code>BootstrapBlazorOptions</code> section <code>WebClientOptions</code> By default it is <code>false</code>, which means the IP address location function is not enabled. Please change it to <code>true</code> in the configuration file or code."
4111+
"LocatorsProviderDesc": "<p>The component library has two built-in free online geolocation locators, <code>BaiduIpLocatorProvider</code> <code>BaiduIpLocatorProviderV2</code><p><p>The component library has a built-in paid online geolocation locator <code>BootstrapBlazor.JuHeIpLocatorProvider</code> <a href=\"https://www.nuget.org/packages/BootstrapBlazor.JuHeIpLocatorProvider\" target=\"_blank\">Nuget package</a> <a href=\"https://juhe.cn\" target=\"_blank\">Official website address</a></p><p>The component library has a built-in free offline geolocation locator <code>BootstrapBlazor.IP2Region</code> <a href=\"https://www.nuget.org/packages/BootstrapBlazor.IP2Region\" target=\"_blank\">Nuget package</a></p>"
41084112
},
41094113
"BootstrapBlazor.Server.Components.Samples.Print": {
41104114
"PrintsTitle": "Print",

src/BootstrapBlazor.Server/Locales/zh-CN.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3809,6 +3809,11 @@
38093809
"BasicUsageP2": "1. <b>Startup.cs</b> 文件中使用 <code>UseBootstrapBlazor</code> 中间件进行客户端信息收集",
38103810
"BasicUsageTips": "<code>app.UseBootstrapBlazor</code> 中间件位于程序集 <code>BootstrapBlazor.Middleware</code>,请自行引用此包才能正常使用",
38113811
"BasicUsageP3": "2. 组件中使用注入服务 <code>WebClientService</code> 调用 <code>GetClientInfo</code> 方法",
3812+
"BasicUsageP4": "3. 开启 IP 地理位置定位功能",
3813+
"LocatorsProviderOptions": "全局配置定位器选项 <code>WebClientOptions</code> 默认 <code>false</code> 没有启用 IP 地址定位功能,请在配置文件中或者代码中更改为 <code>true</code>",
3814+
"LocatorsProviderDesc1": "更新 <code>appsetting.json</code> 项目配置文件",
3815+
"LocatorsProviderDesc2": "或者使用代码开启",
3816+
"LocatorsProviderDesc3": "或者通过配置开启本功能",
38123817
"GroupBoxTitle": "您的连接信息",
38133818
"IpLocatorFactoryDesc": "本服务已内置 IP 地理位置定位功能,详细配置与文档请参考",
38143819
"Id": "连接 ID",
@@ -4103,8 +4108,7 @@
41034108
"LocatorsNormalInputText": "Ip 地址",
41044109
"LocatorsNormalDisplayText": "地理位置",
41054110
"LocatorsNormalButtonText": "定位",
4106-
"LocatorsProviderDesc": "<p>组件库内置两个免费在线地理位置定位器分别为 <code>BaiduIpLocatorProvider</code> <code>BaiduIpLocatorProviderV2</code><p><p>组件库内置一个收费在线地理位置定位器 <code>BootstrapBlazor.JuHeIpLocatorProvider</code> <a href=\"https://www.nuget.org/packages/BootstrapBlazor.JuHeIpLocatorProvider\" target=\"_blank\">Nuget 包</a> <a href=\"https://juhe.cn\" target=\"_blank\">官网地址</a></p><p>组件库内置一个免费离线地理位置定位器 <code>BootstrapBlazor.IP2Region</code> <a href=\"https://www.nuget.org/packages/BootstrapBlazor.IP2Region\" target=\"_blank\">Nuget 包</a></p>",
4107-
"LocatorsProviderOptions": "全局配置定位器选项 <code>WebClientOptions</code> 默认 <code>false</code> 没有启用 IP 地址定位功能,请在配置文件中或者代码中更改为 <code>true</code>"
4111+
"LocatorsProviderDesc": "<p>组件库内置两个免费在线地理位置定位器分别为 <code>BaiduIpLocatorProvider</code> <code>BaiduIpLocatorProviderV2</code><p><p>组件库内置一个收费在线地理位置定位器 <code>BootstrapBlazor.JuHeIpLocatorProvider</code> <a href=\"https://www.nuget.org/packages/BootstrapBlazor.JuHeIpLocatorProvider\" target=\"_blank\">Nuget 包</a> <a href=\"https://juhe.cn\" target=\"_blank\">官网地址</a></p><p>组件库内置一个免费离线地理位置定位器 <code>BootstrapBlazor.IP2Region</code> <a href=\"https://www.nuget.org/packages/BootstrapBlazor.IP2Region\" target=\"_blank\">Nuget 包</a></p>"
41084112
},
41094113
"BootstrapBlazor.Server.Components.Samples.Print": {
41104114
"PrintsTitle": "Print 打印按钮",

0 commit comments

Comments
 (0)