1
0
懒得勤快 5 жил өмнө
parent
commit
b78c483a0d

+ 1 - 0
src/Masuit.MyBlogs.Core/Common/TrackData.cs

@@ -25,6 +25,7 @@ namespace Masuit.MyBlogs.Core.Common
             }
 
             File.WriteAllLines(logPath, RequestLogs.OrderBy(x => x.Key).ThenByDescending(x => x.Value).Select(x => x.Value + "\t" + x.Key), Encoding.UTF8);
+            File.AppendAllLines(logPath, new[] { "", $"累计处理请求数:{RequestLogs.Sum(kv => kv.Value)}" });
             RequestLogs.Clear();
         }
     }

+ 7 - 7
src/Masuit.MyBlogs.Core/Controllers/NoticeController.cs

@@ -156,21 +156,21 @@ namespace Masuit.MyBlogs.Core.Controllers
         [ResponseCache(Duration = 600, VaryByHeader = "Cookie")]
         public ActionResult Last()
         {
+            var notice = NoticeService.Get(n => n.Status == Status.Display, n => n.ModifyDate, false);
+            if (notice == null)
+            {
+                return ResultData(null, false);
+            }
+
             if (Request.Cookies.TryGetValue("last-notice", out var json))
             {
                 var data = JsonConvert.DeserializeObject<NoticeOutputDto>(json);
-                if (!NoticeService.Any(n => n.Id > data.Id))
+                if (notice.Id == data.Id)
                 {
                     return ResultData(data);
                 }
             }
 
-            var notice = NoticeService.Get(n => n.Status == Status.Display, n => n.ModifyDate, false);
-            if (notice == null)
-            {
-                return ResultData(null, false);
-            }
-
             notice.ViewCount += 1;
             NoticeService.SaveChanges();
             var dto = notice.Mapper<NoticeOutputDto>();

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

@@ -23,8 +23,8 @@
 
     <ItemGroup>
         <PackageReference Include="Aliyun.OSS.SDK.NetCore" Version="2.9.1" />
-        <PackageReference Include="Autofac.Extensions.DependencyInjection" Version="5.0.1" />
-        <PackageReference Include="AutoMapper.Extensions.ExpressionMapping" Version="3.0.5" />
+        <PackageReference Include="Autofac.Extensions.DependencyInjection" Version="6.0.0" />
+        <PackageReference Include="AutoMapper.Extensions.ExpressionMapping" Version="3.0.6" />
         <PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="7.0.0" />
         <PackageReference Include="CacheManager.Microsoft.Extensions.Caching.Memory" Version="2.0.0-beta-1629" />
         <PackageReference Include="CacheManager.Serialization.Json" Version="2.0.0-beta-1629" />
@@ -42,7 +42,7 @@
         <PackageReference Include="MiniProfiler.AspNetCore.Mvc" Version="4.1.0" />
         <PackageReference Include="MiniProfiler.EntityFrameworkCore" Version="4.1.0" />
         <PackageReference Include="PanGu.HighLight" Version="1.0.0" />
-        <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="3.1.0" />
+        <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="3.1.1" />
         <PackageReference Include="System.Linq.Dynamic.Core" Version="1.0.20" />
         <PackageReference Include="WilderMinds.RssSyndication" Version="1.6.0" />
         <PackageReference Include="WinInsider.System.Net.Http.Formatting" Version="1.0.14" />

+ 3 - 3
src/Masuit.MyBlogs.Core/Startup.cs

@@ -177,9 +177,6 @@ namespace Masuit.MyBlogs.Core
                 app.UseHttpsRedirection().UseRewriter(new RewriteOptions().AddRedirectToNonWww()); // URL重写
             }
 
-            app.UseSession().UseCookiePolicy().UseMiniProfiler(); //注入Session
-            app.UseRequestIntercept(); //启用网站请求拦截
-            app.UseStaticHttpContext(); //注入静态HttpContext对象
             app.UseStaticFiles(new StaticFileOptions //静态资源缓存策略
             {
                 OnPrepareResponse = context =>
@@ -189,6 +186,9 @@ namespace Masuit.MyBlogs.Core
                 },
                 ContentTypeProvider = new FileExtensionContentTypeProvider(MimeMapper.MimeTypes),
             });
+            app.UseSession().UseCookiePolicy().UseMiniProfiler(); //注入Session
+            app.UseRequestIntercept(); //启用网站请求拦截
+            app.UseStaticHttpContext(); //注入静态HttpContext对象
 
             app.UseHangfireServer().UseHangfireDashboard("/taskcenter", new DashboardOptions()
             {