From 578f26aaba842ecdbac179174e4146e4b9917adf Mon Sep 17 00:00:00 2001 From: Argo-Lenovo Date: Sat, 12 Nov 2016 18:23:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=AD=90=E8=8F=9C=E5=8D=95ac?= =?UTF-8?q?tive=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bootstrap.Admin/Models/NavigatorBarModel.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Bootstrap.Admin/Models/NavigatorBarModel.cs b/Bootstrap.Admin/Models/NavigatorBarModel.cs index db685a43..d365134f 100644 --- a/Bootstrap.Admin/Models/NavigatorBarModel.cs +++ b/Bootstrap.Admin/Models/NavigatorBarModel.cs @@ -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 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; + }); + } /// /// ///