diff --git a/Bootstrap.Admin/App_Start/BAAuthorizeAttribute.cs b/Bootstrap.Admin/App_Start/BAAuthorizeAttribute.cs new file mode 100644 index 00000000..094db468 --- /dev/null +++ b/Bootstrap.Admin/App_Start/BAAuthorizeAttribute.cs @@ -0,0 +1,14 @@ +using Longbow.Web.Mvc; +using System; + +namespace Bootstrap.Admin +{ + /// + /// + /// + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = true)] + class BAAuthorizeAttribute : LgbAuthorizeAttribute + { + + } +} \ No newline at end of file diff --git a/Bootstrap.Admin/App_Start/FilterConfig.cs b/Bootstrap.Admin/App_Start/FilterConfig.cs new file mode 100644 index 00000000..603359a1 --- /dev/null +++ b/Bootstrap.Admin/App_Start/FilterConfig.cs @@ -0,0 +1,23 @@ +using Longbow.Web.Mvc; +using System; +using System.Web.Mvc; + +namespace Bootstrap.Admin +{ + /// + /// + /// + public static class FilterConfig + { + /// + /// + /// + /// + public static void RegisterGlobalFilters(GlobalFilterCollection filters) + { + if (filters == null) throw new ArgumentNullException("filters"); + filters.Add(new LgbHandleErrorAttribute()); + filters.Add(new BAAuthorizeAttribute()); + } + } +} \ No newline at end of file diff --git a/Bootstrap.Admin/App_Start/RouteConfig.cs b/Bootstrap.Admin/App_Start/RouteConfig.cs index ed8c6895..74f852e9 100644 --- a/Bootstrap.Admin/App_Start/RouteConfig.cs +++ b/Bootstrap.Admin/App_Start/RouteConfig.cs @@ -12,7 +12,7 @@ namespace Bootstrap.Admin routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", - defaults: new { controller = "Admin", action = "Index", id = UrlParameter.Optional } + defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } ); } } diff --git a/Bootstrap.Admin/Bootstrap.Admin.csproj b/Bootstrap.Admin/Bootstrap.Admin.csproj index 428811fd..c7146e53 100644 --- a/Bootstrap.Admin/Bootstrap.Admin.csproj +++ b/Bootstrap.Admin/Bootstrap.Admin.csproj @@ -44,6 +44,7 @@ + @@ -154,6 +155,7 @@ + Designer @@ -164,6 +166,8 @@ bldver.cs + + @@ -199,6 +203,8 @@ + + Web.config diff --git a/Bootstrap.Admin/Controllers/AdminController.cs b/Bootstrap.Admin/Controllers/AdminController.cs index 0d637b9a..479d40e6 100644 --- a/Bootstrap.Admin/Controllers/AdminController.cs +++ b/Bootstrap.Admin/Controllers/AdminController.cs @@ -1,28 +1,37 @@ using Bootstrap.Admin.Models; -using Bootstrap.DataAccess; using System.Web.Mvc; namespace Bootstrap.Admin.Controllers { + /// + /// + /// public class AdminController : Controller { - // GET: Admin + /// + /// + /// + /// public ActionResult Index() { - var v = new ModelBase(); - v.Header = new HeaderBarModel(); - v.Header.UserName = "Argo Zhang"; - v.Navigator = new NavigatorBarModel(); + var v = new NavigatorBarModel(); + v.UserName = "Argo Zhang"; + v.ShowMenu = "hide"; + v.HomeUrl = "~/Admin"; return View(v); } - + /// + /// + /// + /// public ActionResult Users() { - var v = new UserModel(); - v.Header = new HeaderBarModel(); - v.Header.UserName = "Argo Zhang"; - v.Header.BreadcrumbName = "用户管理"; - v.Navigator = new NavigatorBarModel(); + var v = new NavigatorBarModel(); + v.UserName = "Argo Zhang"; + v.BreadcrumbName = "用户管理"; + v.ShowMenu = "hide"; + v.Menus[1].Active = "active"; + v.HomeUrl = "~/Admin"; return View(v); } } diff --git a/Bootstrap.Admin/Controllers/HomeController.cs b/Bootstrap.Admin/Controllers/HomeController.cs index 6981cf9d..07af0a16 100644 --- a/Bootstrap.Admin/Controllers/HomeController.cs +++ b/Bootstrap.Admin/Controllers/HomeController.cs @@ -1,25 +1,67 @@ -using System.Web.Mvc; +using Bootstrap.Admin.Models; +using System.Web.Mvc; +using System.Web.Security; namespace Bootstrap.Admin.Controllers { + /// + /// + /// public class HomeController : Controller { - // GET: Home + /// + /// + /// + /// public ActionResult Index() { - return View(); + var v = new HeaderBarModel(); + return View(v); } + /// + /// + /// + /// public ActionResult Rules() { - return View(); + var v = new HeaderBarModel(); + v.BreadcrumbName = "规则设置"; + return View(v); } + /// + /// + /// + /// public ActionResult Terminals() { + var v = new HeaderBarModel(); + v.BreadcrumbName = "输入口设置"; + return View(v); + } + /// + /// + /// + /// + /// + /// + /// + [AllowAnonymous] + public ActionResult Login(string username, string password, string remember) + { + if (username == "Argo") + { + FormsAuthentication.RedirectFromLoginPage(username, false); + } return View(); } - public ActionResult Login() + /// + /// + /// + /// + public ActionResult Logout() { - return View(); + FormsAuthentication.SignOut(); + return RedirectToAction("Login"); } } } \ No newline at end of file diff --git a/Bootstrap.Admin/Controllers/UsersController.cs b/Bootstrap.Admin/Controllers/UsersController.cs index bd83e8a7..5c54473d 100644 --- a/Bootstrap.Admin/Controllers/UsersController.cs +++ b/Bootstrap.Admin/Controllers/UsersController.cs @@ -1,6 +1,4 @@ using Bootstrap.Admin.Models; -using Bootstrap.DataAccess; -using System.Collections.Generic; using System.Web.Http; namespace Bootstrap.Admin.Controllers diff --git a/Bootstrap.Admin/Global.asax.cs b/Bootstrap.Admin/Global.asax.cs index ec4b4523..f99c3c70 100644 --- a/Bootstrap.Admin/Global.asax.cs +++ b/Bootstrap.Admin/Global.asax.cs @@ -13,7 +13,8 @@ namespace Bootstrap.Admin // Code that runs on application startup AreaRegistration.RegisterAllAreas(); GlobalConfiguration.Configure(WebApiConfig.Register); - RouteConfig.RegisterRoutes(RouteTable.Routes); + RouteConfig.RegisterRoutes(RouteTable.Routes); + FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); } } } \ No newline at end of file diff --git a/Bootstrap.Admin/Models/HeaderBarModel.cs b/Bootstrap.Admin/Models/HeaderBarModel.cs index a1fc1991..1d1502eb 100644 --- a/Bootstrap.Admin/Models/HeaderBarModel.cs +++ b/Bootstrap.Admin/Models/HeaderBarModel.cs @@ -3,8 +3,13 @@ /// /// /// - public class HeaderBarModel + public class HeaderBarModel : ModelBase { + public HeaderBarModel() + { + UserName = "Argo Zhang"; + HomeUrl = "~/"; + } /// /// /// @@ -13,5 +18,13 @@ /// /// public string BreadcrumbName { get; set; } + /// + /// + /// + public string ShowMenu { get; set; } + /// + /// + /// + public string HomeUrl { get; set; } } } \ No newline at end of file diff --git a/Bootstrap.Admin/Models/ModelBase.cs b/Bootstrap.Admin/Models/ModelBase.cs index 93ec6977..24a8a391 100644 --- a/Bootstrap.Admin/Models/ModelBase.cs +++ b/Bootstrap.Admin/Models/ModelBase.cs @@ -1,20 +1,10 @@ -using Bootstrap.DataAccess; -using System.Collections.Generic; - -namespace Bootstrap.Admin.Models +namespace Bootstrap.Admin.Models { /// /// /// public class ModelBase { - /// - /// - /// - public HeaderBarModel Header { get; set; } - /// - /// - /// - public NavigatorBarModel Navigator { get; set; } + } } \ No newline at end of file diff --git a/Bootstrap.Admin/Models/NavigatorBarModel.cs b/Bootstrap.Admin/Models/NavigatorBarModel.cs index 8640695e..d660a68b 100644 --- a/Bootstrap.Admin/Models/NavigatorBarModel.cs +++ b/Bootstrap.Admin/Models/NavigatorBarModel.cs @@ -1,17 +1,17 @@ -using Bootstrap.DataAccess; -using System.Collections.Generic; - -namespace Bootstrap.Admin.Models -{ - public class NavigatorBarModel - { - public NavigatorBarModel() - { - Navigator = Menu.RetrieveMenus(); - } - /// - /// - /// - public List Navigator { get; set; } - } +using Bootstrap.DataAccess; +using System.Collections.Generic; + +namespace Bootstrap.Admin.Models +{ + public class NavigatorBarModel : HeaderBarModel + { + public NavigatorBarModel() + { + Menus = Menu.RetrieveMenus(); + } + /// + /// + /// + public List Menus { get; set; } + } } \ No newline at end of file diff --git a/Bootstrap.Admin/Models/UserModel.cs b/Bootstrap.Admin/Models/UserModel.cs index b517ca72..1bad06b0 100644 --- a/Bootstrap.Admin/Models/UserModel.cs +++ b/Bootstrap.Admin/Models/UserModel.cs @@ -1,6 +1,6 @@ namespace Bootstrap.Admin.Models { - public class UserModel : ModelBase + public class UserModel : HeaderBarModel { } diff --git a/Bootstrap.Admin/Views/Admin/Index.cshtml b/Bootstrap.Admin/Views/Admin/Index.cshtml index 1ebe00c1..a5fcf5d9 100644 --- a/Bootstrap.Admin/Views/Admin/Index.cshtml +++ b/Bootstrap.Admin/Views/Admin/Index.cshtml @@ -3,9 +3,9 @@ Layout = "~/Views/Shared/_Admin.cshtml"; } @section header { - @Html.Partial("Header", Model.Header) + @Html.Partial("Header", Model) } @section navigator { - @Html.Partial("Navigator", Model.Navigator) + @Html.Partial("Navigator", Model) }

欢迎使用后台管理

diff --git a/Bootstrap.Admin/Views/Admin/Users.cshtml b/Bootstrap.Admin/Views/Admin/Users.cshtml index 90d4be29..04ae574e 100644 --- a/Bootstrap.Admin/Views/Admin/Users.cshtml +++ b/Bootstrap.Admin/Views/Admin/Users.cshtml @@ -1,4 +1,4 @@ -@model Bootstrap.Admin.Models.UserModel +@model Bootstrap.Admin.Models.NavigatorBarModel @{ ViewBag.Title = "用户管理"; Layout = "~/Views/Shared/_Default.cshtml"; @@ -8,10 +8,10 @@ } @section header { - @Html.Partial("Header", Model.Header) + @Html.Partial("Header", Model) } @section navigator { - @Html.Partial("Navigator", Model.Navigator) + @Html.Partial("Navigator", Model) } @section query {
diff --git a/Bootstrap.Admin/Views/Home/Index.cshtml b/Bootstrap.Admin/Views/Home/Index.cshtml index dca9dc51..30c26648 100644 --- a/Bootstrap.Admin/Views/Home/Index.cshtml +++ b/Bootstrap.Admin/Views/Home/Index.cshtml @@ -1,29 +1,9 @@ -@{ - ViewBag.Title = "系统登陆"; - Layout = "~/Views/Shared/_Layout.cshtml"; +@model Bootstrap.Admin.Models.HeaderBarModel +@{ + ViewBag.Title = "Rules"; + Layout = "~/Views/Shared/_Fix.cshtml"; } -@section css { - +@section header { + @Html.Partial("Header", Model) } -@section javascript { - -} -
- - - - -
+

欢迎使用本系统

\ No newline at end of file diff --git a/Bootstrap.Admin/Views/Home/Login.cshtml b/Bootstrap.Admin/Views/Home/Login.cshtml new file mode 100644 index 00000000..969907c5 --- /dev/null +++ b/Bootstrap.Admin/Views/Home/Login.cshtml @@ -0,0 +1,29 @@ +@{ + ViewBag.Title = "系统登陆"; + Layout = "~/Views/Shared/_Layout.cshtml"; +} +@section css { + +} +@section javascript { + +} +
+ +
diff --git a/Bootstrap.Admin/Views/Home/Rules.cshtml b/Bootstrap.Admin/Views/Home/Rules.cshtml index 709aa0d6..ce095600 100644 --- a/Bootstrap.Admin/Views/Home/Rules.cshtml +++ b/Bootstrap.Admin/Views/Home/Rules.cshtml @@ -1,4 +1,5 @@ -@{ +@model Bootstrap.Admin.Models.HeaderBarModel +@{ ViewBag.Title = "Rules"; Layout = "~/Views/Shared/_Fix.cshtml"; } @@ -10,6 +11,9 @@ } +@section header { + @Html.Partial("Header", Model) +}
查询条件
diff --git a/Bootstrap.Admin/Views/Home/Terminals.cshtml b/Bootstrap.Admin/Views/Home/Terminals.cshtml index e16ae5ea..4aa1b629 100644 --- a/Bootstrap.Admin/Views/Home/Terminals.cshtml +++ b/Bootstrap.Admin/Views/Home/Terminals.cshtml @@ -1,4 +1,5 @@ -@{ +@model Bootstrap.Admin.Models.HeaderBarModel +@{ ViewBag.Title = "Terminals"; Layout = "~/Views/Shared/_Normal.cshtml"; } @@ -10,6 +11,9 @@ } +@section header { + @Html.Partial("Header", Model) +}
查询条件
diff --git a/Bootstrap.Admin/Views/Shared/Header.cshtml b/Bootstrap.Admin/Views/Shared/Header.cshtml index e80d5b67..c5f3c327 100644 --- a/Bootstrap.Admin/Views/Shared/Header.cshtml +++ b/Bootstrap.Admin/Views/Shared/Header.cshtml @@ -7,6 +7,20 @@ +
@@ -35,7 +49,7 @@