Skip to content

Commit 827bbcd

Browse files
authored
feat(module: menu): add IconFont support (#89)
1 parent 4505c99 commit 827bbcd

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

src/layout/example/AntDesign.ProLayout.Wasm/Shared/ProLayout.razor

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
<SettingDrawer />
4242

4343
@inject HttpClient HttpClient
44+
@inject IconService iconService;
45+
4446
@code
4547
{
4648
private MenuDataItem[] MenuData { get; set; } = {};
@@ -52,6 +54,7 @@
5254
{
5355
await base.OnInitializedAsync();
5456
var data = await HttpClient.GetFromJsonAsync<List<MenuDataItem>>("data/menu.json");
57+
data[0].IconFont = "icon-tuichu";
5558
data.Insert(0, new MenuDataItem
5659
{
5760
TitleTemplate =@<span><Icon Type="user"></Icon> Custom Menu </span>,
@@ -63,4 +66,12 @@
6366
{
6467
openKeys = [];
6568
}
69+
70+
protected override async Task OnAfterRenderAsync(bool firstRender)
71+
{
72+
if (firstRender)
73+
{
74+
await iconService.CreateFromIconfontCN("//at.alicdn.com/t/font_8d5l8fzk5b87iudi.js");
75+
}
76+
}
6677
}

src/layout/src/AntDesign.ProLayout.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
<Exec WorkingDirectory="$(SolutionDir)" Command="npm install" />
5252
<Exec WorkingDirectory="$(SolutionDir)" Command="npm run gulp:layout" />
5353
</Target>
54-
54+
5555
<ItemGroup>
5656
<Content Update="**\*.razor">
5757
<Pack>false</Pack>

src/layout/src/SiderMenu/BaseMenu.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
return @<span>
2424
@if (!string.IsNullOrEmpty(menuItem.Icon))
2525
{
26-
<Icon Type="@menuItem.Icon" Theme="outline" />
26+
<Icon IconFont="@menuItem.IconFont" Type="@menuItem.Icon" Theme="outline" />
2727
}
2828
<span>@menuItem.Name</span>
2929
</span>

src/layout/src/SiderMenu/MenuDataItem.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public class MenuDataItem
1010
public bool HideChildrenInMenu { get; set; }
1111
public bool HideInMenu { get; set; }
1212
public string Icon { get; set; }
13+
public string IconFont { get; set; }
1314
public string Locale { get; set; }
1415
public virtual string Name { get; set; }
1516
public string Key { get; set; }

0 commit comments

Comments
 (0)