Skip to content

Commit 05adf6f

Browse files
authored
doc(Services): update services ready for auto mode (#4780)
* doc: 增加 ImportMap 组件 * refactor: 移除重复服务 * refactor: 移除 TagHelper 包 * refactor: 移动模拟登录服务 * refactor: 移动多语言服务
1 parent ca29c43 commit 05adf6f

File tree

4 files changed

+23
-22
lines changed

4 files changed

+23
-22
lines changed

src/BootstrapBlazor.Server/Components/App.razor

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
<link rel="stylesheet" href="@Assets["_content/BootstrapBlazor.Shared/BootstrapBlazor.Shared.bundle.scp.css"]" />
2828
<link rel="stylesheet" href="@Assets["_content/BootstrapBlazor.Shared/css/site.css"]" />
2929

30+
<ImportMap></ImportMap>
31+
3032
<HeadOutlet @rendermode="new InteractiveServerRenderMode(false)" />
3133
</head>
3234

src/BootstrapBlazor.Server/Extensions/ServiceCollectionExtensions.cs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
using BootstrapBlazor.Service.Services;
77
using Microsoft.AspNetCore.SignalR;
8+
using Microsoft.Extensions.Options;
89
using System.Text.Encodings.Web;
910
using System.Text.Unicode;
1011

@@ -17,9 +18,27 @@ public static IServiceCollection AddBootstrapBlazorServerService(this IServiceCo
1718
// 增加中文编码支持网页源码显示汉字
1819
services.AddSingleton(HtmlEncoder.Create(UnicodeRanges.All));
1920

21+
// 增加错误日志
2022
services.AddLogging(logBuilder => logBuilder.AddFileLogger());
23+
24+
// 增加跨域服务
2125
services.AddCors();
2226

27+
// 增加多语言支持配置信息
28+
services.AddRequestLocalization<IOptionsMonitor<BootstrapBlazorOptions>>((localizerOption, blazorOption) =>
29+
{
30+
blazorOption.OnChange(Invoke);
31+
Invoke(blazorOption.CurrentValue);
32+
return;
33+
34+
void Invoke(BootstrapBlazorOptions option)
35+
{
36+
var supportedCultures = option.GetSupportedCultures();
37+
localizerOption.SupportedCultures = supportedCultures;
38+
localizerOption.SupportedUICultures = supportedCultures;
39+
}
40+
});
41+
2342
#if DEBUG
2443
#else
2544
services.AddResponseCompression(options =>
@@ -34,8 +53,8 @@ public static IServiceCollection AddBootstrapBlazorServerService(this IServiceCo
3453
// 增加 SignalR 服务数据传输大小限制配置
3554
services.Configure<HubOptions>(option => option.MaximumReceiveMessageSize = null);
3655

37-
// 增加错误日志
38-
services.AddLogging(logging => logging.AddFileLogger());
56+
// 增加授权服务
57+
services.AddAuthorization();
3958

4059
// 增加后台任务服务
4160
services.AddTaskServices();

src/BootstrapBlazor.Shared/BootstrapBlazor.Shared.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
<PackageReference Include="BootstrapBlazor.SvgEditor" Version="9.0.0" />
6060
<PackageReference Include="BootstrapBlazor.SummerNote" Version="9.0.1" />
6161
<PackageReference Include="BootstrapBlazor.TableExport" Version="9.0.0" />
62-
<PackageReference Include="BootstrapBlazor.TagHelper" Version="9.0.0" />
6362
<PackageReference Include="BootstrapBlazor.Topology" Version="9.0.0" />
6463
<PackageReference Include="BootstrapBlazor.VideoPlayer" Version="9.0.1" />
6564
<PackageReference Include="BootstrapBlazor.WinBox" Version="9.0.5" />

src/BootstrapBlazor.Shared/Extensions/ServicesCollectionExtensions.cs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,6 @@ public static IServiceCollection AddBootstrapBlazorServices(this IServiceCollect
3535
// 增加 Baidu ORC 服务
3636
services.AddBootstrapBlazorBaiduOcr();
3737

38-
// 增加多语言支持配置信息
39-
services.AddRequestLocalization<IOptionsMonitor<BootstrapBlazorOptions>>((localizerOption, blazorOption) =>
40-
{
41-
blazorOption.OnChange(Invoke);
42-
Invoke(blazorOption.CurrentValue);
43-
return;
44-
45-
void Invoke(BootstrapBlazorOptions option)
46-
{
47-
var supportedCultures = option.GetSupportedCultures();
48-
localizerOption.SupportedCultures = supportedCultures;
49-
localizerOption.SupportedUICultures = supportedCultures;
50-
}
51-
});
52-
5338
// 增加 AzureOpenAI 服务
5439
services.AddBootstrapBlazorAzureOpenAIService();
5540

@@ -86,9 +71,6 @@ void Invoke(BootstrapBlazorOptions option)
8671
// 增加 Table Excel 导出服务
8772
services.AddBootstrapBlazorTableExportService();
8873

89-
// 增加 脚本版本服务
90-
services.AddBootstrapAppendVersionService();
91-
9274
// 增加 PetaPoco ORM 数据服务操作类
9375
// 需要时打开下面代码
9476
//services.AddPetaPoco(option =>
@@ -147,7 +129,6 @@ public static IServiceCollection AddWebSiteServices(this IServiceCollection serv
147129
services.AddOptionsMonitor<WebsiteOptions>();
148130

149131
// 增加模拟登录服务
150-
services.AddAuthorization();
151132
services.AddCascadingAuthenticationState();
152133
services.AddScoped<AuthenticationStateProvider, MockAuthenticationStateProvider>();
153134

0 commit comments

Comments
 (0)