重构代码:移除HeaderBarModel的HomeUrl属性

This commit is contained in:
Argo-MacBookPro 2018-09-16 01:24:51 +08:00
parent 535270925a
commit 1af42a61d2
5 changed files with 5 additions and 14 deletions

View File

@ -1,10 +1,7 @@
using Bootstrap.Admin.Models; using Bootstrap.Admin.Models;
using Bootstrap.DataAccess; using Bootstrap.DataAccess;
using Longbow.Web.WebSockets;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
namespace Bootstrap.Admin.Controllers namespace Bootstrap.Admin.Controllers
{ {
@ -17,10 +14,10 @@ namespace Bootstrap.Admin.Controllers
/// ///
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public ActionResult Index() public IActionResult Index()
{ {
var v = new HeaderBarModel(User.Identity) { HomeUrl = DictHelper.RetrieveHomeUrl() }; var url = DictHelper.RetrieveHomeUrl();
return v.HomeUrl.StartsWith("~/") ? (ActionResult)View(v) : Redirect(v.HomeUrl); return url.Equals("~/Home/Index", System.StringComparison.OrdinalIgnoreCase) ? (IActionResult)View(new HeaderBarModel(User.Identity)) : Redirect(url);
} }
/// <summary> /// <summary>
/// ///

View File

@ -22,10 +22,6 @@ namespace Bootstrap.Admin.Models
/// </summary> /// </summary>
public string DisplayName { get; } public string DisplayName { get; }
/// <summary> /// <summary>
///
/// </summary>
public string HomeUrl { get; set; }
/// <summary>
/// 获得/设置 用户头像地址 /// 获得/设置 用户头像地址
/// </summary> /// </summary>
public string Icon { get; } public string Icon { get; }

View File

@ -11,7 +11,6 @@ namespace Bootstrap.Admin.Models
{ {
Navigations = BootstrapMenu.RetrieveSystemMenus(UserName, $"~{controller.HttpContext.Request.Path}"); Navigations = BootstrapMenu.RetrieveSystemMenus(UserName, $"~{controller.HttpContext.Request.Path}");
Applications = DictHelper.RetrieveApps(); Applications = DictHelper.RetrieveApps();
HomeUrl = "~/Admin/Index";
} }
/// <summary> /// <summary>
/// ///

View File

@ -1,5 +1,4 @@
@model HeaderBarModel @{
@{
ViewBag.Title = "首页"; ViewBag.Title = "首页";
Layout = "~/Views/Shared/_Bootstrap.cshtml"; Layout = "~/Views/Shared/_Bootstrap.cshtml";
} }

View File

@ -105,7 +105,7 @@
</div> </div>
<nav aria-label="breadcrumb"> <nav aria-label="breadcrumb">
<ol class="breadcrumb"> <ol class="breadcrumb">
<li class="breadcrumb-item"><a href="@Url.Content(Model.HomeUrl)"><i class="fa fa-home"></i>首页</a></li> <li class="breadcrumb-item"><a href="@Url.Content("~/Admin/Index")"><i class="fa fa-home"></i>首页</a></li>
<li class="breadcrumb-item d-none" id="breadNav"></li> <li class="breadcrumb-item d-none" id="breadNav"></li>
</ol> </ol>
</nav> </nav>