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

+ 4 - 2
src/Masuit.MyBlogs.Core/Extensions/Hangfire/HangfireBackJob.cs

@@ -172,10 +172,12 @@ namespace Masuit.MyBlogs.Core.Extensions.Hangfire
                     if (t.IsCanceled || t.IsFaulted)
                     {
                         link.Status = Status.Unavailable;
-                        return;
+                    }
+                    else
+                    {
+                        link.Status = !t.Result.Contains(CommonHelper.SystemSettings["Domain"]) ? Status.Unavailable : Status.Available;
                     }
 
-                    link.Status = !t.Result.Contains(CommonHelper.SystemSettings["Domain"]) ? Status.Unavailable : Status.Available;
                     if (link.Status != prev)
                     {
                         link.UpdateTime = DateTime.Now;

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

@@ -24,7 +24,8 @@
     <ItemGroup>
         <PackageReference Include="Aliyun.OSS.SDK.NetCore" Version="2.10.0" />
         <PackageReference Include="Autofac.Extensions.DependencyInjection" Version="6.0.0" />
-        <PackageReference Include="AutoMapper.Extensions.ExpressionMapping" Version="3.1.2" />
+        <PackageReference Include="AutoMapper" Version="10.0.0" />
+        <PackageReference Include="AutoMapper.Extensions.ExpressionMapping" Version="4.0.0" />
         <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" />
@@ -34,7 +35,7 @@
         <PackageReference Include="Hangfire.MemoryStorage" Version="1.7.0" />
         <PackageReference Include="htmldiff.net-core" Version="1.3.6" />
         <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.2.0" />
         <PackageReference Include="MaxMind.GeoIP2" Version="3.2.0" />
         <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.5" />
         <PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson" Version="3.1.5" />
@@ -44,10 +45,10 @@
         <PackageReference Include="MiniProfiler.EntityFrameworkCore" Version="4.2.1" />
         <PackageReference Include="PanGu.HighLight" Version="1.0.0" />
         <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="3.1.1" />
-        <PackageReference Include="System.Linq.Dynamic.Core" Version="1.1.5" />
+        <PackageReference Include="System.Linq.Dynamic.Core" Version="1.1.7" />
         <PackageReference Include="WilderMinds.RssSyndication" Version="1.6.0" />
         <PackageReference Include="WinInsider.System.Net.Http.Formatting" Version="1.0.14" />
-        <PackageReference Include="Z.EntityFramework.Plus.EFCore" Version="3.0.52" />
+        <PackageReference Include="Z.EntityFramework.Plus.EFCore" Version="3.0.53" />
     </ItemGroup>
     <ItemGroup>
         <Content Update="appsettings.json">

+ 11 - 1
src/Masuit.MyBlogs.Core/Startup.cs

@@ -185,7 +185,17 @@ namespace Masuit.MyBlogs.Core
             UseLuceneSearch(env, hangfire, luceneIndexerOptions);
             if (bool.Parse(Configuration["Https:Enabled"]))
             {
-                app.UseHttpsRedirection().UseRewriter(new RewriteOptions().AddRedirectToNonWww()); // URL重写
+                app.UseHttpsRedirection();
+            }
+
+            switch (Configuration["UseRewriter"])
+            {
+                case "NonWww":
+                    app.UseRewriter(new RewriteOptions().AddRedirectToNonWww()); // URL重写
+                    break;
+                case "WWW":
+                    app.UseRewriter(new RewriteOptions().AddRedirectToWww(301)); // URL重写
+                    break;
             }
 
             app.UseDefaultFiles().UseStaticFiles(new StaticFileOptions //静态资源缓存策略

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

@@ -12,6 +12,7 @@
         "CertPath": "App_Data/cert/server.pfx", // https证书
         "CertPassword": "cEHlnUGu" // 证书密码
     },
+    "UseRewriter": "NonWww", //NonWww:重定向到不带www的域名,WWW:重定向到带www的域名
     "ConnString": "Server=127.0.0.1;Port=3306;Database=MyBlogs;Uid=root;Pwd=;Charset=utf8mb4",
     //"ConnString": "Data Source=.;Initial Catalog=MyBlogs;Integrated Security=True",
     "BaiduAK": "你的BaiduAK", // 百度开放平台AppKey