forked from ant-design-blazor/blazor-pro-components
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProLayout.razor
More file actions
81 lines (74 loc) · 2.43 KB
/
ProLayout.razor
File metadata and controls
81 lines (74 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@inherits LayoutComponentBase
<BasicLayout
Logo="@("logo.png")"
MenuData="MenuData"
Theme="MenuTheme.Light"
FoldedSiderWidth="80"
MenuAccordion
BaseURL=""
@bind-OpenKeys="openKeys"
@bind-Collapsed="collapsed"
@bind-SelectedKeys=selectedKeys>
<HeaderContentRender>
<Menu Mode="MenuMode.Horizontal" Theme="MenuTheme.Dark">
<MenuItem OnClick="ResetMenu">Refresh Menu</MenuItem>
<MenuItem>Menu 2</MenuItem>
</Menu>
</HeaderContentRender>
<RightContentRender>
<RightContent />
</RightContentRender>
<MenuExtraRender>
<Select
TItem="string"
TItemValue="string"
DefaultValue="@("product")"
Size="@InputSize.Small"
Style="width: 100%;">
<SelectOptions>
<SelectOption TItem="string" TItemValue="string" Value="@("product")" Label="Product" />
<SelectOption TItem="string" TItemValue="string" Value="@("dev")" Label="Development" />
<SelectOption TItem="string" TItemValue="string" Value="@("disabled")" Label="Preview" Disabled />
<SelectOption TItem="string" TItemValue="string" Value="@("test")" Label="Test" />
</SelectOptions>
</Select>
</MenuExtraRender>
<FooterRender>
<AntDesign.ProLayout.Wasm.Components.Footer />
</FooterRender>
<ChildContent>
@Body
</ChildContent>
</BasicLayout>
<SettingDrawer />
@inject HttpClient HttpClient
@inject IconService iconService;
@code
{
private MenuDataItem[] MenuData { get; set; } = {};
private bool collapsed;
private string[] openKeys = [];
private string[] selectedKeys = ["welcome"];
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
var data = await HttpClient.GetFromJsonAsync<List<MenuDataItem>>("data/menu.json");
data[0].IconFont = "icon-tuichu";
data.Insert(0, new MenuDataItem
{
TitleTemplate =@<span><Icon Type="user"></Icon><span> Custom Menu </span</span>,
});
MenuData = data.ToArray();
}
private void ResetMenu()
{
openKeys = [];
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
await iconService.CreateFromIconfontCN("//at.alicdn.com/t/font_8d5l8fzk5b87iudi.js");
}
}
}