增加完善分类伪静态
This commit is contained in:
@@ -6,6 +6,7 @@ using COMCMS.Core;
|
||||
using COMCMS.Common;
|
||||
using XCode;
|
||||
|
||||
|
||||
namespace COMCMS.Web.Common
|
||||
{
|
||||
/// <summary>
|
||||
@@ -14,6 +15,11 @@ namespace COMCMS.Web.Common
|
||||
public class ViewsHelper
|
||||
{
|
||||
#region 获取分类链接
|
||||
/// <summary>
|
||||
/// 文章分类
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public static string EchoURL(ArticleCategory model)
|
||||
{
|
||||
if (model == null)
|
||||
@@ -23,6 +29,46 @@ namespace COMCMS.Web.Common
|
||||
else
|
||||
return $"/article/index/{model.Id}";
|
||||
}
|
||||
/// <summary>
|
||||
/// 商品分类
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public static string EchoURL(Category model)
|
||||
{
|
||||
if (model == null)
|
||||
return "";
|
||||
if (!string.IsNullOrEmpty(model.FilePath))
|
||||
return model.FilePath + "/index.html";
|
||||
else
|
||||
return $"/product/index/{model.Id}";
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="ctype"></param>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public static string EchoURL(Utils.CMSType ctype,int id)
|
||||
{
|
||||
string url = "/";
|
||||
switch (ctype)
|
||||
{
|
||||
case Utils.CMSType.ArticleCategory:
|
||||
ArticleCategory ac = ArticleCategory.FindById(id);
|
||||
url = EchoURL(ac);
|
||||
break;
|
||||
case Utils.CMSType.ProductCategory:
|
||||
Category pc = Category.FindById(id);
|
||||
url = EchoURL(pc);
|
||||
break;
|
||||
default:
|
||||
url= "/";
|
||||
break;
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace COMCMS.Web.Controllers
|
||||
}
|
||||
|
||||
#region 测试
|
||||
//[Route("{path:regex([[a-zA-Z0-9-]])}/index.html")]
|
||||
//[Route("c/{*path}/index2.html")]
|
||||
//public IActionResult Test(string path = "")
|
||||
//{
|
||||
// string tel = "13332835377";
|
||||
|
||||
@@ -31,12 +31,13 @@
|
||||
<div class="menu-bg"></div>
|
||||
<ul class="nav-list">
|
||||
<li id="nav_0"><a href="/" title="首页">首页</a><i></i></li>
|
||||
<li id="nav_1"><a asp-controller="Article" asp-action="Index" asp-route-id="1" title="关于我们">关于我们</a><i></i></li>
|
||||
<li id="nav_P"><a asp-controller="Product" asp-action="Index" asp-route-id="1" title="产品中心">产品中心</a><i></i></li>
|
||||
<li id="nav_2"><a asp-controller="Article" asp-action="Index" asp-route-id="2" title="新闻资讯">新闻资讯</a><i></i></li>
|
||||
<li id="nav_3"><a asp-controller="Article" asp-action="Index" asp-route-id="3" title="项目案例">项目案例</a><i></i></li>
|
||||
<li id="nav_4"><a asp-controller="Article" asp-action="Index" asp-route-id="4" title="用户服务">用户服务</a><i></i></li>
|
||||
<li id="nav_5"><a asp-controller="Article" asp-action="Index" asp-route-id="5" title="联系我们">联系我们</a><i></i></li>
|
||||
|
||||
<li id="nav_1"><a href="@ViewsHelper.EchoURL(Utils.CMSType.ArticleCategory,1)" title="关于我们">关于我们</a><i></i></li>
|
||||
<li id="nav_P"><a href="@ViewsHelper.EchoURL(Utils.CMSType.ProductCategory,1)" title="产品中心">产品中心</a><i></i></li>
|
||||
<li id="nav_2"><a href="@ViewsHelper.EchoURL(Utils.CMSType.ArticleCategory,2)" title="新闻资讯">新闻资讯</a><i></i></li>
|
||||
<li id="nav_3"><a href="@ViewsHelper.EchoURL(Utils.CMSType.ArticleCategory,3)" title="项目案例">项目案例</a><i></i></li>
|
||||
<li id="nav_4"><a href="@ViewsHelper.EchoURL(Utils.CMSType.ArticleCategory,4)" title="用户服务">用户服务</a><i></i></li>
|
||||
<li id="nav_5"><a href="@ViewsHelper.EchoURL(Utils.CMSType.ArticleCategory,5)" title="联系我们">联系我们</a><i></i></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user