using wispro.sp.web.Models; using wispro.sp.web.Services; using AntDesign.ProLayout; using Microsoft.AspNetCore.Components; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using AntDesign; using Microsoft.AspNetCore.Components.Authorization; using wispro.sp.web.Auth; namespace wispro.sp.web.Components { public partial class RightContent { private CurrentUser _currentUser = new CurrentUser(); private NoticeIconData[] _notifications = { }; private NoticeIconData[] _messages = { }; private NoticeIconData[] _events = { }; private int _count = 0; private List> DefaultOptions { get; set; } = new List> { new AutoCompleteDataItem { Label = "umi ui", Value = "umi ui" }, new AutoCompleteDataItem { Label = "Pro Table", Value = "Pro Table" }, new AutoCompleteDataItem { Label = "Pro Layout", Value = "Pro Layout" } }; public AvatarMenuItem[] AvatarMenuItems { get; set; } = new AvatarMenuItem[] { //new() { Key = "center", IconType = "user", Option = "个人中心"}, new() { Key = "setting", IconType = "lock", Option = "修改密码"}, new() { IsDivider = true }, new() { Key = "logout", IconType = "logout", Option = "退出登录"} }; [Inject] protected NavigationManager NavigationManager { get; set; } [Inject] protected IUserService UserService { get; set; } [Inject] protected IProjectService ProjectService { get; set; } [Inject] protected MessageService MessageService { get; set; } [Inject] protected IAuthService authorProvider { get; set; } protected override async System.Threading.Tasks.Task OnInitializedAsync() { await base.OnInitializedAsync(); SetClassMap(); _currentUser = await UserService.GetUser(); //var notices = await ProjectService.GetNoticesAsync(); //_notifications = notices.Where(x => x.Type == "notification").Cast().ToArray(); //_messages = notices.Where(x => x.Type == "message").Cast().ToArray(); //_events = notices.Where(x => x.Type == "event").Cast().ToArray(); //_count = notices.Length; } protected void SetClassMap() { ClassMapper .Clear() .Add("right"); } public void HandleSelectUser(MenuItem item) { switch (item.Key) { case "center": NavigationManager.NavigateTo("/account/center"); break; case "setting": NavigationManager.NavigateTo("/ChangePassword/false"); break; case "logout": authorProvider.LogoutAsync(); NavigationManager.NavigateTo("/LoginPages"); break; } } public void HandleSelectLang(MenuItem item) { } public async System.Threading.Tasks.Task HandleClear(string key) { switch (key) { case "notification": _notifications = new NoticeIconData[] { }; break; case "message": _messages = new NoticeIconData[] { }; break; case "event": _events = new NoticeIconData[] { }; break; } await MessageService.Success($"清空了{key}"); } public async System.Threading.Tasks.Task HandleViewMore(string key) { await MessageService.Info("Click on view more"); } } }