diff --git a/Bootstrap.Admin/Controllers/HomeController.cs b/Bootstrap.Admin/Controllers/HomeController.cs index 615e7889..7bf16f96 100644 --- a/Bootstrap.Admin/Controllers/HomeController.cs +++ b/Bootstrap.Admin/Controllers/HomeController.cs @@ -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); } /// diff --git a/Bootstrap.Admin/Models/HeaderBarModel.cs b/Bootstrap.Admin/Models/HeaderBarModel.cs index 140e6ca5..f7097138 100644 --- a/Bootstrap.Admin/Models/HeaderBarModel.cs +++ b/Bootstrap.Admin/Models/HeaderBarModel.cs @@ -16,7 +16,7 @@ namespace Bootstrap.Admin.Models DisplayName = user.DisplayName; UserName = user.UserName; UserID = user.ID; - Menus = MenuHelper.RetrieveLinksByUserName(UserName); + Menus = new List(); } public string UserName { get; protected set; } /// @@ -30,15 +30,11 @@ namespace Bootstrap.Admin.Models /// /// /// - public bool ShowMenu { get; set; } - /// - /// - /// public string HomeUrl { get; set; } /// /// 获得/设置 前台菜单 /// - public IEnumerable Menus { get; private set; } + public IEnumerable Menus { get; set; } /// /// 获得/设置 用户头像地址 /// diff --git a/Bootstrap.Admin/Views/Shared/Header.cshtml b/Bootstrap.Admin/Views/Shared/Header.cshtml index 29f6dbd0..821f88f1 100644 --- a/Bootstrap.Admin/Views/Shared/Header.cshtml +++ b/Bootstrap.Admin/Views/Shared/Header.cshtml @@ -7,7 +7,7 @@ @Model.Title - @if (Model.Menus.Count() > 0 && Model.ShowMenu) + @if (Model.Menus.Count() > 0) { } - @if (!Model.ShowMenu && (LgbPrincipal.IsAdmin(User.Identity.Name) || User.IsInRole("Administrators"))) + @if (LgbPrincipal.IsAdmin(User.Identity.Name) || User.IsInRole("Administrators")) {
    diff --git a/Bootstrap.DataAccess/MenuHelper.cs b/Bootstrap.DataAccess/MenuHelper.cs index 16963bfa..133ad983 100644 --- a/Bootstrap.DataAccess/MenuHelper.cs +++ b/Bootstrap.DataAccess/MenuHelper.cs @@ -83,9 +83,9 @@ namespace Bootstrap.DataAccess return root; } /// - /// + /// 通过当前用户名获得前台菜单 /// - /// + /// 当前登陆的用户名 /// public static IEnumerable RetrieveLinksByUserName(string userName) {