Przeglądaj źródła

修正移动端不能翻页的bug

懒得勤快 4 lat temu
rodzic
commit
2aec7184bd

+ 1 - 1
src/Masuit.MyBlogs.Core/Controllers/HomeController.cs

@@ -51,7 +51,7 @@ namespace Masuit.MyBlogs.Core.Controllers
         /// 首页
         /// </summary>
         /// <returns></returns>
-        [HttpGet, ResponseCache(Duration = 600, VaryByHeader = "Cookie", Location = ResponseCacheLocation.Any)]
+        [HttpGet, ResponseCache(Duration = 600, VaryByHeader = "Cookie")]
         public async Task<ActionResult> Index([FromServices] IFastShareService fastShareService)
         {
             var banners = AdsService.GetsByWeightedPrice(8, AdvertiseType.Banner, Request.Location()).OrderByRandom().ToList();

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

@@ -33,7 +33,6 @@ using Microsoft.EntityFrameworkCore;
 using Microsoft.Net.Http.Headers;
 using System;
 using System.Collections.Generic;
-using System.Collections.Immutable;
 using System.ComponentModel.DataAnnotations;
 using System.Linq;
 using System.Linq.Dynamic.Core;
@@ -148,7 +147,9 @@ namespace Masuit.MyBlogs.Core.Controllers
                 Time = DateTime.Now,
                 UserAgent = Request.Headers[HeaderNames.UserAgent],
                 Remark = "无权限查看该文章",
-                Address = Request.Location()
+                Address = Request.Location(),
+                HttpVersion = Request.Protocol,
+                Headers = Request.Headers.ToJsonString()
             });
             throw new NotFoundException("文章未找到");
         }

+ 2 - 2
src/Masuit.MyBlogs.Core/Controllers/SearchController.cs

@@ -82,7 +82,7 @@ namespace Masuit.MyBlogs.Core.Controllers
         /// <param name="size"></param>
         /// <param name="search"></param>
         /// <returns></returns>
-        [MyAuthorize, HttpPost("search/SearchList"), ResponseCache(Duration = 600, VaryByQueryKeys = new[] { "page", "size", "search" }, VaryByHeader = "Cookie")]
+        [MyAuthorize, HttpPost("search/SearchList"), ResponseCache(Duration = 600, VaryByQueryKeys = new[] { "page", "size", "search" })]
         public ActionResult SearchList([Range(1, int.MaxValue, ErrorMessage = "页码必须大于0")] int page = 1, [Range(1, 50, ErrorMessage = "页大小必须在0到50之间")] int size = 15, string search = "")
         {
             var where = string.IsNullOrEmpty(search) ? (Expression<Func<SearchDetails, bool>>)(s => true) : s => s.Keywords.Contains(search);
@@ -99,7 +99,7 @@ namespace Masuit.MyBlogs.Core.Controllers
         /// 热词
         /// </summary>
         /// <returns></returns>
-        [MyAuthorize, Route("search/HotKey"), ResponseCache(Duration = 600, VaryByHeader = "Cookie")]
+        [MyAuthorize, Route("search/HotKey"), ResponseCache(Duration = 600)]
         public ActionResult HotKey()
         {
             return ResultData(new

+ 3 - 1
src/Masuit.MyBlogs.Core/Controllers/SubscribeController.cs

@@ -286,7 +286,9 @@ namespace Masuit.MyBlogs.Core.Controllers
                 Time = DateTime.Now,
                 UserAgent = Request.Headers[HeaderNames.UserAgent],
                 Remark = "无权限查看该文章",
-                Address = Request.Location()
+                Address = Request.Location(),
+                HttpVersion = Request.Protocol,
+                Headers = Request.Headers.ToJsonString()
             });
             throw new NotFoundException("文章未找到");
         }

+ 3 - 3
src/Masuit.MyBlogs.Core/Controllers/ToolsController.cs

@@ -39,7 +39,7 @@ namespace Masuit.MyBlogs.Core.Controllers
         /// </summary>
         /// <param name="ip"></param>
         /// <returns></returns>
-        [Route("ip"), Route("ip/{ip?}", Order = 1), ResponseCache(Duration = 600, VaryByQueryKeys = new[] { "ip" }, VaryByHeader = "Cookie")]
+        [Route("ip"), Route("ip/{ip?}", Order = 1), ResponseCache(Duration = 600, VaryByQueryKeys = new[] { "ip" })]
         public async Task<ActionResult> GetIpInfo([IsIPAddress] string ip)
         {
             if (string.IsNullOrEmpty(ip))
@@ -76,7 +76,7 @@ namespace Masuit.MyBlogs.Core.Controllers
         /// <param name="lat"></param>
         /// <param name="lng"></param>
         /// <returns></returns>
-        [HttpGet("pos"), ResponseCache(Duration = 600, VaryByQueryKeys = new[] { "lat", "lng" }, VaryByHeader = "Cookie")]
+        [HttpGet("pos"), ResponseCache(Duration = 600, VaryByQueryKeys = new[] { "lat", "lng" })]
         public async Task<ActionResult> Position(string lat, string lng)
         {
             if (string.IsNullOrEmpty(lat) || string.IsNullOrEmpty(lng))
@@ -121,7 +121,7 @@ namespace Masuit.MyBlogs.Core.Controllers
         /// </summary>
         /// <param name="addr"></param>
         /// <returns></returns>
-        [Route("addr"), ResponseCache(Duration = 600, VaryByQueryKeys = new[] { "addr" }, VaryByHeader = "Cookie")]
+        [Route("addr"), ResponseCache(Duration = 600, VaryByQueryKeys = new[] { "addr" })]
         public async Task<ActionResult> Address(string addr)
         {
             if (string.IsNullOrEmpty(addr))

+ 3 - 1
src/Masuit.MyBlogs.Core/Extensions/Firewall/FirewallAttribute.cs

@@ -97,7 +97,9 @@ namespace Masuit.MyBlogs.Core.Extensions.Firewall
                 Referer = request.Headers[HeaderNames.Referer],
                 UserAgent = request.Headers[HeaderNames.UserAgent],
                 Remark = remark,
-                Address = request.Location()
+                Address = request.Location(),
+                HttpVersion = request.Protocol,
+                Headers = request.Headers.ToJsonString()
             });
             var limit = CommonHelper.SystemSettings.GetOrAdd("LimitIPInterceptTimes", "30").ToInt32();
             await RedisHelper.LRangeAsync<IpIntercepter>("intercept", 0, -1).ContinueWith(async t =>

+ 2 - 0
src/Masuit.MyBlogs.Core/Extensions/Firewall/IpIntercepter.cs

@@ -11,5 +11,7 @@ namespace Masuit.MyBlogs.Core.Extensions.Firewall
         public string UserAgent { get; set; }
         public DateTime Time { get; set; }
         public string Remark { get; set; }
+        public string HttpVersion { get; set; }
+        public string Headers { get; set; }
     }
 }

+ 3 - 1
src/Masuit.MyBlogs.Core/Extensions/Firewall/RequestInterceptMiddleware.cs

@@ -58,7 +58,9 @@ namespace Masuit.MyBlogs.Core.Extensions.Firewall
                     Referer = request.Headers[HeaderNames.Referer],
                     UserAgent = request.Headers[HeaderNames.UserAgent],
                     Remark = $"检测到敏感词拦截:{match.Value}",
-                    Address = request.Location()
+                    Address = request.Location(),
+                    HttpVersion = request.Protocol,
+                    Headers = request.Headers.ToJsonString()
                 });
                 context.Response.StatusCode = 400;
                 context.Response.ContentType = "text/html; charset=utf-8";

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

@@ -46,7 +46,7 @@
         <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="5.0.9" />
         <PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="5.0.9" />
         <PackageReference Include="Microsoft.Extensions.Http.Polly" Version="5.0.1" />
-        <PackageReference Include="Microsoft.Graph" Version="4.1.0" />
+        <PackageReference Include="Microsoft.Graph" Version="4.2.0" />
         <PackageReference Include="Microsoft.Graph.Auth" Version="1.0.0-preview.6" />
         <PackageReference Include="MiniProfiler.AspNetCore.Mvc" Version="4.2.22" />
         <PackageReference Include="OpenXmlPowerTools-NetStandard" Version="4.4.21" />

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

@@ -86,10 +86,10 @@
             <h3>Oops!抱歉~本专题没有收录相关的文章或资源!如果您有相关的结果,您可以 <a asp-controller="Post" asp-action="Publish" class="btn btn-info btn-lg">点击这里</a> 投稿哦!</h3>
         }
         <div class="row">
-            <div class="col-xs-8">
+            <div class="col-sm-8 col-xs-12">
                 @{ await Html.RenderPartialAsync("_Pagination", page); }
             </div>
-            <div class="col-sm-4 text-right">
+            <div class="col-sm-4 col-xs-12 text-right">
                 <div class="btn-group dropup">
                     <a asp-controller="Post" asp-action="All" class="btn btn-info">所有专题</a>
                     <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">

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

@@ -34,10 +34,10 @@
             }
         }
         <div class="row">
-            <div class="col-xs-9">
+            <div class="col-sm-9 col-xs-12">
                 @{ await Html.RenderPartialAsync("_Pagination", Model.PageParams); }
             </div>
-            <div class="col-sm-3 text-right">
+            <div class="col-sm-3 col-xs-12 text-right">
                 <div class="btn-group dropup">
                     <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                         @(Model.PageParams.OrderBy?.GetDescription()??"排序方式")

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

@@ -34,10 +34,10 @@
             }
         }
         <div class="row">
-            <div class="col-xs-9">
+            <div class="col-sm-9 col-xs-12">
                 @{ await Html.RenderPartialAsync("_Pagination", Model.PageParams); }
             </div>
-            <div class="col-sm-3 text-right">
+            <div class="col-sm-3 col-xs-12 text-right">
                 <div class="btn-group dropup">
                     <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                         @(Model.PageParams.OrderBy?.GetDescription()??"排序方式")

+ 7 - 1
src/Masuit.MyBlogs.Core/wwwroot/ng-views/views/system/firewall.html

@@ -109,6 +109,9 @@
             <td filter="{RequestUrl: 'text'}" title="'请求URL'">
                 <a ng-href="{{row.RequestUrl}}" target="_blank">{{row.RequestUrl}}</a>
             </td>
+            <td filter="{HttpVersion: 'text'}" title="'协议'">
+                {{row.HttpVersion}}
+            </td>
             <td filter="{Referer: 'text'}" title="'来源URL'">
                 <a ng-href="{{row.Referer}}" target="_blank">{{row.Referer}}</a>
             </td>
@@ -116,11 +119,14 @@
                 {{row.UserAgent}}
             </td>
             <td title="'拦截时间'">
-                {{row.Time|date:'yyyy-MM-dd HH:mm:ss'}}
+                {{row.Time|date:'yyyy-MM-dd HH:mm'}}
             </td>
             <td filter="{Remark: 'text'}" title="'备注'">
                 {{row.Remark}}
             </td>
+            <td filter="{Headers: 'text'}" title="'请求头'">
+                {{row.Headers}}
+            </td>
         </tr>
     </table>
 </div>