1
0
Эх сурвалжийг харах

1. 增加今日热榜功能
2. 广告权重算法优化
3. 文章分析优化
4. 安全审计优化

懒得勤快 4 жил өмнө
parent
commit
31974b78d1

+ 0 - 2
src/Masuit.MyBlogs.Core/Configs/AutofacModule.cs

@@ -1,6 +1,5 @@
 using Autofac;
 using Hangfire;
-using Masuit.MyBlogs.Core.Extensions.Firewall;
 using Masuit.MyBlogs.Core.Extensions.Hangfire;
 using System.Reflection;
 
@@ -12,7 +11,6 @@ namespace Masuit.MyBlogs.Core.Configs
         {
             builder.RegisterAssemblyTypes(Assembly.GetExecutingAssembly()).AsImplementedInterfaces().Where(t => t.Name.EndsWith("Repository") || t.Name.EndsWith("Service") || t.Name.EndsWith("Controller") || t.Name.EndsWith("Attribute")).PropertiesAutowired().AsSelf().InstancePerDependency();
             builder.RegisterType<BackgroundJobClient>().SingleInstance();
-            builder.RegisterType<FirewallAttribute>().PropertiesAutowired().AsSelf().InstancePerDependency();
             builder.RegisterType<HangfireBackJob>().As<IHangfireBackJob>().PropertiesAutowired(PropertyWiringOptions.PreserveSetValues).InstancePerDependency();
         }
     }

+ 22 - 2
src/Masuit.MyBlogs.Core/Controllers/BaseController.cs

@@ -245,6 +245,11 @@ namespace Masuit.MyBlogs.Core.Controllers
             }
 
             var location = Request.Location() + "|" + Request.Headers[HeaderNames.Referer] + "|" + Request.Headers[HeaderNames.UserAgent];
+            if (Request.Cookies.TryGetValue(SessionKey.RawIP, out var rawip) && ClientIP != rawip)
+            {
+                location += "|" + rawip.GetIPLocation();
+            }
+
             posts.RemoveAll(p =>
             {
                 switch (p.LimitMode)
@@ -281,11 +286,15 @@ namespace Masuit.MyBlogs.Core.Controllers
             }
 
             var location = Request.Location() + "|" + Request.Headers[HeaderNames.Referer] + "|" + Request.Headers[HeaderNames.UserAgent];
+            if (Request.Cookies.TryGetValue(SessionKey.RawIP, out var rawip) && ClientIP != rawip)
+            {
+                location += "|" + rawip.GetIPLocation();
+            }
+
             return p => p.LimitMode == null || p.LimitMode == RegionLimitMode.All ? true :
                    p.LimitMode == RegionLimitMode.AllowRegion ? Regex.IsMatch(location, p.Regions) :
                    p.LimitMode == RegionLimitMode.ForbidRegion ? !Regex.IsMatch(location, p.Regions) :
                    p.LimitMode == RegionLimitMode.AllowRegionExceptForbidRegion ? Regex.IsMatch(location, p.Regions) && !Regex.IsMatch(location, p.ExceptRegions) : !Regex.IsMatch(location, p.Regions) || Regex.IsMatch(location, p.ExceptRegions);
-
         }
 
         protected void CheckPermission(Post post)
@@ -296,6 +305,11 @@ namespace Masuit.MyBlogs.Core.Controllers
             }
 
             var location = Request.Location() + "|" + Request.Headers[HeaderNames.Referer] + "|" + Request.Headers[HeaderNames.UserAgent];
+            if (Request.Cookies.TryGetValue(SessionKey.RawIP, out var rawip) && ClientIP != rawip)
+            {
+                location += "|" + rawip.GetIPLocation();
+            }
+
             switch (post.LimitMode)
             {
                 case RegionLimitMode.AllowRegion:
@@ -331,6 +345,12 @@ namespace Masuit.MyBlogs.Core.Controllers
 
         private void Disallow(Post post)
         {
+            var remark = "无权限查看该文章";
+            if (Request.Cookies.TryGetValue(SessionKey.RawIP, out var rawip) && ClientIP != rawip)
+            {
+                remark += ",发生了IP切换,原始IP:" + rawip;
+            }
+
             RedisHelper.IncrBy("interceptCount");
             RedisHelper.LPush("intercept", new IpIntercepter()
             {
@@ -339,7 +359,7 @@ namespace Masuit.MyBlogs.Core.Controllers
                 Referer = Request.Headers[HeaderNames.Referer],
                 Time = DateTime.Now,
                 UserAgent = Request.Headers[HeaderNames.UserAgent],
-                Remark = "无权限查看该文章",
+                Remark = remark,
                 Address = Request.Location(),
                 HttpVersion = Request.Protocol,
                 Headers = Request.Headers.ToJsonString()

+ 21 - 4
src/Masuit.MyBlogs.Core/Controllers/HomeController.cs

@@ -92,7 +92,11 @@ namespace Masuit.MyBlogs.Core.Controllers
         {
             var viewModel = await GetIndexPageViewModel();
             var postsQuery = PostService.GetQuery(PostBaseWhere().And(p => p.Status == Status.Published)); //准备文章的查询
-            var posts = await postsQuery.Where(p => !p.IsFixedTop).OrderBy((orderBy ?? OrderBy.ModifyDate).GetDisplay() + " desc").ToCachedPagedListAsync<Post, PostDto>(page, size, MapperConfig);
+            var posts = orderBy switch
+            {
+                OrderBy.Trending => await postsQuery.Where(p => !p.IsFixedTop).OrderByDescending(p => p.PostVisitRecords.Count(e => e.Time >= DateTime.Today)).ToCachedPagedListAsync<Post, PostDto>(page, size, MapperConfig),
+                _ => await postsQuery.Where(p => !p.IsFixedTop).OrderBy((orderBy ?? OrderBy.ModifyDate).GetDisplay() + " desc").ToCachedPagedListAsync<Post, PostDto>(page, size, MapperConfig)
+            };
             if (page == 1)
             {
                 posts.Data.InsertRange(0, postsQuery.Where(p => p.IsFixedTop).OrderByDescending(p => p.ModifyDate).ProjectTo<PostDto>(MapperConfig).ToList());
@@ -122,7 +126,12 @@ namespace Masuit.MyBlogs.Core.Controllers
         public async Task<ActionResult> Tag(string tag, [Optional] OrderBy? orderBy, [Range(1, int.MaxValue, ErrorMessage = "页码必须大于0")] int page = 1, [Range(1, 50, ErrorMessage = "页大小必须在0到50之间")] int size = 15)
         {
             Expression<Func<Post, bool>> where = PostBaseWhere().And(p => p.Status == Status.Published);
-            var posts = await PostService.GetQuery(tag.Split(",", StringSplitOptions.RemoveEmptyEntries).Select(s => s.Trim()).Aggregate(where, (current, s) => current.And(p => Regex.IsMatch(p.Label, s)))).OrderBy($"{nameof(PostDto.IsFixedTop)} desc,{(orderBy ?? OrderBy.ModifyDate).GetDisplay()} desc").ToCachedPagedListAsync<Post, PostDto>(page, size, MapperConfig);
+            var queryable = PostService.GetQuery(tag.Split(",", StringSplitOptions.RemoveEmptyEntries).Select(s => s.Trim()).Aggregate(@where, (current, s) => current.And(p => Regex.IsMatch(p.Label, s))));
+            var posts = orderBy switch
+            {
+                OrderBy.Trending => await queryable.OrderByDescending(p => p.PostVisitRecords.Count(e => e.Time >= DateTime.Today)).ToCachedPagedListAsync<Post, PostDto>(page, size, MapperConfig),
+                _ => await queryable.OrderBy($"{nameof(PostDto.IsFixedTop)} desc,{(orderBy ?? OrderBy.ModifyDate).GetDisplay()} desc").ToCachedPagedListAsync<Post, PostDto>(page, size, MapperConfig)
+            };
             var viewModel = await GetIndexPageViewModel();
             ViewBag.Tag = tag;
             viewModel.Posts = posts;
@@ -150,7 +159,11 @@ namespace Masuit.MyBlogs.Core.Controllers
         {
             Expression<Func<Post, bool>> where = p => p.Author.Equals(author) || p.Modifier.Equals(author) || p.Email.Equals(author) || p.PostHistoryVersion.Any(v => v.Modifier.Equals(author) || v.ModifierEmail.Equals(author));
             where = where.And(p => p.Status == Status.Published).And(PostBaseWhere());
-            var posts = await PostService.GetQuery(where).OrderBy($"{nameof(PostDto.IsFixedTop)} desc,{(orderBy ?? OrderBy.ModifyDate).GetDisplay()} desc").ToCachedPagedListAsync<Post, PostDto>(page, size, MapperConfig);
+            var posts = orderBy switch
+            {
+                OrderBy.Trending => await PostService.GetQuery(where).OrderByDescending(p => p.PostVisitRecords.Count(e => e.Time >= DateTime.Today)).ToCachedPagedListAsync<Post, PostDto>(page, size, MapperConfig),
+                _ => await PostService.GetQuery(where).OrderBy($"{nameof(PostDto.IsFixedTop)} desc,{(orderBy ?? OrderBy.ModifyDate).GetDisplay()} desc").ToCachedPagedListAsync<Post, PostDto>(page, size, MapperConfig)
+            };
             var viewModel = await GetIndexPageViewModel();
             ViewBag.Author = author;
             viewModel.Posts = posts;
@@ -177,7 +190,11 @@ namespace Masuit.MyBlogs.Core.Controllers
         public async Task<ActionResult> Category(int id, [Optional] OrderBy? orderBy, [Range(1, int.MaxValue, ErrorMessage = "页码必须大于0")] int page = 1, [Range(1, 50, ErrorMessage = "页大小必须在0到50之间")] int size = 15)
         {
             var cat = await CategoryService.GetByIdAsync(id) ?? throw new NotFoundException("文章分类未找到");
-            var posts = await PostService.GetQuery(PostBaseWhere().And(p => p.CategoryId == cat.Id && p.Status == Status.Published)).OrderBy($"{nameof(PostDto.IsFixedTop)} desc,{(orderBy ?? OrderBy.ModifyDate).GetDisplay()} desc").ToCachedPagedListAsync<Post, PostDto>(page, size, MapperConfig);
+            var posts = orderBy switch
+            {
+                OrderBy.Trending => await PostService.GetQuery(PostBaseWhere().And(p => p.CategoryId == cat.Id && p.Status == Status.Published)).OrderByDescending(p => p.PostVisitRecords.Count(e => e.Time >= DateTime.Today)).ToCachedPagedListAsync<Post, PostDto>(page, size, MapperConfig),
+                _ => await PostService.GetQuery(PostBaseWhere().And(p => p.CategoryId == cat.Id && p.Status == Status.Published)).OrderBy($"{nameof(PostDto.IsFixedTop)} desc,{(orderBy ?? OrderBy.ModifyDate).GetDisplay()} desc").ToCachedPagedListAsync<Post, PostDto>(page, size, MapperConfig)
+            };
             var viewModel = await GetIndexPageViewModel();
             viewModel.Posts = posts;
             ViewBag.Category = cat;

+ 17 - 3
src/Masuit.MyBlogs.Core/Controllers/PostController.cs

@@ -1015,11 +1015,18 @@ namespace Masuit.MyBlogs.Core.Controllers
                 Title = p.Title,
                 ViewCount = (int)p.AverageViewCount
             }).Cacheable().ToListAsync();
+            var trending = await postsQuery.OrderByDescending(p => p.PostVisitRecords.Count(e => e.Time >= DateTime.Today)).Take(10).Select(p => new PostModelBase()
+            {
+                Id = p.Id,
+                Title = p.Title,
+                ViewCount = p.PostVisitRecords.Count(e => e.Time >= DateTime.Today)
+            }).Cacheable().ToListAsync();
             return ResultData(new
             {
                 mostHots,
                 mostView,
-                mostAverage
+                mostAverage,
+                trending
             });
         }
 
@@ -1032,9 +1039,16 @@ namespace Masuit.MyBlogs.Core.Controllers
         /// <returns></returns>
         [HttpGet("/{id}/records"), MyAuthorize]
         [ProducesResponseType(typeof(PagedList<PostVisitRecordViewModel>), (int)HttpStatusCode.OK)]
-        public async Task<IActionResult> PostVisitRecords(int id, int page = 1, int size = 15)
+        public async Task<IActionResult> PostVisitRecords(int id, int page = 1, int size = 15, string kw = "")
         {
-            var pages = await PostVisitRecordService.GetPagesAsync<DateTime, PostVisitRecordViewModel>(page, size, e => e.PostId == id, e => e.Time, false);
+            Expression<Func<PostVisitRecord, bool>> where = e => e.PostId == id;
+            if (!string.IsNullOrEmpty(kw))
+            {
+                kw = Regex.Escape(kw);
+                where = where.And(e => Regex.IsMatch(e.IP + e.Referer, kw));
+            }
+
+            var pages = await PostVisitRecordService.GetPagesAsync<DateTime, PostVisitRecordViewModel>(page, size, where, e => e.Time, false);
             return Ok(pages);
         }
 

+ 6 - 1
src/Masuit.MyBlogs.Core/Controllers/SeminarController.cs

@@ -11,6 +11,7 @@ using Masuit.Tools.Core.Net;
 using Masuit.Tools.Linq;
 using Masuit.Tools.Systems;
 using Microsoft.AspNetCore.Mvc;
+using System;
 using System.ComponentModel.DataAnnotations;
 using System.Linq;
 using System.Linq.Dynamic.Core;
@@ -46,7 +47,11 @@ namespace Masuit.MyBlogs.Core.Controllers
         public async Task<ActionResult> Index(int id, [Optional] OrderBy? orderBy, [Range(1, int.MaxValue, ErrorMessage = "页码必须大于0")] int page = 1, [Range(1, 50, ErrorMessage = "页大小必须在0到50之间")] int size = 15)
         {
             var s = await SeminarService.GetByIdAsync(id) ?? throw new NotFoundException("专题未找到");
-            var posts = await PostService.GetQuery(PostBaseWhere().And(p => p.Seminar.Any(x => x.Id == id) && p.Status == Status.Published)).OrderBy($"{nameof(Post.IsFixedTop)} desc,{(orderBy ?? OrderBy.ModifyDate).GetDisplay()} desc").ToCachedPagedListAsync<Post, PostDto>(page, size, MapperConfig);
+            var posts = orderBy switch
+            {
+                OrderBy.Trending => await PostService.GetQuery(PostBaseWhere().And(p => p.Seminar.Any(x => x.Id == id) && p.Status == Status.Published)).OrderByDescending(p => p.PostVisitRecords.Count(e => e.Time >= DateTime.Today)).ToCachedPagedListAsync<Post, PostDto>(page, size, MapperConfig),
+                _ => await PostService.GetQuery(PostBaseWhere().And(p => p.Seminar.Any(x => x.Id == id) && p.Status == Status.Published)).OrderBy($"{nameof(Post.IsFixedTop)} desc,{(orderBy ?? OrderBy.ModifyDate).GetDisplay()} desc").ToCachedPagedListAsync<Post, PostDto>(page, size, MapperConfig)
+            };
             ViewBag.Id = s.Id;
             ViewBag.Title = s.Title;
             ViewBag.Desc = s.Description;

+ 9 - 0
src/Masuit.MyBlogs.Core/Extensions/Firewall/RequestInterceptMiddleware.cs

@@ -116,6 +116,15 @@ namespace Masuit.MyBlogs.Core.Extensions.Firewall
                 context.Session.Set(SessionKey.TimeZone, context.Connection.RemoteIpAddress.GetClientTimeZone());
             }
 
+            if (!context.Request.Cookies.ContainsKey(SessionKey.RawIP))
+            {
+                context.Response.Cookies.Append(SessionKey.RawIP, ip, new CookieOptions()
+                {
+                    Expires = DateTimeOffset.Now.AddDays(1),
+                    SameSite = SameSiteMode.Lax
+                });
+            }
+
             return _next(context);
         }
     }

+ 2 - 2
src/Masuit.MyBlogs.Core/Infrastructure/Services/AdvertisementService.cs

@@ -52,11 +52,11 @@ namespace Masuit.MyBlogs.Core.Infrastructure.Services
                     var scid = cid.ToString();
                     if (Any(a => a.CategoryIds.Contains(scid)))
                     {
-                        @where = @where.And(a => a.CategoryIds.Contains(scid) || string.IsNullOrEmpty(a.CategoryIds));
+                        where = where.And(a => a.CategoryIds.Contains(scid) || string.IsNullOrEmpty(a.CategoryIds));
                     }
                 }
 
-                var list = GetQuery(where).OrderBy(a => -Math.Log(DataContext.Random()) / (double)a.Price * (string.IsNullOrEmpty(a.CategoryIds) ? 5 : 1)).Take(count).ToList();
+                var list = GetQuery(where).OrderBy(a => -Math.Log(DataContext.Random()) / ((double)a.Price / a.Types.Length) * (string.IsNullOrEmpty(a.CategoryIds) ? 5 : 1)).Take(count).ToList();
                 var ids = list.Select(a => a.Id).ToArray();
                 GetQuery(a => ids.Contains(a.Id)).UpdateFromQuery(a => new Advertisement()
                 {

+ 1 - 1
src/Masuit.MyBlogs.Core/Masuit.MyBlogs.Core.csproj

@@ -51,7 +51,7 @@
         <PackageReference Include="MiniProfiler.EntityFrameworkCore" Version="4.2.22" />
         <PackageReference Include="PanGu.HighLight" Version="1.0.0" />
         <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="5.0.2" />
-        <PackageReference Include="System.Linq.Dynamic.Core" Version="1.2.12" />
+        <PackageReference Include="System.Linq.Dynamic.Core" Version="1.2.13" />
         <PackageReference Include="TimeZoneConverter" Version="3.5.0" />
         <PackageReference Include="WilderMinds.RssSyndication" Version="1.7.0" />
         <PackageReference Include="Z.EntityFramework.Plus.EFCore" Version="5.2.13" />

+ 7 - 0
src/Masuit.MyBlogs.Core/Models/Enum/OrderBy.cs

@@ -49,5 +49,12 @@ namespace Masuit.MyBlogs.Core.Models.Enum
         [Description("最热门")]
         [Display(Name = nameof(AverageViewCount))]
         AverageViewCount,
+
+        /// <summary>
+        /// 今日热榜
+        /// </summary>
+        [Description("今日热榜")]
+        [Display(Name = nameof(Trending))]
+        Trending,
     }
 }

+ 1 - 0
src/Masuit.MyBlogs.Core/Models/ViewModel/SessionKey.cs

@@ -4,5 +4,6 @@
     {
         public const string UserInfo = "userinfo";
         public const string TimeZone = "TimeZone";
+        public const string RawIP = "rawip";
     }
 }

+ 0 - 17
src/Masuit.MyBlogs.Core/Startup.cs

@@ -15,7 +15,6 @@ using Masuit.MyBlogs.Core.Extensions.Firewall;
 using Masuit.MyBlogs.Core.Extensions.Hangfire;
 using Masuit.MyBlogs.Core.Infrastructure;
 using Masuit.MyBlogs.Core.Models.DTO;
-using Masuit.MyBlogs.Core.Models.Entity;
 using Masuit.MyBlogs.Core.Models.ViewModel;
 using Masuit.Tools.AspNetCore.Mime;
 using Masuit.Tools.Config;
@@ -31,7 +30,6 @@ using Microsoft.Extensions.Hosting;
 using Microsoft.Extensions.Primitives;
 using Polly;
 using System;
-using System.Linq;
 using System.Net;
 using System.Net.Http;
 using System.Threading.Tasks;
@@ -149,7 +147,6 @@ namespace Masuit.MyBlogs.Core
         public void Configure(IApplicationBuilder app, IWebHostEnvironment env, DataContext db, IHangfireBackJob hangfire, LuceneIndexerOptions luceneIndexerOptions)
         {
             db.Database.EnsureCreated();
-            Migration(db);
             ServiceProvider = app.ApplicationServices;
             app.InitSettings();
             app.UseLuceneSearch(env, hangfire, luceneIndexerOptions);
@@ -191,19 +188,5 @@ namespace Masuit.MyBlogs.Core
 
             Console.WriteLine("网站启动完成");
         }
-
-        /// <summary>
-        /// TODO:期初迁移数据,下个release删除
-        /// </summary>
-        /// <param name="db"></param>
-        [Obsolete("期初迁移数据,下个release删除")]
-        private void Migration(DataContext db)
-        {
-            db.Post.Where(p => p.Regions.Contains(",") || p.ExceptRegions.Contains(",")).UpdateFromQuery(p => new Post()
-            {
-                Regions = p.Regions.Replace(",", "|"),
-                ExceptRegions = p.ExceptRegions.Replace(",", "|")
-            });
-        }
     }
 }

+ 21 - 1
src/Masuit.MyBlogs.Core/Views/Post/PostVisitRecordInsight.cshtml

@@ -16,10 +16,18 @@
 </head>
 <body style="overflow-x: hidden">
     <h3 align="center">文章《@Model.Title》洞察分析</h3>
+    <div class="searchTable">
+        <div class="layui-inline">
+            <input class="layui-input" name="kw" id="kw">
+        </div>
+        <button class="layui-btn" data-type="reload">搜索</button>
+    </div>
     <table class="layui-hide" id="table" lay-filter="tableEvent"></table>
     <div id="chart" style="height: 500px"></div>
+    <mini-profiler max-traces="5" />
 </body>
 </html>
+
 <script src="/Assets/layui/layui.js"></script>
 <script src="https://cdn.jsdelivr.net/npm/echarts@5/dist/echarts.min.js" type="text/javascript"></script>
 <script>
@@ -60,6 +68,18 @@
                 window.open(data.Referer);
             }
         });
+
+        var $ = layui.$;
+        $('.searchTable .layui-btn').on('click', function () {
+            table.reload('table', {
+                page: {
+                    curr: 1
+                },
+                where: {
+                    kw: $('#kw').val()
+                }
+            });
+        });
     });
     window.fetch("/@Model.Id/records-chart", {
         credentials: 'include',
@@ -121,4 +141,4 @@
         };
         myChart.setOption(option);
     });
-</script>
+</script>

+ 3 - 0
src/Masuit.MyBlogs.Core/Views/Seminar/Index.cshtml

@@ -106,6 +106,9 @@
                         <li>
                             <a asp-route-orderby="@OrderBy.PostDate">最后发表日期</a>
                         </li>
+                        <li>
+                            <a asp-route-orderby="@OrderBy.Trending">今日热榜</a>
+                        </li>
                         <li role="separator" class="divider"></li>
                         <li>
                             <a asp-route-orderby="@OrderBy.CommentCount">评论最多</a>

+ 5 - 1
src/Masuit.MyBlogs.Core/Views/Shared/_ArticleListPartial.cshtml

@@ -23,7 +23,8 @@
             var list = Model.PostsQueryable.OrderByRandom().Take(5).ToList();
             if (list.Any())
             {
-                if (Model.Posts.CurrentPage==1) {
+                if (Model.Posts.CurrentPage == 1)
+                {
                     <div class="page-header">
                         <h3>Oops!抱歉~没有找到相关的文章或资源!如果您有相关的结果,您可以 <a asp-controller="Post" asp-action="Publish" class="btn btn-info btn-lg">点击这里</a> 投稿哦!以下是一些随机推荐:</h3>
                     </div>
@@ -52,6 +53,9 @@
                         <li>
                             <a href="@($"{Context.Request.Path}?orderby={OrderBy.PostDate}".TrimQuery())">最后发表日期</a>
                         </li>
+                        <li>
+                            <a href="@($"{Context.Request.Path}?orderby={OrderBy.Trending}".TrimQuery())">今日热榜</a>
+                        </li>
                         <li role="separator" class="divider"></li>
                         <li>
                             <a href="@($"{Context.Request.Path}?orderby={OrderBy.CommentCount}".TrimQuery())">评论最多</a>

+ 8 - 5
src/Masuit.MyBlogs.Core/Views/Shared/_ArticleListPartial_Admin.cshtml

@@ -48,20 +48,23 @@
                             <a href="">最后修改日期</a>
                         </li>
                         <li>
-                            <a asp-route-orderby="@OrderBy.PostDate">最后发表日期</a>
+                            <a href="@($"{Context.Request.Path}?orderby={OrderBy.PostDate}".TrimQuery())">最后发表日期</a>
+                        </li>
+                        <li>
+                            <a href="@($"{Context.Request.Path}?orderby={OrderBy.Trending}".TrimQuery())">今日热榜</a>
                         </li>
                         <li role="separator" class="divider"></li>
                         <li>
-                            <a asp-route-orderby="@OrderBy.CommentCount">评论最多</a>
+                            <a href="@($"{Context.Request.Path}?orderby={OrderBy.CommentCount}".TrimQuery())">评论最多</a>
                         </li>
                         <li>
-                            <a asp-route-orderby="@OrderBy.TotalViewCount">访问量最多</a>
+                            <a href="@($"{Context.Request.Path}?orderby={OrderBy.TotalViewCount}".TrimQuery())">访问量最多</a>
                         </li>
                         <li>
-                            <a asp-route-orderby="@OrderBy.VoteUpCount">支持最多</a>
+                            <a href="@($"{Context.Request.Path}?orderby={OrderBy.VoteUpCount}".TrimQuery())">支持最多</a>
                         </li>
                         <li>
-                            <a asp-route-orderby="@OrderBy.AverageViewCount">最热门</a>
+                            <a href="@($"{Context.Request.Path}?orderby={OrderBy.AverageViewCount}".TrimQuery())">最热门</a>
                         </li>
                     </ul>
                 </div>

+ 29 - 8
src/Masuit.MyBlogs.Core/wwwroot/ng-views/views/post/postlist.html

@@ -145,7 +145,28 @@
     <tm-pagination conf="paginationConf"></tm-pagination>
 </div>
 <div class="row">
-    <div class="col-md-4" ng-if="agg.mostHots.length>0">
+    <div class="col-md-6" ng-if="agg.trending.length>0">
+        <div class="page-header">
+            <h3 class="text-center">今日热榜</h3>
+        </div>
+        <table class="table table-bordered table-condensed table-responsive">
+            <thead>
+                <tr>
+                    <th style="min-width: 40px">序号</th>
+                    <th>标题</th>
+                    <th style="min-width: 60px">今日访问量</th>
+                </tr>
+            </thead>
+            <tbody>
+                <tr ng-repeat="item in agg.trending">
+                    <td>{{$index+1}}</td>
+                    <td><a ng-href="/{{item.Id}}" target="_blank">{{item.Title}}</a></td>
+                    <td>{{item.ViewCount}}</td>
+                </tr>
+            </tbody>
+        </table>
+    </div>
+    <div class="col-md-6" ng-if="agg.mostHots.length>0">
         <div class="page-header">
             <h3 class="text-center">当前在看排行榜</h3>
         </div>
@@ -166,20 +187,20 @@
             </tbody>
         </table>
     </div>
-    <div class="col-md-4" ng-if="agg.mostView.length>0">
+    <div class="col-md-6" ng-if="agg.mostAverage.length>0">
         <div class="page-header">
-            <h3 class="text-center">访问量最高排行榜</h3>
+            <h3 class="text-center">日均访问量排行榜</h3>
         </div>
         <table class="table table-bordered table-condensed table-responsive">
             <thead>
                 <tr>
                     <th style="min-width: 40px">序号</th>
                     <th>标题</th>
-                    <th style="min-width: 60px">访问量</th>
+                    <th style="min-width: 60px">日均访问量</th>
                 </tr>
             </thead>
             <tbody>
-                <tr ng-repeat="item in agg.mostView">
+                <tr ng-repeat="item in agg.mostAverage">
                     <td>{{$index+1}}</td>
                     <td><a ng-href="/{{item.Id}}" target="_blank">{{item.Title}}</a></td>
                     <td>{{item.ViewCount}}</td>
@@ -187,9 +208,9 @@
             </tbody>
         </table>
     </div>
-    <div class="col-md-4" ng-if="agg.mostAverage.length>0">
+    <div class="col-md-6" ng-if="agg.mostView.length>0">
         <div class="page-header">
-            <h3 class="text-center">日均访问量排行榜</h3>
+            <h3 class="text-center">访问量最高排行榜</h3>
         </div>
         <table class="table table-bordered table-condensed table-responsive">
             <thead>
@@ -200,7 +221,7 @@
                 </tr>
             </thead>
             <tbody>
-                <tr ng-repeat="item in agg.mostAverage">
+                <tr ng-repeat="item in agg.mostView">
                     <td>{{$index+1}}</td>
                     <td><a ng-href="/{{item.Id}}" target="_blank">{{item.Title}}</a></td>
                     <td>{{item.ViewCount}}</td>