zhaolei
5 days ago 4a2e5b9a21940f11757be37d99f0944e240e908b
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
82
83
84
85
86
87
88
89
90
91
92
93
94
using Bootstrap.Admin.Pages.Extensions;
using Bootstrap.Admin.Pages.Shared;
using Bootstrap.Security;
using Microsoft.AspNetCore.Components;
using System.Threading.Tasks;
 
namespace Bootstrap.Admin.Pages.Components
{
    /// <summary>
    ///
    /// </summary>
    public class TabBase : ComponentBase
    {
        /// <summary>
        ///
        /// </summary>
        [Parameter]
        public string Title { get; set; } = "";
 
        /// <summary>
        ///
        /// </summary>
        [Parameter]
        public string? Id { get; set; }
 
        /// <summary>
        ///
        /// </summary>
        [Parameter]
        public string Url { get; set; } = "";
 
        /// <summary>
        ///
        /// </summary>
        [Parameter]
        public string Icon { get; set; } = "";
 
        /// <summary>
        ///
        /// </summary>
        [Parameter]
        public bool Active { get; set; }
 
        /// <summary>
        /// 
        /// </summary>
        [CascadingParameter(Name = "Admin")]
        public AdminLayout Layout { get; protected set; } = new AdminLayout();
 
        /// <summary>
        /// 
        /// </summary>
        [Inject]
        public NavigationManager? NavigationManager { get; set; }
 
        private bool closeTab;
        /// <summary>
        ///
        /// </summary>
        protected async Task CloseTab()
        {
            closeTab = true;
            if (Layout.TabSet != null) await Layout.TabSet.CloseTab(Id);
        }
 
        /// <summary>
        ///
        /// </summary>
        protected void ClickTab()
        {
            if (!closeTab) NavigationManager?.NavigateTo(Url);
            else closeTab = false;
        }
 
        /// <summary>
        ///
        /// </summary>
        /// <param name="menu"></param>
        public void Init(BootstrapMenu menu)
        {
            Title = menu.Name;
            Url = menu.Url.ToBlazorMenuUrl();
            Icon = menu.Icon;
            Id = menu.Id;
            Active = true;
        }
 
        /// <summary>
        ///
        /// </summary>
        /// <param name="val"></param>
        public void SetActive(bool val) => Active = val;
    }
}