From f9ee2df6fd32e9e264bf35ed2159b8ff150fe4ea Mon Sep 17 00:00:00 2001 From: "DESKTOP-CLI22EN\\HogenWang" Date: Thu, 6 Jun 2019 01:04:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AE=8C=E5=96=84=E5=88=86?= =?UTF-8?q?=E7=B1=BB=E4=BC=AA=E9=9D=99=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- COMCMS.Common/Utils.cs | 26 ++++++++++++++ COMCMS.Web/Common/ViewsHelper.cs | 46 ++++++++++++++++++++++++ COMCMS.Web/Controllers/HomeController.cs | 2 +- COMCMS.Web/Views/Shared/_Layout.cshtml | 13 +++---- 4 files changed, 80 insertions(+), 7 deletions(-) diff --git a/COMCMS.Common/Utils.cs b/COMCMS.Common/Utils.cs index 155d41c..630a9d4 100644 --- a/COMCMS.Common/Utils.cs +++ b/COMCMS.Common/Utils.cs @@ -75,6 +75,32 @@ namespace COMCMS.Common /// 配送状态 "未配送", "配货中", "已配送", "已收到", "退货中", "已退货" /// public static string[] DeliverState = { "未配送", "配货中", "已配送", "已收到", "退货中", "已退货" }; + /// + /// cms类型 + /// + public enum CMSType + { + /// + /// 文章分类 + /// + ArticleCategory=0, + /// + /// 文章 + /// + Article=1, + /// + /// 商品分类 + /// + ProductCategory=2, + /// + /// 商品详情 + /// + Product=3, + /// + /// 首页 + /// + Home=99 + } #endregion #region 验证部分 diff --git a/COMCMS.Web/Common/ViewsHelper.cs b/COMCMS.Web/Common/ViewsHelper.cs index c0b83d3..427584e 100644 --- a/COMCMS.Web/Common/ViewsHelper.cs +++ b/COMCMS.Web/Common/ViewsHelper.cs @@ -6,6 +6,7 @@ using COMCMS.Core; using COMCMS.Common; using XCode; + namespace COMCMS.Web.Common { /// @@ -14,6 +15,11 @@ namespace COMCMS.Web.Common public class ViewsHelper { #region 获取分类链接 + /// + /// 文章分类 + /// + /// + /// public static string EchoURL(ArticleCategory model) { if (model == null) @@ -23,6 +29,46 @@ namespace COMCMS.Web.Common else return $"/article/index/{model.Id}"; } + /// + /// 商品分类 + /// + /// + /// + 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}"; + } + /// + /// + /// + /// + /// + /// + 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 } diff --git a/COMCMS.Web/Controllers/HomeController.cs b/COMCMS.Web/Controllers/HomeController.cs index 4cade6e..253e8f3 100644 --- a/COMCMS.Web/Controllers/HomeController.cs +++ b/COMCMS.Web/Controllers/HomeController.cs @@ -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"; diff --git a/COMCMS.Web/Views/Shared/_Layout.cshtml b/COMCMS.Web/Views/Shared/_Layout.cshtml index 6463c3b..937c373 100644 --- a/COMCMS.Web/Views/Shared/_Layout.cshtml +++ b/COMCMS.Web/Views/Shared/_Layout.cshtml @@ -31,12 +31,13 @@