diff --git a/COMCMS.Web/Common/ViewsHelper.cs b/COMCMS.Web/Common/ViewsHelper.cs index e9ed9b1..9c56dd0 100644 --- a/COMCMS.Web/Common/ViewsHelper.cs +++ b/COMCMS.Web/Common/ViewsHelper.cs @@ -43,6 +43,39 @@ namespace COMCMS.Web.Common else return $"/product/index/{model.Id}"; } + /// + /// 生成文章详情地址 + /// + /// + /// + public static string EchoURL(Article model) + { + if (model == null) + return "javascript:;"; + + if (!string.IsNullOrEmpty(model.ArticleKind.FilePath)) + { + string url = $"{model.ArticleKind.FilePath}/{model.Id}.html"; + if (!string.IsNullOrEmpty(model.FileName)) + { + url = $"{model.ArticleKind.FilePath}/{model.FileName}"; + } + return url; + } + else + return $"/article/detail/{model.Id}"; + + } + /// + /// 商品 + /// + /// + /// + public static string EchoURL(Product model) + { + return $"/product/detail/{model.Id}"; + } + /// /// /// diff --git a/COMCMS.Web/Controllers/HomeController.cs b/COMCMS.Web/Controllers/HomeController.cs index 5f0561b..ce112d1 100644 --- a/COMCMS.Web/Controllers/HomeController.cs +++ b/COMCMS.Web/Controllers/HomeController.cs @@ -430,6 +430,7 @@ namespace COMCMS.Web.Controllers [HttpGet] public IActionResult SitemapHTML() { + ViewBag.cfg = cfg; return View(); } #endregion diff --git a/COMCMS.Web/Controllers/api/IndexController.cs b/COMCMS.Web/Controllers/api/IndexController.cs index 903de8e..299fa54 100644 --- a/COMCMS.Web/Controllers/api/IndexController.cs +++ b/COMCMS.Web/Controllers/api/IndexController.cs @@ -27,6 +27,12 @@ namespace COMCMS.Web.Controllers.api return cfg; } + [HttpGet] + public string Index() + { + return "Hello World"; + } + #region 测试验签 /// /// 测试验签 diff --git a/COMCMS.Web/Views/Article/Detail.cshtml b/COMCMS.Web/Views/Article/Detail.cshtml index bcbd9fb..a59ea87 100644 --- a/COMCMS.Web/Views/Article/Detail.cshtml +++ b/COMCMS.Web/Views/Article/Detail.cshtml @@ -33,7 +33,7 @@ diff --git a/COMCMS.Web/Views/Article/Detail_About.cshtml b/COMCMS.Web/Views/Article/Detail_About.cshtml index ccd7201..569e192 100644 --- a/COMCMS.Web/Views/Article/Detail_About.cshtml +++ b/COMCMS.Web/Views/Article/Detail_About.cshtml @@ -32,7 +32,7 @@ diff --git a/COMCMS.Web/Views/Home/SitemapHTML.cshtml b/COMCMS.Web/Views/Home/SitemapHTML.cshtml index 2c4b85b..f1bbc4e 100644 --- a/COMCMS.Web/Views/Home/SitemapHTML.cshtml +++ b/COMCMS.Web/Views/Home/SitemapHTML.cshtml @@ -1,14 +1,19 @@ @{ - Layout = null; + ViewBag.title = "网站地图"; + ViewBag.keywords = "网站地图"; + ViewBag.description = "网站地图"; } - - - - - - - SitemapHTML - - - - + + +
+
+
+ @* 请自行将网站栏目显示于此 *@ + 网站地图。 +
+
+
\ No newline at end of file diff --git a/COMCMS.Web/Views/Home/SitemapXML.cshtml b/COMCMS.Web/Views/Home/SitemapXML.cshtml index ad92a77..2264457 100644 --- a/COMCMS.Web/Views/Home/SitemapXML.cshtml +++ b/COMCMS.Web/Views/Home/SitemapXML.cshtml @@ -6,6 +6,12 @@ IList articleCategories = ArticleCategory.FindAll(ArticleCategory._.IsHide == 0, null, null, 0, 0); //前2000篇文章 IList
articles = Article.FindAll(Article._.IsHide == 0, null, null, 0, 2000); + + //所有商品栏目 + IList productCategories = Category.FindAll(Category._.IsHide == 0, null, null, 0, 0); + + //前2000个商品 + IList products = Product.FindAll(Product._.IsHide == 0, null, null, 0, 2000); } @url @@ -15,7 +21,16 @@ @foreach (var item in articleCategories) { - @(url)/article/index/@(item.Id) + @(url)@(ViewsHelper.EchoURL(item)) + 0.80 + @(lastmod) + daily + +} +@foreach (var item in productCategories) +{ + + @(url)@(ViewsHelper.EchoURL(item))) 0.80 @(lastmod) daily @@ -24,7 +39,16 @@ @foreach (var item in articles) { - @(url)/article/detail/@(item.Id) + @(url)@(ViewsHelper.EchoURL(item))) + 0.80 + @(lastmod) + daily + +} +@foreach (var item in products) +{ + + @(url)@(ViewsHelper.EchoURL(item))) 0.80 @(lastmod) daily