From 8d8e3977ac9510275fc65a38a3d0c1bd0fbf7d23 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Fri, 7 Feb 2020 17:41:42 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Pages/Components/TableBase.cs | 2 +- .../Pages/Views/Admin/Notifications.razor | 29 ++++++ .../Views/Components/NotificationsBase.cs | 90 +++++++++++++++++++ 3 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 src/admin/Bootstrap.Admin/Pages/Views/Admin/Notifications.razor create mode 100644 src/admin/Bootstrap.Admin/Pages/Views/Components/NotificationsBase.cs diff --git a/src/admin/Bootstrap.Admin/Pages/Components/TableBase.cs b/src/admin/Bootstrap.Admin/Pages/Components/TableBase.cs index 65f9c379..457e819b 100644 --- a/src/admin/Bootstrap.Admin/Pages/Components/TableBase.cs +++ b/src/admin/Bootstrap.Admin/Pages/Components/TableBase.cs @@ -386,7 +386,7 @@ namespace Bootstrap.Admin.Pages.Components /// /// 查询按钮调用此方法 /// - protected void Query() + public void Query() { if (OnQuery != null) { diff --git a/src/admin/Bootstrap.Admin/Pages/Views/Admin/Notifications.razor b/src/admin/Bootstrap.Admin/Pages/Views/Admin/Notifications.razor new file mode 100644 index 00000000..77876b91 --- /dev/null +++ b/src/admin/Bootstrap.Admin/Pages/Views/Admin/Notifications.razor @@ -0,0 +1,29 @@ +@inherits NotificationsBase + +
+
+ 查询结果 +
+
+ + + + + + + + + + + + + + +
同意 + +
+
+
@context.UserName@context.DisplayName@context.Description@context.RegisterTime
+
+
diff --git a/src/admin/Bootstrap.Admin/Pages/Views/Components/NotificationsBase.cs b/src/admin/Bootstrap.Admin/Pages/Views/Components/NotificationsBase.cs new file mode 100644 index 00000000..7e7e2ab6 --- /dev/null +++ b/src/admin/Bootstrap.Admin/Pages/Views/Components/NotificationsBase.cs @@ -0,0 +1,90 @@ +using Bootstrap.Admin.Pages.Components; +using Bootstrap.DataAccess; +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Authorization; +using System.Linq; + +namespace Bootstrap.Admin.Pages.Views.Admin.Components +{ + /// + /// 消息通知组件 + /// + public class NotificationsBase : ComponentBase + { + /// + /// 获得 授权服务 + /// + [Inject] + protected AuthenticationStateProvider? AuthenticationStateProvider { get; set; } + + /// + /// 获得/设置 编辑类型实例 + /// + protected User DataContext { get; set; } = new User(); + + /// + /// 获得/设置 用户登录名 + /// + protected string? UserName { get; set; } + + /// + /// 获得/设置 Table 实例 + /// + + protected TableBase? Table { get; set; } + + /// + /// OnInitializedAsync 方法 + /// + /// + protected override async System.Threading.Tasks.Task OnInitializedAsync() + { + if (AuthenticationStateProvider != null) + { + var state = await AuthenticationStateProvider.GetAuthenticationStateAsync(); + UserName = state?.User.Identity.Name; + } + } + + /// + /// 数据查询方法 + /// + /// + /// + protected QueryData Query(QueryPageOptions options) + { + var data = UserHelper.RetrieveNewUsers(); + return new QueryData() + { + Items = data, + PageIndex = 1, + PageItems = data.Count(), + TotalCount = data.Count() + }; + } + + /// + /// 批准新用户方法 + /// + protected void Approve(string? userId) + { + if (!string.IsNullOrEmpty(userId) && !string.IsNullOrEmpty(UserName)) + { + UserHelper.Approve(userId, UserName); + Table?.Query(); + } + } + + /// + /// 拒绝新用户方法 + /// + protected void Reject(string? userId) + { + if (!string.IsNullOrEmpty(userId) && !string.IsNullOrEmpty(UserName)) + { + UserHelper.Reject(userId, UserName); + Table?.Query(); + } + } + } +}