懒得勤快 4 gadi atpakaļ
vecāks
revīzija
70d91761ab

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

@@ -56,7 +56,7 @@ namespace Masuit.MyBlogs.Core.Infrastructure.Services
 
 
                 var list = GetQuery(where).AsEnumerable().Select(a => new WeightedItem<Advertisement>(a, a.CategoryIds is { Length: > 0 } ? (int)a.Price * 2 : (int)a.Price)).WeightedItems(count);
                 var list = GetQuery(where).AsEnumerable().Select(a => new WeightedItem<Advertisement>(a, a.CategoryIds is { Length: > 0 } ? (int)a.Price * 2 : (int)a.Price)).WeightedItems(count);
                 var ids = list.Select(a => a.Id).ToArray();
                 var ids = list.Select(a => a.Id).ToArray();
-                GetQuery(a => ids.Contains(a.Id)).UpdateFromQueryAsync(a => new Advertisement()
+                GetQuery(a => ids.Contains(a.Id)).UpdateFromQuery(a => new Advertisement()
                 {
                 {
                     DisplayCount = a.DisplayCount + 1
                     DisplayCount = a.DisplayCount + 1
                 });
                 });

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

@@ -14,8 +14,11 @@ using Masuit.MyBlogs.Core.Extensions.DriveHelpers;
 using Masuit.MyBlogs.Core.Extensions.Firewall;
 using Masuit.MyBlogs.Core.Extensions.Firewall;
 using Masuit.MyBlogs.Core.Extensions.Hangfire;
 using Masuit.MyBlogs.Core.Extensions.Hangfire;
 using Masuit.MyBlogs.Core.Infrastructure;
 using Masuit.MyBlogs.Core.Infrastructure;
+using Masuit.MyBlogs.Core.Models.DTO;
+using Masuit.MyBlogs.Core.Models.ViewModel;
 using Masuit.Tools.Core.AspNetCore;
 using Masuit.Tools.Core.AspNetCore;
 using Masuit.Tools.Core.Config;
 using Masuit.Tools.Core.Config;
+using Masuit.Tools.Core.Net;
 using Microsoft.AspNetCore.Builder;
 using Microsoft.AspNetCore.Builder;
 using Microsoft.AspNetCore.Hosting;
 using Microsoft.AspNetCore.Hosting;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Http;
@@ -143,13 +146,12 @@ namespace Masuit.MyBlogs.Core
             app.UseBundles();
             app.UseBundles();
             app.SetupHttpsRedirection(Configuration);
             app.SetupHttpsRedirection(Configuration);
             app.UseDefaultFiles().UseStaticFiles();
             app.UseDefaultFiles().UseStaticFiles();
-            app.UseSession().UseCookiePolicy().UseMiniProfiler(); //注入Session
+            app.UseSession().UseCookiePolicy(); //注入Session
+            app.UseWhen(c => c.Session.Get<UserInfoDto>(SessionKey.UserInfo)?.IsAdmin == true, builder => builder.UseMiniProfiler().UseCLRStatsDashboard());
             app.UseWhen(c => !c.Request.Path.StartsWithSegments("/_blazor"), builder => builder.UseMiddleware<RequestInterceptMiddleware>()); //启用网站请求拦截
             app.UseWhen(c => !c.Request.Path.StartsWithSegments("/_blazor"), builder => builder.UseMiddleware<RequestInterceptMiddleware>()); //启用网站请求拦截
             app.SetupHangfire();
             app.SetupHangfire();
-            app.UseCLRStatsDashboard();
             app.UseResponseCaching().UseResponseCompression(); //启动Response缓存
             app.UseResponseCaching().UseResponseCompression(); //启动Response缓存
             app.UseWhen(c => !c.Request.Path.StartsWithSegments("/_blazor"), builder => builder.UseMiddleware<TranslateMiddleware>());
             app.UseWhen(c => !c.Request.Path.StartsWithSegments("/_blazor"), builder => builder.UseMiddleware<TranslateMiddleware>());
-            //app.UseActivity();// 抽奖活动 
             app.UseRouting().UseEndpoints(endpoints =>
             app.UseRouting().UseEndpoints(endpoints =>
             {
             {
                 endpoints.MapBlazorHub(options =>
                 endpoints.MapBlazorHub(options =>