重构HeaderBarModel移除不用的ShowMenu,判断是否需要初始化前台菜单
This commit is contained in:
parent
0a7d3cd489
commit
f51237f9ea
|
@ -19,8 +19,11 @@ namespace Bootstrap.Admin.Controllers
|
|||
{
|
||||
var v = new HeaderBarModel();
|
||||
v.HomeUrl = DictHelper.RetrieveHomeUrl();
|
||||
v.ShowMenu = true;
|
||||
if (v.HomeUrl.StartsWith("~/")) return View(v);
|
||||
if (v.HomeUrl.StartsWith("~/"))
|
||||
{
|
||||
v.Menus = MenuHelper.RetrieveLinksByUserName(User.Identity.Name);
|
||||
return View(v);
|
||||
}
|
||||
else return Redirect(v.HomeUrl);
|
||||
}
|
||||
/// <summary>
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace Bootstrap.Admin.Models
|
|||
DisplayName = user.DisplayName;
|
||||
UserName = user.UserName;
|
||||
UserID = user.ID;
|
||||
Menus = MenuHelper.RetrieveLinksByUserName(UserName);
|
||||
Menus = new List<Menu>();
|
||||
}
|
||||
public string UserName { get; protected set; }
|
||||
/// <summary>
|
||||
|
@ -30,15 +30,11 @@ namespace Bootstrap.Admin.Models
|
|||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public bool ShowMenu { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string HomeUrl { get; set; }
|
||||
/// <summary>
|
||||
/// 获得/设置 前台菜单
|
||||
/// </summary>
|
||||
public IEnumerable<Menu> Menus { get; private set; }
|
||||
public IEnumerable<Menu> Menus { get; set; }
|
||||
/// <summary>
|
||||
/// 获得/设置 用户头像地址
|
||||
/// </summary>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<span id="websiteTitle">@Model.Title</span>
|
||||
</a>
|
||||
<!--logo end-->
|
||||
@if (Model.Menus.Count() > 0 && Model.ShowMenu)
|
||||
@if (Model.Menus.Count() > 0)
|
||||
{
|
||||
<ul id="menu" class="dropdown-menu menu">
|
||||
<div class="arrow-up"></div>
|
||||
|
@ -21,7 +21,7 @@
|
|||
</li>
|
||||
</ul>
|
||||
}
|
||||
@if (!Model.ShowMenu && (LgbPrincipal.IsAdmin(User.Identity.Name) || User.IsInRole("Administrators")))
|
||||
@if (LgbPrincipal.IsAdmin(User.Identity.Name) || User.IsInRole("Administrators"))
|
||||
{
|
||||
<!-- notification start -->
|
||||
<ul class="notify-row">
|
||||
|
|
|
@ -83,9 +83,9 @@ namespace Bootstrap.DataAccess
|
|||
return root;
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// 通过当前用户名获得前台菜单
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="userName">当前登陆的用户名</param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<Menu> RetrieveLinksByUserName(string userName)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue