2020-06-23 15:19:44 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
|
|
|
|
|
|
namespace AntDesign
|
|
|
|
|
{
|
|
|
|
|
public partial class DrawerContainer
|
|
|
|
|
{
|
|
|
|
|
[Inject]
|
|
|
|
|
private DrawerService DrawerService { get; set; }
|
|
|
|
|
|
|
|
|
|
protected override void OnInitialized()
|
|
|
|
|
{
|
2020-06-30 13:40:51 +08:00
|
|
|
|
DrawerService.OnCloseEvent += DrawerService_OnClose;
|
|
|
|
|
DrawerService.OnOpenEvent += DrawerService_OnCreate;
|
2020-06-23 15:19:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void Dispose(bool disposing)
|
|
|
|
|
{
|
2020-06-30 13:40:51 +08:00
|
|
|
|
DrawerService.OnCloseEvent -= DrawerService_OnClose;
|
|
|
|
|
DrawerService.OnOpenEvent -= DrawerService_OnCreate;
|
2020-06-23 15:19:44 +08:00
|
|
|
|
base.Dispose(disposing);
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-30 13:40:51 +08:00
|
|
|
|
private List<DrawerRef> _drawerRefs = new List<DrawerRef>();
|
2020-06-23 15:19:44 +08:00
|
|
|
|
|
|
|
|
|
|
2020-06-30 13:40:51 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 创建并打开抽屉
|
|
|
|
|
/// </summary>
|
|
|
|
|
private async Task DrawerService_OnCreate(DrawerRef drawerRef)
|
2020-06-23 15:19:44 +08:00
|
|
|
|
{
|
2020-06-30 13:40:51 +08:00
|
|
|
|
drawerRef.Config.Visible = true;
|
|
|
|
|
if (!_drawerRefs.Contains(drawerRef))
|
|
|
|
|
{
|
|
|
|
|
_drawerRefs.Add(drawerRef);
|
|
|
|
|
}
|
2020-06-23 15:19:44 +08:00
|
|
|
|
await InvokeAsync(StateHasChanged);
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-30 13:40:51 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 关闭抽屉
|
|
|
|
|
/// </summary>
|
|
|
|
|
private async Task DrawerService_OnClose(DrawerRef drawerRef)
|
2020-06-23 15:19:44 +08:00
|
|
|
|
{
|
2020-06-30 13:40:51 +08:00
|
|
|
|
drawerRef.Config.Visible = false;
|
|
|
|
|
await InvokeAsync(StateHasChanged);
|
|
|
|
|
await Task.Delay(300);
|
|
|
|
|
if (_drawerRefs.Contains(drawerRef))
|
2020-06-23 15:19:44 +08:00
|
|
|
|
{
|
2020-06-30 13:40:51 +08:00
|
|
|
|
_drawerRefs.Remove(drawerRef);
|
2020-06-23 15:19:44 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|