修复显示地址问题。增加sitemap

This commit is contained in:
2020-05-13 15:35:25 +08:00
parent 23a9399b43
commit 64b017c1da
7 changed files with 85 additions and 16 deletions
+33
View File
@@ -43,6 +43,39 @@ namespace COMCMS.Web.Common
else
return $"/product/index/{model.Id}";
}
/// <summary>
/// 生成文章详情地址
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
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}";
}
/// <summary>
/// 商品
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public static string EchoURL(Product model)
{
return $"/product/detail/{model.Id}";
}
/// <summary>
///
/// </summary>
+1
View File
@@ -430,6 +430,7 @@ namespace COMCMS.Web.Controllers
[HttpGet]
public IActionResult SitemapHTML()
{
ViewBag.cfg = cfg;
return View();
}
#endregion
@@ -27,6 +27,12 @@ namespace COMCMS.Web.Controllers.api
return cfg;
}
[HttpGet]
public string Index()
{
return "Hello World";
}
#region 测试验签
/// <summary>
/// 测试验签
+1 -1
View File
@@ -33,7 +33,7 @@
<ul class="sec-nav-list">
@foreach (Article a in alist)
{
<li class="@(a.Id == Model.Id?"sec-on":"")"><a href="@ViewsHelper.EchoURL(k)" title="@a.Title">@a.Title</a></li>
<li class="@(a.Id == Model.Id?"sec-on":"")"><a href="@ViewsHelper.EchoURL(a)" title="@a.Title">@a.Title</a></li>
}
</ul>
+1 -1
View File
@@ -32,7 +32,7 @@
<ul class="sec-nav-list">
@foreach (Article a in alist)
{
<li class="@(a.Id == Model.Id?"sec-on":"")"><a href="@ViewsHelper.EchoURL(k)" title="@a.Title">@a.Title</a></li>
<li class="@(a.Id == Model.Id?"sec-on":"")"><a href="@ViewsHelper.EchoURL(a)" title="@a.Title">@a.Title</a></li>
}
</ul>
+17 -12
View File
@@ -1,14 +1,19 @@
@{
Layout = null;
ViewBag.title = "网站地图";
ViewBag.keywords = "网站地图";
ViewBag.description = "网站地图";
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>SitemapHTML</title>
</head>
<body>
</body>
</html>
<div class="banner mobile sec-banner">
<em style="background: url('/images/default/slide-1.jpg') center top no-repeat; background-size: 100%;"></em>
</div>
<div class="banner normal sec-banner">
<em style="background: url('/images/default/slide-1.jpg') center top no-repeat; background-size: 100%;"></em>
</div>
<div class="content au">
<div class="au-bg">
<div class="cont">
@* 请自行将网站栏目显示于此 *@
网站地图。
</div>
</div>
</div>
+26 -2
View File
@@ -6,6 +6,12 @@
IList<ArticleCategory> articleCategories = ArticleCategory.FindAll(ArticleCategory._.IsHide == 0, null, null, 0, 0);
//前2000篇文章
IList<Article> articles = Article.FindAll(Article._.IsHide == 0, null, null, 0, 2000);
//所有商品栏目
IList<Category> productCategories = Category.FindAll(Category._.IsHide == 0, null, null, 0, 0);
//前2000个商品
IList<Product> products = Product.FindAll(Product._.IsHide == 0, null, null, 0, 2000);
}
<url>
<loc>@url</loc>
@@ -15,7 +21,16 @@
@foreach (var item in articleCategories)
{
<url>
<loc>@(url)/article/index/@(item.Id)</loc>
<loc>@(url)@(ViewsHelper.EchoURL(item))</loc>
<priority>0.80</priority>
<lastmod>@(lastmod)</lastmod>
<changefreq>daily</changefreq>
</url>
}
@foreach (var item in productCategories)
{
<url>
<loc>@(url)@(ViewsHelper.EchoURL(item)))</loc>
<priority>0.80</priority>
<lastmod>@(lastmod)</lastmod>
<changefreq>daily</changefreq>
@@ -24,7 +39,16 @@
@foreach (var item in articles)
{
<url>
<loc>@(url)/article/detail/@(item.Id)</loc>
<loc>@(url)@(ViewsHelper.EchoURL(item)))</loc>
<priority>0.80</priority>
<lastmod>@(lastmod)</lastmod>
<changefreq>daily</changefreq>
</url>
}
@foreach (var item in products)
{
<url>
<loc>@(url)@(ViewsHelper.EchoURL(item)))</loc>
<priority>0.80</priority>
<lastmod>@(lastmod)</lastmod>
<changefreq>daily</changefreq>