Skip to content

Commit ffe9689

Browse files
feat(IIconTheme): use FrozenDictionary improve performance (#5008)
* refactor: 增加参数可为空精简代码 * feat: 重构 IIconTheme 接口使用 FrozenDictionary 优化性能 * chore: bump version 9.2.1 Co-Authored-By: Alex chow <[email protected]> * refactor: 增加可为空修饰符 * refactor: 精简代码 * refactor: 使用空集合代替 new 提高性能 * refactor: 增加 TryAddIcons 方法 * test: 更新单元测试 * chore: 更新依赖 * refactor: add readonly keyword --------- Co-authored-by: Alex chow <[email protected]>
1 parent 9a215d2 commit ffe9689

File tree

9 files changed

+292
-225
lines changed

9 files changed

+292
-225
lines changed

src/BootstrapBlazor.Server/BootstrapBlazor.Server.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<PackageReference Include="BootstrapBlazor.BarCode" Version="9.0.0" />
2929
<PackageReference Include="BootstrapBlazor.BarcodeGenerator" Version="9.0.0" />
3030
<PackageReference Include="BootstrapBlazor.BootstrapIcon" Version="9.0.0" />
31-
<PackageReference Include="BootstrapBlazor.BootstrapIcon.Extensions" Version="9.0.0" />
31+
<PackageReference Include="BootstrapBlazor.BootstrapIcon.Extensions" Version="9.1.0" />
3232
<PackageReference Include="BootstrapBlazor.Chart" Version="9.0.0" />
3333
<PackageReference Include="BootstrapBlazor.CherryMarkdown" Version="9.0.0" />
3434
<PackageReference Include="BootstrapBlazor.Dock" Version="9.0.0" />
@@ -45,7 +45,7 @@
4545
<PackageReference Include="BootstrapBlazor.Live2DDisplay" Version="9.0.1" />
4646
<PackageReference Include="BootstrapBlazor.Markdown" Version="9.0.0" />
4747
<PackageReference Include="BootstrapBlazor.MaterialDesign" Version="9.0.0" />
48-
<PackageReference Include="BootstrapBlazor.MaterialDesign.Extensions" Version="9.0.0" />
48+
<PackageReference Include="BootstrapBlazor.MaterialDesign.Extensions" Version="9.1.0" />
4949
<PackageReference Include="BootstrapBlazor.MeiliSearch" Version="9.1.4" />
5050
<PackageReference Include="BootstrapBlazor.Mermaid" Version="9.0.3" />
5151
<PackageReference Include="BootstrapBlazor.MindMap" Version="9.1.0" />

src/BootstrapBlazor.Server/Extensions/ServiceCollectionSharedExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public static IServiceCollection AddBootstrapBlazorServices(this IServiceCollect
8080
services.ConfigureBootstrapIconTheme();
8181

8282
// 增加 FontAwesome 图标主题
83-
services.ConfigureIconThemeOptions(options => options.ThemeKey = "fa");
83+
services.ConfigureIconThemeOptions();
8484

8585
// 增加 BootstrapBlazor 假日服务
8686
services.AddBootstrapHolidayService();

src/BootstrapBlazor/BootstrapBlazor.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Razor">
22

33
<PropertyGroup>
4-
<Version>9.2.1-beta03</Version>
4+
<Version>9.2.1</Version>
55
</PropertyGroup>
66

77
<ItemGroup>

src/BootstrapBlazor/Extensions/BootstrapBlazorServiceCollectionExtensions.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,12 @@ static IServiceCollection AddIconTheme(this IServiceCollection services)
217217
/// <param name="services"></param>
218218
/// <param name="configureOptions"></param>
219219
/// <returns></returns>
220-
public static IServiceCollection ConfigureIconThemeOptions(this IServiceCollection services, Action<IconThemeOptions> configureOptions)
220+
public static IServiceCollection ConfigureIconThemeOptions(this IServiceCollection services, Action<IconThemeOptions>? configureOptions = null)
221221
{
222-
services.Configure(configureOptions);
222+
if (configureOptions != null)
223+
{
224+
services.Configure(configureOptions);
225+
}
223226
return services;
224227
}
225228
}
Lines changed: 224 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,224 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the Apache 2.0 License
3+
// See the LICENSE file in the project root for more information.
4+
// Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone
5+
6+
namespace BootstrapBlazor.Components;
7+
8+
internal static class FontAwesomeIcons
9+
{
10+
public static readonly Dictionary<ComponentIcons, string> Icons = new()
11+
{
12+
{ ComponentIcons.AnchorLinkIcon, "fa-solid fa-link" },
13+
{ ComponentIcons.AvatarIcon, "fa-solid fa-user" },
14+
{ ComponentIcons.AutoFillIcon, "fa-solid fa-angle-up" },
15+
{ ComponentIcons.AutoCompleteIcon, "fa-solid fa-angle-up" },
16+
17+
{ ComponentIcons.ButtonLoadingIcon, "fa-solid fa-spin fa-spinner" },
18+
19+
{ ComponentIcons.CaptchaRefreshIcon, "fa-solid fa-arrows-rotate" },
20+
{ ComponentIcons.CaptchaBarIcon, "fa-solid fa-arrow-right" },
21+
{ ComponentIcons.CameraPlayIcon, "fa-solid fa-circle-play" },
22+
{ ComponentIcons.CameraStopIcon, "fa-solid fa-circle-stop" },
23+
{ ComponentIcons.CameraPhotoIcon, "fa-solid fa-camera-retro" },
24+
{ ComponentIcons.CardCollapseIcon, "fa-solid fa-circle-chevron-right" },
25+
{ ComponentIcons.CarouselPreviousIcon, "fa-solid fa-angle-left" },
26+
{ ComponentIcons.CarouselNextIcon, "fa-solid fa-angle-right" },
27+
{ ComponentIcons.CascaderIcon, "fa-solid fa-angle-up" },
28+
{ ComponentIcons.CascaderSubMenuIcon, "fa-solid fa-angle-down" },
29+
{ ComponentIcons.ConsoleClearButtonIcon, "fa-solid fa-xmark" },
30+
31+
{ ComponentIcons.DatePickBodyPreviousYearIcon, "fa-solid fa-angles-left" },
32+
{ ComponentIcons.DatePickBodyPreviousMonthIcon, "fa-solid fa-angle-left" },
33+
{ ComponentIcons.DatePickBodyNextMonthIcon, "fa-solid fa-angle-right" },
34+
{ ComponentIcons.DatePickBodyNextYearIcon, "fa-solid fa-angles-right" },
35+
36+
{ ComponentIcons.DateTimePickerIcon, "fa-regular fa-calendar-days" },
37+
38+
{ ComponentIcons.TimePickerCellUpIcon, "fa-solid fa-angle-up" },
39+
{ ComponentIcons.TimePickerCellDownIcon, "fa-solid fa-angle-down" },
40+
41+
{ ComponentIcons.DateTimeRangeIcon, "fa-regular fa-calendar-days" },
42+
{ ComponentIcons.DateTimeRangeClearIcon, "fa-solid fa-circle-xmark" },
43+
44+
{ ComponentIcons.DialogCloseButtonIcon, "fa-solid fa-xmark" },
45+
{ ComponentIcons.DialogSaveButtonIcon, "fa-solid fa-floppy-disk" },
46+
{ ComponentIcons.DialogMaximizeWindowIcon, "fa-regular fa-window-maximize" },
47+
{ ComponentIcons.DialogRestoreWindowIcon, "fa-regular fa-window-restore" },
48+
49+
{ ComponentIcons.TopMenuDropdownIcon, "fa-solid fa-angle-down" },
50+
{ ComponentIcons.SideMenuDropdownIcon, "fa-solid fa-angle-down" },
51+
{ ComponentIcons.MenuLinkArrowIcon, "fa-solid fa-angle-left" },
52+
53+
{ ComponentIcons.ResultDialogYesIcon, "fa-solid fa-check" },
54+
{ ComponentIcons.ResultDialogNoIcon, "fa-solid fa-xmark" },
55+
{ ComponentIcons.ResultDialogCloseIcon, "fa-solid fa-xmark" },
56+
57+
{ ComponentIcons.SearchDialogClearIcon, "fa-regular fa-trash-can" },
58+
{ ComponentIcons.SearchDialogSearchIcon, "fa-solid fa-magnifying-glass" },
59+
60+
{ ComponentIcons.StepIcon, "fa-solid fa-check" },
61+
{ ComponentIcons.StepErrorIcon, "fa-solid fa-xmark" },
62+
63+
{ ComponentIcons.FilterButtonFilterIcon, "fa-solid fa-filter" },
64+
{ ComponentIcons.FilterButtonClearIcon, "fa-solid fa-ban" },
65+
66+
{ ComponentIcons.TableFilterPlusIcon, "fa-solid fa-plus" },
67+
{ ComponentIcons.TableFilterMinusIcon, "fa-solid fa-minus" },
68+
69+
{ ComponentIcons.FullScreenButtonIcon, "fa-solid fa-maximize" },
70+
{ ComponentIcons.FullScreenExitButtonIcon, "fa-solid fa-minimize" },
71+
72+
{ ComponentIcons.GoTopIcon, "fa-solid fa-angle-up" },
73+
74+
{ ComponentIcons.ImagePreviewPreviousIcon, "fa-solid fa-angle-left" },
75+
{ ComponentIcons.ImagePreviewNextIcon, "fa-solid fa-angle-right" },
76+
{ ComponentIcons.ImagePreviewMinusIcon, "fa-solid fa-magnifying-glass-minus" },
77+
{ ComponentIcons.ImagePreviewPlusIcon, "fa-solid fa-magnifying-glass-plus" },
78+
{ ComponentIcons.ImagePreviewRotateLeftIcon, "fa-solid fa-rotate-left" },
79+
{ ComponentIcons.ImagePreviewRotateRightIcon, "fa-solid fa-rotate-right" },
80+
81+
{ ComponentIcons.ImageViewerFileIcon, "fa-regular fa-file-image" },
82+
83+
{ ComponentIcons.InputClearIcon, "fa-regular fa-circle-xmark" },
84+
85+
{ ComponentIcons.InputNumberMinusIcon, "fa-solid fa-circle-minus" },
86+
{ ComponentIcons.InputNumberPlusIcon, "fa-solid fa-circle-plus" },
87+
88+
{ ComponentIcons.LayoutMenuBarIcon, "fa-solid fa-bars" },
89+
{ ComponentIcons.LogoutLinkIcon, "fa-solid fa-key" },
90+
91+
{ ComponentIcons.LoadingIcon, "fa-solid fa-fw fa-spin fa-spinner" },
92+
93+
{ ComponentIcons.PaginationPrevPageIcon, "fa-solid fa-angle-left" },
94+
{ ComponentIcons.PaginationNextPageIcon, "fa-solid fa-angle-right" },
95+
{ ComponentIcons.PaginationPrevEllipsisPageIcon, "fa-solid fa-ellipsis" },
96+
{ ComponentIcons.PaginationNextEllipsisPageIcon, "fa-solid fa-ellipsis" },
97+
98+
{ ComponentIcons.PopConfirmButtonConfirmIcon, "fa-solid fa-circle-exclamation" },
99+
100+
{ ComponentIcons.RateStarIcon, "fa-solid fa-star" },
101+
{ ComponentIcons.RateUnStarIcon, "fa-regular fa-star" },
102+
103+
{ ComponentIcons.RibbonTabArrowUpIcon, "fa-solid fa-angle-up" },
104+
{ ComponentIcons.RibbonTabArrowDownIcon, "fa-solid fa-angle-down" },
105+
{ ComponentIcons.RibbonTabArrowPinIcon, "fa-solid fa-thumbtack fa-rotate-90" },
106+
107+
{ ComponentIcons.MultiSelectDropdownIcon, "fa-solid fa-angle-up" },
108+
{ ComponentIcons.MultiSelectClearIcon, "fa-solid fa-xmark" },
109+
110+
{ ComponentIcons.SelectTreeDropdownIcon, "fa-solid fa-angle-up" },
111+
112+
{ ComponentIcons.SearchClearButtonIcon, "fa-solid fa-delete-left" },
113+
{ ComponentIcons.SearchButtonIcon, "fa-solid fa-magnifying-glass" },
114+
{ ComponentIcons.SearchButtonLoadingIcon, "fa-solid fa-spin fa-spinner" },
115+
116+
{ ComponentIcons.SelectDropdownIcon, "fa-solid fa-angle-up" },
117+
{ ComponentIcons.SelectClearIcon, "fa-regular fa-circle-xmark" },
118+
{ ComponentIcons.SelectSearchIcon, "fa-solid fa-magnifying-glass" },
119+
120+
{ ComponentIcons.SweetAlertCloseIcon, "fa-solid fa-xmark" },
121+
{ ComponentIcons.SweetAlertConfirmIcon, "fa-solid fa-check" },
122+
123+
{ ComponentIcons.PrintButtonIcon, "fa-solid fa-print" },
124+
125+
{ ComponentIcons.ToastSuccessIcon, "fa-solid fa-check-circle" },
126+
{ ComponentIcons.ToastInformationIcon, "fa-solid fa-exclamation-circle" },
127+
{ ComponentIcons.ToastWarningIcon, "fa-solid fa-exclamation-triangle" },
128+
{ ComponentIcons.ToastErrorIcon, "fa-solid fa-xmark-circle" },
129+
130+
{ ComponentIcons.TabPreviousIcon, "fa-solid fa-chevron-left" },
131+
{ ComponentIcons.TabNextIcon, "fa-solid fa-chevron-right" },
132+
{ ComponentIcons.TabDropdownIcon, "fa-solid fa-chevron-down" },
133+
{ ComponentIcons.TabCloseIcon, "fa-solid fa-xmark" },
134+
135+
{ ComponentIcons.TableColumnToolboxIcon, "fa-solid fa-gear" },
136+
137+
{ ComponentIcons.TableSortIconAsc, "fa-solid fa-sort-up" },
138+
{ ComponentIcons.TableSortDesc, "fa-solid fa-sort-down" },
139+
{ ComponentIcons.TableSortIcon, "fa-solid fa-sort" },
140+
{ ComponentIcons.TableFilterIcon, "fa-solid fa-filter" },
141+
{ ComponentIcons.TableExportButtonIcon, "fa-solid fa-download" },
142+
143+
{ ComponentIcons.TableAddButtonIcon, "fa-solid fa-plus" },
144+
{ ComponentIcons.TableEditButtonIcon, "fa-regular fa-pen-to-square" },
145+
{ ComponentIcons.TableDeleteButtonIcon, "fa-solid fa-xmark" },
146+
{ ComponentIcons.TableRefreshButtonIcon, "fa-solid fa-arrows-rotate" },
147+
{ ComponentIcons.TableCardViewButtonIcon, "fa-solid fa-bars" },
148+
{ ComponentIcons.TableColumnListButtonIcon, "fa-solid fa-table-list" },
149+
{ ComponentIcons.TableExportCsvIcon, "fa-solid fa-fw fa-file-csv" },
150+
{ ComponentIcons.TableExportExcelIcon, "fa-solid fa-fw fa-file-excel" },
151+
{ ComponentIcons.TableExportPdfIcon, "fa-solid fa-fw fa-file-pdf" },
152+
{ ComponentIcons.TableSearchButtonIcon, "fa-solid fa-magnifying-glass" },
153+
{ ComponentIcons.TableResetSearchButtonIcon, "fa-regular fa-trash-can" },
154+
{ ComponentIcons.TableCloseButtonIcon, "fa-solid fa-xmark" },
155+
{ ComponentIcons.TableCancelButtonIcon, "fa-solid fa-xmark" },
156+
{ ComponentIcons.TableSaveButtonIcon, "fa-solid fa-floppy-disk" },
157+
{ ComponentIcons.TableAdvanceButtonIcon, "fa-solid fa-magnifying-glass-plus" },
158+
{ ComponentIcons.TableAdvancedSortButtonIcon, "fa-solid fa-arrow-up-a-z" },
159+
160+
{ ComponentIcons.TableTreeIcon, "fa-solid fa-caret-right" },
161+
{ ComponentIcons.TableTreeExpandIcon, "fa-solid fa-caret-right fa-rotate-90" },
162+
{ ComponentIcons.TableTreeNodeLoadingIcon, "fa-solid fa-spin fa-spinner" },
163+
{ ComponentIcons.TableCopyColumnButtonIcon, "fa-regular fa-clipboard" },
164+
{ ComponentIcons.TableGearIcon, "fa-solid fa-gear" },
165+
166+
{ ComponentIcons.TransferLeftIcon, "fa-solid fa-angle-left" },
167+
{ ComponentIcons.TransferRightIcon, "fa-solid fa-angle-right" },
168+
{ ComponentIcons.TransferPanelSearchIcon, "fa-solid fa-magnifying-glass" },
169+
170+
{ ComponentIcons.TimerIcon, "fa-solid fa-bell" },
171+
172+
{ ComponentIcons.TreeViewExpandNodeIcon, "fa-solid fa-caret-right fa-rotate-90" },
173+
{ ComponentIcons.TreeViewNodeIcon, "fa-solid fa-caret-right" },
174+
{ ComponentIcons.TreeViewSearchIcon, "fa-solid fa-magnifying-glass" },
175+
{ ComponentIcons.TreeViewResetSearchIcon, "fa-solid fa-delete-left" },
176+
{ ComponentIcons.TreeViewLoadingIcon, "fa-solid fa-spinner fa-spin" },
177+
178+
// Upload
179+
{ ComponentIcons.AvatarUploadDeleteIcon, "fa-regular fa-trash-can" },
180+
{ ComponentIcons.AvatarUploadLoadingIcon, "fa-solid fa-spinner fa-spin" },
181+
{ ComponentIcons.AvatarUploadAddIcon, "fa-solid fa-plus" },
182+
{ ComponentIcons.AvatarUploadValidStatusIcon, "fa-solid fa-check" },
183+
{ ComponentIcons.AvatarUploadInvalidStatusIcon, "fa-solid fa-xmark" },
184+
185+
{ ComponentIcons.ButtonUploadBrowserButtonIcon, "fa-regular fa-folder-open" },
186+
{ ComponentIcons.ButtonUploadLoadingIcon, "fa-solid fa-spinner fa-spin" },
187+
{ ComponentIcons.ButtonUploadInvalidStatusIcon, "fa-regular fa-circle-xmark" },
188+
{ ComponentIcons.ButtonUploadValidStatusIcon, "fa-regular fa-circle-check" },
189+
{ ComponentIcons.ButtonUploadDeleteIcon, "fa-regular fa-trash-can" },
190+
{ ComponentIcons.ButtonUploadDownloadIcon, "fa-solid fa-download" },
191+
192+
{ ComponentIcons.InputUploadBrowserButtonIcon, "fa-regular fa-folder-open" },
193+
{ ComponentIcons.InputUploadDeleteButtonIcon, "fa-regular fa-trash-can" },
194+
195+
{ ComponentIcons.CardUploadAddIcon, "fa-solid fa-plus" },
196+
{ ComponentIcons.CardUploadStatusIcon, "fa-solid fa-check" },
197+
{ ComponentIcons.CardUploadDeleteIcon, "fa-solid fa-xmark" },
198+
{ ComponentIcons.CardUploadRemoveIcon, "fa-regular fa-trash-can" },
199+
{ ComponentIcons.CardUploadDownloadIcon, "fa-solid fa-download" },
200+
{ ComponentIcons.CardUploadZoomIcon, "fa-solid fa-magnifying-glass-plus" },
201+
{ ComponentIcons.UploadCancelIcon, "fa-solid fa-ban" },
202+
203+
{ ComponentIcons.FileIconExcel, "fa-regular fa-file-excel" },
204+
{ ComponentIcons.FileIconDocx, "fa-regular fa-file-word" },
205+
{ ComponentIcons.FileIconPPT, "fa-regular fa-file-powerpoint" },
206+
{ ComponentIcons.FileIconAudio, "fa-regular fa-file-audio" },
207+
{ ComponentIcons.FileIconVideo, "fa-regular fa-file-video" },
208+
{ ComponentIcons.FileIconCode, "fa-regular fa-file-code" },
209+
{ ComponentIcons.FileIconPdf, "fa-regular fa-file-pdf" },
210+
{ ComponentIcons.FileIconZip, "fa-regular fa-file-archive" },
211+
{ ComponentIcons.FileIconArchive, "fa-regular fa-file-text" },
212+
{ ComponentIcons.FileIconImage, "fa-regular fa-file-image" },
213+
{ ComponentIcons.FileIconFile, "fa-regular fa-file" },
214+
215+
{ ComponentIcons.QueryBuilderPlusIcon, "fa-solid fa-plus" },
216+
{ ComponentIcons.QueryBuilderMinusIcon, "fa-solid fa-minus" },
217+
{ ComponentIcons.QueryBuilderRemoveIcon, "fa-solid fa-xmark" },
218+
219+
{ ComponentIcons.ThemeProviderAutoModeIcon, "fa-solid fa-circle-half-stroke" },
220+
{ ComponentIcons.ThemeProviderLightModeIcon, "fa-solid fa-sun" },
221+
{ ComponentIcons.ThemeProviderDarkModeIcon, "fa-solid fa-moon" },
222+
{ ComponentIcons.ThemeProviderActiveModeIcon, "fa-solid fa-check" }
223+
};
224+
}

0 commit comments

Comments
 (0)