Skip to content

Commit 48c135c

Browse files
committed
home page and readme
1 parent 1178995 commit 48c135c

File tree

4 files changed

+219
-13
lines changed

4 files changed

+219
-13
lines changed

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
A simple management project template written using Blazor and MudBlazor.
44

5+
[中文版](README_zh.md)
6+
57
---
68

79
#### Credentials:
@@ -22,22 +24,24 @@ Password:BlazorAdmin
2224

2325
- Built on Mudblazor
2426

25-
- Theme light/dark switch
27+
- Theme light/dark and color switch
2628

2729
- Localization
2830

2931
- Audit/Login Log
3032

3133
- Modularization
3234

35+
- Quartz Support
36+
3337
---
3438

3539
#### Technology stack:
3640

37-
- .NET 8
41+
- .NET 9
3842

3943
- Blazor
4044

4145
- MudBlazor
4246

43-
- Entity Framework 8
47+
- Entity Framework Core

README_zh.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
### BlazorAdmin
2+
3+
一个使用 Blazor 和 MudBlazor 编写的简单管理项目模板。
4+
5+
---
6+
7+
#### 登录凭据:
8+
9+
用户名:BlazorAdmin
10+
11+
密码:BlazorAdmin
12+
13+
---
14+
15+
#### 特性:
16+
17+
- 支持交互式自动渲染模式
18+
19+
- 实现了基于角色的访问控制(RBAC)
20+
21+
- JWT 身份认证
22+
23+
- 基于 MudBlazor 构建
24+
25+
- 主题明暗及颜色切换
26+
27+
- 本地化支持
28+
29+
- 审计/登录日志
30+
31+
- 模块化设计
32+
33+
- 添加Quartz支持
34+
35+
---
36+
37+
#### 技术栈:
38+
39+
- .NET 9
40+
41+
- Blazor
42+
43+
- MudBlazor
44+
45+
- Entity Framework Core

src/BlazorAdmin/BlazorAdmin.Modules/BlazorAdmin.Layout/Components/Notification/NotificationIcon.razor

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -251,19 +251,12 @@
251251
public string Content { get; set; }
252252
}
253253

254-
private Timer _refreshTimer;
255254

256255
protected override async Task OnInitializedAsync()
257256
{
258257
await LoadNotifications();
259258
await LoadUnreadCount();
260-
261-
_refreshTimer = new Timer(async _ =>
262-
{
263-
await LoadNotifications();
264-
await LoadUnreadCount();
265-
await InvokeAsync(StateHasChanged);
266-
}, null, TimeSpan.Zero, TimeSpan.FromMinutes(1));
259+
StateHasChanged();
267260
}
268261

269262
private async Task LoadUsers()
@@ -467,7 +460,6 @@
467460

468461
public void Dispose()
469462
{
470-
_refreshTimer?.Dispose();
471463
}
472464

473465
private void ShowAllNotRead()
Lines changed: 166 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,169 @@
11
@page "/"
22
@using BlazorAdmin.Servers.Core.Helper
33
@using BlazorAdmin.Servers.Core.States
4-
<MudMarkdown Value="@Value" />
4+
@using BlazorAdmin.Servers.Core.Data.Entities.Rbac
5+
@using BlazorAdmin.Servers.Core.Data.Entities.Log
6+
@using BlazorAdmin.Servers.Core.Data.Entities.Notification
7+
@using BlazorAdmin.Servers.Core.Data
8+
@using Microsoft.EntityFrameworkCore
9+
@inject BlazorAdminDbContext DbContext
10+
11+
<MudContainer MaxWidth="MaxWidth.Large" Class="mt-4">
12+
<MudGrid>
13+
<MudItem xs="12">
14+
<MudText Typo="Typo.h4" Class="mb-4">系统概览</MudText>
15+
</MudItem>
16+
17+
<MudItem xs="12" sm="6" md="3">
18+
<MudPaper Elevation="2" Class="pa-4" Style="height: 150px;">
19+
<MudStack>
20+
<MudIcon Icon="@Icons.Material.Filled.People" Color="Color.Primary" Size="Size.Large" />
21+
<MudText Typo="Typo.h5">@_userCount</MudText>
22+
<MudText>用户总数</MudText>
23+
</MudStack>
24+
</MudPaper>
25+
</MudItem>
26+
27+
<MudItem xs="12" sm="6" md="3">
28+
<MudPaper Elevation="2" Class="pa-4" Style="height: 150px;">
29+
<MudStack>
30+
<MudIcon Icon="@Icons.Material.Filled.AccountTree" Color="Color.Secondary" Size="Size.Large" />
31+
<MudText Typo="Typo.h5">@_orgCount</MudText>
32+
<MudText>组织数量</MudText>
33+
</MudStack>
34+
</MudPaper>
35+
</MudItem>
36+
37+
<MudItem xs="12" sm="6" md="3">
38+
<MudPaper Elevation="2" Class="pa-4" Style="height: 150px;">
39+
<MudStack>
40+
<MudIcon Icon="@Icons.Material.Filled.Login" Color="Color.Success" Size="Size.Large" />
41+
<MudText Typo="Typo.h5">@_todayLoginCount</MudText>
42+
<MudText>今日登录</MudText>
43+
</MudStack>
44+
</MudPaper>
45+
</MudItem>
46+
47+
<MudItem xs="12" sm="6" md="3">
48+
<MudPaper Elevation="2" Class="pa-4" Style="height: 150px;">
49+
<MudStack>
50+
<MudIcon Icon="@Icons.Material.Filled.History" Color="Color.Warning" Size="Size.Large" />
51+
<MudText Typo="Typo.h5">@_todayAuditCount</MudText>
52+
<MudText>今日操作</MudText>
53+
</MudStack>
54+
</MudPaper>
55+
</MudItem>
56+
57+
<MudItem xs="12" md="12">
58+
<MudGrid>
59+
<MudItem xs="6">
60+
<MudPaper Elevation="2" Class="pa-4">
61+
<MudText Typo="Typo.h6" Class="mb-4">系统通知</MudText>
62+
<MudList Dense="true" T="string">
63+
@foreach (var notification in _notifications)
64+
{
65+
<MudListItem>
66+
<MudText>@notification.Title</MudText>
67+
<MudText Typo="Typo.caption">@notification.SendTime.ToString("yyyy-MM-dd HH:mm:ss")</MudText>
68+
</MudListItem>
69+
}
70+
</MudList>
71+
</MudPaper>
72+
</MudItem>
73+
74+
<MudItem xs="6">
75+
<MudPaper Elevation="2" Class="pa-4">
76+
<MudText Typo="Typo.h6" Class="mb-4">最近登录</MudText>
77+
<MudList Dense="true" T="string">
78+
@foreach (var log in _recentLogins)
79+
{
80+
<MudListItem>
81+
<div class="d-flex">
82+
<MudText>@log.UserName</MudText>
83+
<MudText Typo="Typo.caption" Class="ml-auto">@log.Time.ToString("yyyy-MM-dd HH:mm:ss")</MudText>
84+
</div>
85+
<MudText Typo="Typo.caption">IP: @log.Ip</MudText>
86+
</MudListItem>
87+
}
88+
</MudList>
89+
</MudPaper>
90+
</MudItem>
91+
</MudGrid>
92+
</MudItem>
93+
94+
<MudItem xs="12" md="12">
95+
<MudGrid>
96+
97+
<MudItem xs="12">
98+
<MudPaper Elevation="2" Class="pa-4">
99+
<MudText Typo="Typo.h6" Class="mb-4">最近操作审计</MudText>
100+
<MudTable Items="_recentAudits" Dense="true" Hover="true">
101+
<HeaderContent>
102+
<MudTh>操作类型</MudTh>
103+
<MudTh>实体</MudTh>
104+
<MudTh>时间</MudTh>
105+
</HeaderContent>
106+
<RowTemplate>
107+
<MudTd>
108+
@switch (context.Operation)
109+
{
110+
case 2:
111+
<MudChip Color="Color.Error" Size="Size.Small" T="string">删除</MudChip>
112+
break;
113+
case 3:
114+
<MudChip Color="Color.Warning" Size="Size.Small" T="string">修改</MudChip>
115+
break;
116+
case 4:
117+
<MudChip Color="Color.Success" Size="Size.Small" T="string">添加</MudChip>
118+
break;
119+
}
120+
</MudTd>
121+
<MudTd>@context.EntityName</MudTd>
122+
<MudTd>@context.OperateTime.ToString("yyyy-MM-dd HH:mm:ss")</MudTd>
123+
</RowTemplate>
124+
</MudTable>
125+
</MudPaper>
126+
</MudItem>
127+
</MudGrid>
128+
</MudItem>
129+
130+
</MudGrid>
131+
</MudContainer>
132+
133+
@code {
134+
private int _userCount;
135+
private int _orgCount;
136+
private int _todayLoginCount;
137+
private int _todayAuditCount;
138+
private List<Organization> _organizations = new();
139+
private List<LoginLog> _recentLogins = new();
140+
private List<AuditLog> _recentAudits = new();
141+
private List<Notification> _notifications = new();
142+
143+
protected override async Task OnInitializedAsync()
144+
{
145+
_userCount = await DbContext.Users.CountAsync();
146+
_orgCount = await DbContext.Organizations.CountAsync();
147+
_todayLoginCount = await DbContext.LoginLogs
148+
.Where(x => x.Time.Date == DateTime.Today)
149+
.CountAsync();
150+
_todayAuditCount = await DbContext.AuditLogs
151+
.Where(x => x.OperateTime.Date == DateTime.Today)
152+
.CountAsync();
153+
154+
_recentLogins = await DbContext.LoginLogs
155+
.OrderByDescending(x => x.Time)
156+
.Take(5)
157+
.ToListAsync();
158+
159+
_recentAudits = await DbContext.AuditLogs
160+
.OrderByDescending(x => x.OperateTime)
161+
.Take(10)
162+
.ToListAsync();
163+
164+
_notifications = await DbContext.Notifications
165+
.OrderByDescending(x => x.SendTime)
166+
.Take(5)
167+
.ToListAsync();
168+
}
169+
}

0 commit comments

Comments
 (0)