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

View File

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

View File

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

View File

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

View File

@ -105,7 +105,7 @@
</div>
<nav aria-label="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>
</ol>
</nav>