浏览代码

一点优化

懒得勤快 5 年之前
父节点
当前提交
bf56549f2b

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

@@ -41,7 +41,7 @@ namespace Masuit.MyBlogs.Core.Controllers
         /// <param name="dto"></param>
         /// <param name="dto"></param>
         /// <returns></returns>
         /// <returns></returns>
         [HttpPost, ValidateAntiForgeryToken]
         [HttpPost, ValidateAntiForgeryToken]
-        public async Task<ActionResult> Put(CommentCommand dto)
+        public async Task<ActionResult> Submit(CommentCommand dto)
         {
         {
             if (Regex.Match(dto.Content, CommonHelper.BanRegex).Length > 0)
             if (Regex.Match(dto.Content, CommonHelper.BanRegex).Length > 0)
             {
             {

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

@@ -106,7 +106,7 @@ namespace Masuit.MyBlogs.Core.Controllers
         /// <param name="dto"></param>
         /// <param name="dto"></param>
         /// <returns></returns>
         /// <returns></returns>
         [HttpPost, ValidateAntiForgeryToken]
         [HttpPost, ValidateAntiForgeryToken]
-        public ActionResult Put(LeaveMessageCommand dto)
+        public ActionResult Submit(LeaveMessageCommand dto)
         {
         {
             if (Regex.Match(dto.Content, CommonHelper.BanRegex).Length > 0)
             if (Regex.Match(dto.Content, CommonHelper.BanRegex).Length > 0)
             {
             {

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

@@ -1,9 +1,7 @@
 using Masuit.MyBlogs.Core.Common;
 using Masuit.MyBlogs.Core.Common;
 using Masuit.Tools.Security;
 using Masuit.Tools.Security;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Http;
-using Microsoft.EntityFrameworkCore.Internal;
 using System;
 using System;
-using System.Linq;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 
 
 namespace Masuit.MyBlogs.Core.Extensions
 namespace Masuit.MyBlogs.Core.Extensions
@@ -42,7 +40,7 @@ namespace Masuit.MyBlogs.Core.Extensions
             }
             }
 
 
             var ip = context.Connection.RemoteIpAddress.MapToIPv4().ToString();
             var ip = context.Connection.RemoteIpAddress.MapToIPv4().ToString();
-            RedisHelper.SAddAsync("Share:" + mail, ip).ContinueWith(task => RedisHelper.Expire("Share:" + mail, TimeSpan.FromDays(8)));
+            RedisHelper.SAddAsync("Share:" + mail, ip).ContinueWith(task => RedisHelper.Expire("Share:" + mail, TimeSpan.FromDays(30)));
             //var query = req.Query.Where(x => x.Key != "share").Select(x => x.Key + "=" + x.Value).Join("&");
             //var query = req.Query.Where(x => x.Key != "share").Select(x => x.Key + "=" + x.Value).Join("&");
             //context.Response.Redirect((req.Path + "?" + query).Trim('?'));
             //context.Response.Redirect((req.Path + "?" + query).Trim('?'));
         }
         }

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

@@ -31,7 +31,7 @@ namespace Masuit.MyBlogs.Core.Extensions
             if (!string.IsNullOrEmpty(trueip) && ip != trueip)
             if (!string.IsNullOrEmpty(trueip) && ip != trueip)
             {
             {
                 AccessDeny(trueip, request, "客户端请求不合法,伪造IP:" + ip);
                 AccessDeny(trueip, request, "客户端请求不合法,伪造IP:" + ip);
-                context.Result = new BadRequestObjectResult("当前请求已被非法篡改,本站阻止访问!");
+                context.Result = new BadRequestObjectResult("当前请求已被非法篡改,本站阻止访问!如果你不知道发生了什么,请尝试关闭如adguard隐身模式、代理软件、可能会修改http请求的浏览器扩展等再进行重试!");
                 return;
                 return;
             }
             }
 
 

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

@@ -20,7 +20,6 @@ namespace Masuit.MyBlogs.Core.Infrastructure.Services
         /// <returns></returns>
         /// <returns></returns>
         public List<Comment> GetSelfAndAllChildrenCommentsByParentId(int id)
         public List<Comment> GetSelfAndAllChildrenCommentsByParentId(int id)
         {
         {
-            //return SqlQuery("exec sp_getChildrenCommentByParentId " + id);
             var c = GetById(id);
             var c = GetById(id);
             if (c != null)
             if (c != null)
             {
             {
@@ -40,7 +39,7 @@ namespace Masuit.MyBlogs.Core.Infrastructure.Services
         /// <returns></returns>
         /// <returns></returns>
         private void GetSelfAndAllChildrenCommentsByParentId(Comment comment, List<Comment> list)
         private void GetSelfAndAllChildrenCommentsByParentId(Comment comment, List<Comment> list)
         {
         {
-            var comments = GetQueryFromCache(x => x.ParentId == comment.Id).ToList();
+            var comments = GetQuery(x => x.ParentId == comment.Id).ToList();
             if (comments.Any())
             if (comments.Any())
             {
             {
                 list.AddRange(comments);
                 list.AddRange(comments);

+ 3 - 3
src/Masuit.MyBlogs.Core/Infrastructure/Services/LeaveMessageService.cs

@@ -20,7 +20,7 @@ namespace Masuit.MyBlogs.Core.Infrastructure.Services
         /// <returns></returns>
         /// <returns></returns>
         public IEnumerable<LeaveMessage> GetSelfAndAllChildrenMessagesByParentId(int id)
         public IEnumerable<LeaveMessage> GetSelfAndAllChildrenMessagesByParentId(int id)
         {
         {
-            var msg = GetFromCache(m => m.Id == id);
+            var msg = Get(m => m.Id == id);
             if (msg != null)
             if (msg != null)
             {
             {
                 var msgs = new List<LeaveMessage>() { msg };
                 var msgs = new List<LeaveMessage>() { msg };
@@ -38,7 +38,7 @@ namespace Masuit.MyBlogs.Core.Infrastructure.Services
         /// <returns></returns>
         /// <returns></returns>
         private void GetSelfAndAllChildrenMessagesByParentId(LeaveMessage msg, List<LeaveMessage> list)
         private void GetSelfAndAllChildrenMessagesByParentId(LeaveMessage msg, List<LeaveMessage> list)
         {
         {
-            var msgs = GetQueryFromCache(x => x.ParentId == msg.Id).ToList();
+            var msgs = GetQuery(x => x.ParentId == msg.Id).ToList();
             if (msgs.Any())
             if (msgs.Any())
             {
             {
                 list.AddRange(msgs);
                 list.AddRange(msgs);
@@ -56,7 +56,7 @@ namespace Masuit.MyBlogs.Core.Infrastructure.Services
         /// <returns></returns>
         /// <returns></returns>
         public int GetParentMessageIdByChildId(int id)
         public int GetParentMessageIdByChildId(int id)
         {
         {
-            LeaveMessage msg = GetFromCache(m => m.Id == id);
+            LeaveMessage msg = Get(m => m.Id == id);
             if (msg != null)
             if (msg != null)
             {
             {
                 return GetParentMessageIdByChildId(msg);
                 return GetParentMessageIdByChildId(msg);

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

@@ -35,18 +35,18 @@
         <PackageReference Include="htmldiff.net-core" Version="1.3.6" />
         <PackageReference Include="htmldiff.net-core" Version="1.3.6" />
         <PackageReference Include="IP2Region" Version="1.2.0" />
         <PackageReference Include="IP2Region" Version="1.2.0" />
         <PackageReference Include="Karambolo.AspNetCore.Bundling.NUglify" Version="3.1.0" />
         <PackageReference Include="Karambolo.AspNetCore.Bundling.NUglify" Version="3.1.0" />
-        <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.3" />
-        <PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson" Version="3.1.3" />
-        <PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="3.1.3" />
+        <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.4" />
+        <PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson" Version="3.1.4" />
+        <PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="3.1.4" />
         <PackageReference Include="MiniProfiler.AspNetCore.Mvc" Version="4.1.0" />
         <PackageReference Include="MiniProfiler.AspNetCore.Mvc" Version="4.1.0" />
         <PackageReference Include="OpenXmlPowerTools-NetStandard" Version="4.4.21" />
         <PackageReference Include="OpenXmlPowerTools-NetStandard" Version="4.4.21" />
         <PackageReference Include="MiniProfiler.EntityFrameworkCore" Version="4.1.0" />
         <PackageReference Include="MiniProfiler.EntityFrameworkCore" Version="4.1.0" />
         <PackageReference Include="PanGu.HighLight" Version="1.0.0" />
         <PackageReference Include="PanGu.HighLight" Version="1.0.0" />
         <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="3.1.1" />
         <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="3.1.1" />
-        <PackageReference Include="System.Linq.Dynamic.Core" Version="1.1.0" />
+        <PackageReference Include="System.Linq.Dynamic.Core" Version="1.1.1" />
         <PackageReference Include="WilderMinds.RssSyndication" Version="1.6.0" />
         <PackageReference Include="WilderMinds.RssSyndication" Version="1.6.0" />
         <PackageReference Include="WinInsider.System.Net.Http.Formatting" Version="1.0.14" />
         <PackageReference Include="WinInsider.System.Net.Http.Formatting" Version="1.0.14" />
-        <PackageReference Include="Z.EntityFramework.Plus.EFCore" Version="3.0.49" />
+        <PackageReference Include="Z.EntityFramework.Plus.EFCore" Version="3.0.50" />
     </ItemGroup>
     </ItemGroup>
     <ItemGroup>
     <ItemGroup>
         <Content Update="appsettings.json">
         <Content Update="appsettings.json">

+ 1 - 1
src/Masuit.MyBlogs.Core/appsettings.json

@@ -12,7 +12,7 @@
         "CertPath": "App_Data/cert/server.pfx", // https证书
         "CertPath": "App_Data/cert/server.pfx", // https证书
         "CertPassword": "cEHlnUGu" // 证书密码
         "CertPassword": "cEHlnUGu" // 证书密码
     },
     },
-    "ConnString": "Server=127.0.0.1;Port=33066;Database=MyBlogs;Uid=root;Pwd=;Charset=utf8mb4",
+    "ConnString": "Server=127.0.0.1;Port=3306;Database=MyBlogs;Uid=root;Pwd=;Charset=utf8mb4",
     //"ConnString": "Data Source=.;Initial Catalog=MyBlogs;Integrated Security=True",
     //"ConnString": "Data Source=.;Initial Catalog=MyBlogs;Integrated Security=True",
     "BaiduAK": "你的BaiduAK", // 百度开放平台AppKey
     "BaiduAK": "你的BaiduAK", // 百度开放平台AppKey
     "TrueClientIPHeader": "CF-Connecting-IP",
     "TrueClientIPHeader": "CF-Connecting-IP",

+ 2 - 2
src/Masuit.MyBlogs.Core/wwwroot/Scripts/global/article.js

@@ -169,7 +169,7 @@
 		}
 		}
 
 
 		localStorage.setItem("user",  JSON.stringify(formData));
 		localStorage.setItem("user",  JSON.stringify(formData));
-		window.post("/comment/put", formData, function(data) {
+		window.post("/comment/submit", formData, function(data) {
 			loadingDone();
 			loadingDone();
 			if (data.Success) {
 			if (data.Success) {
 				window.notie.alert({
 				window.notie.alert({
@@ -207,7 +207,7 @@
 function submitComment(_this) {
 function submitComment(_this) {
 	loading();
 	loading();
 	localStorage.setItem("user", JSON.stringify($(_this).serializeObject()));
 	localStorage.setItem("user", JSON.stringify($(_this).serializeObject()));
-	window.post("/comment/put", $(_this).serializeObject(), function(data) {
+	window.post("/comment/submit", $(_this).serializeObject(), function(data) {
 		loadingDone();
 		loadingDone();
 		if (data.Success) {
 		if (data.Success) {
 			window.notie.alert({
 			window.notie.alert({

文件差异内容过多而无法显示
+ 0 - 0
src/Masuit.MyBlogs.Core/wwwroot/Scripts/global/article.min.js


+ 2 - 2
src/Masuit.MyBlogs.Core/wwwroot/Scripts/global/leavemsg.js

@@ -103,7 +103,7 @@
             return;
             return;
         }
         }
 		localStorage.setItem("user", JSON.stringify($(this).serializeObject()));
 		localStorage.setItem("user", JSON.stringify($(this).serializeObject()));
-		window.post("/Msg/Put", $(this).serializeObject(), (data) => {
+		window.post("/Msg/submit", $(this).serializeObject(), (data) => {
             loadingDone();
             loadingDone();
             if (data && data.Success) {
             if (data && data.Success) {
 		        window.notie.alert({
 		        window.notie.alert({
@@ -134,7 +134,7 @@
 function submitComment(_this) {
 function submitComment(_this) {
     loading();
     loading();
 	localStorage.setItem("user", JSON.stringify($(_this).serializeObject()));
 	localStorage.setItem("user", JSON.stringify($(_this).serializeObject()));
-    window.post("/Msg/Put", $(_this).serializeObject(), (data) => {
+    window.post("/Msg/submit", $(_this).serializeObject(), (data) => {
         loadingDone();
         loadingDone();
         if (data && data.Success) {
         if (data && data.Success) {
 			window.notie.alert({
 			window.notie.alert({

文件差异内容过多而无法显示
+ 1 - 1
src/Masuit.MyBlogs.Core/wwwroot/Scripts/global/leavemsg.min.js


部分文件因为文件数量过多而无法显示