支持子菜单active状态

This commit is contained in:
Argo-Lenovo 2016-11-12 18:23:03 +08:00
parent 8659c94cd4
commit 578f26aaba
1 changed files with 11 additions and 1 deletions

View File

@ -10,9 +10,19 @@ namespace Bootstrap.Admin.Models
public NavigatorBarModel(string url)
{
Navigations = MenuHelper.RetrieveNavigationsByUserName(UserName);
Navigations.ToList().ForEach(m => m.Active = m.Url.Equals(url, StringComparison.OrdinalIgnoreCase) ? "active" : "");
ActiveMenu(null, Navigations.ToList(), url);
HomeUrl = "~/Admin/Index";
}
private void ActiveMenu(Menu parent, List<Menu> menus, string url)
{
menus.ForEach(m =>
{
m.Active = m.Url.Equals(url, StringComparison.OrdinalIgnoreCase) ? "active" : "";
ActiveMenu(m, m.Menus.ToList(), url);
if (parent != null && m.Active != "") parent.Active = m.Active;
});
}
/// <summary>
///
/// </summary>