public override Task ProcessAsync(TagHelperContext context, TagHelperOutput output) { var button = new Core.Rbac.Model.FapMenuButton() { ButtonID = Id, ButtonName = Content, Description = Content, Enabled = 1, ButtonType = BtnTag == ButtonTag.link?FapMenuButtonType.Link:FapMenuButtonType.Button }; //注册按钮,同时获取多语名称 string permission = _rbacService.GetMenuButtonAuthority(_applicationContext.CurrentRoleUid, button); if (permission.IsPresent() && permission.Equals("1")) { StringBuilder builder = new StringBuilder(); if (BtnTag == ButtonTag.link) { button.ButtonType = FapMenuButtonType.Link; output.TagName = "a"; output.Attributes.Add("class", ClassName); output.Attributes.Add("id", Id); output.Attributes.Add("href", LinkHref.IsMissing() ? "javascript:void(0)" : LinkHref); output.Attributes.Add("title", button.Description); builder.Append($" <i class=\"ace-icon {IconBefore}\"></i>"); builder.Append(button.Description); } else { button.ButtonType = FapMenuButtonType.Button; output.TagName = "button"; output.Attributes.Add("class", ClassName); //builder.Append($" <button {Attribute} class=\"btn {ClassName}\">"); builder.Append($"<i class=\"ace-icon {IconBefore}\"></i>"); builder.Append(button.Description); builder.Append($" <span class=\"ace-icon {IconAfter} icon-on-right\"></span>"); //builder.Append("</button>"); } output.Content.SetHtmlContent(builder.ToString()); } return(base.ProcessAsync(context, output)); }
/// <summary> /// Returns true if the NavItem represents the current page /// </summary> /// <param name="PageIdentifier">can pass a string (LinkPagePath/LinkHref match), an Int (LinkPageID match), or a Guid (LinkPageGuid)</param> public bool IsCurrentPage(object PageIdentifier) { if (PageIdentifier == null) { return(false); } switch (PageIdentifier.GetType().FullName) { case "System.String": default: if (LinkPagePath.Equals(Convert.ToString(PageIdentifier), StringComparison.InvariantCultureIgnoreCase) || (!string.IsNullOrWhiteSpace(LinkHref) && LinkHref.Equals(Convert.ToString(PageIdentifier), StringComparison.InvariantCultureIgnoreCase))) { return(true); } break; case "System.Int32": case "System.Int16": case "System.Int": if (LinkPageID == Convert.ToInt32(PageIdentifier)) { return(true); } break; case "System.Guid": if (LinkPageGuid == (Guid)PageIdentifier) { return(true); } break; } return(false); }