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 @@