瀏覽代碼

移除计时器

懒得勤快 5 年之前
父節點
當前提交
ed3ec628f9

+ 0 - 1
src/Masuit.MyBlogs.Core/Configs/AutofacModule.cs

@@ -15,7 +15,6 @@ namespace Masuit.MyBlogs.Core.Configs
             builder.RegisterType<BackgroundJobClient>().SingleInstance();
             builder.RegisterType<FirewallAttribute>().PropertiesAutowired().AsSelf().InstancePerDependency();
             builder.RegisterType<HangfireBackJob>().As<IHangfireBackJob>().PropertiesAutowired(PropertyWiringOptions.PreserveSetValues).InstancePerDependency();
-            builder.Register(c => new Stopwatch()).As<Stopwatch>().AsSelf().PropertiesAutowired(PropertyWiringOptions.PreserveSetValues).InstancePerLifetimeScope();
         }
     }
 }

+ 1 - 29
src/Masuit.MyBlogs.Core/Controllers/BaseController.cs

@@ -7,17 +7,14 @@ using Masuit.MyBlogs.Core.Models.DTO;
 using Masuit.MyBlogs.Core.Models.Enum;
 using Masuit.MyBlogs.Core.Models.ViewModel;
 using Masuit.Tools.Core.Net;
-using Masuit.Tools.Logging;
 using Masuit.Tools.Security;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.AspNetCore.Mvc.Filters;
 using Microsoft.EntityFrameworkCore.Internal;
 using System;
-using System.Diagnostics;
 using System.Linq;
 using System.Net;
-using System.Web;
 
 namespace Masuit.MyBlogs.Core.Controllers
 {
@@ -25,7 +22,7 @@ namespace Masuit.MyBlogs.Core.Controllers
     /// 基本父控制器
     /// </summary>
     [ApiExplorerSettings(IgnoreApi = true), ServiceFilter(typeof(FirewallAttribute))]
-    public class BaseController : Controller, IResultFilter
+    public class BaseController : Controller
     {
         /// <summary>
         /// UserInfoService
@@ -53,7 +50,6 @@ namespace Masuit.MyBlogs.Core.Controllers
 
         public IMapper Mapper { get; set; }
         public MapperConfiguration MapperConfig { get; set; }
-        public Stopwatch Stopwatch { get; set; }
 
         /// <summary>
         /// 响应数据
@@ -80,7 +76,6 @@ namespace Masuit.MyBlogs.Core.Controllers
         /// <param name="filterContext">有关当前请求和操作的信息。</param>
         public override void OnActionExecuting(ActionExecutingContext filterContext)
         {
-            Stopwatch.Start();
             base.OnActionExecuting(filterContext);
             var user = filterContext.HttpContext.Session.Get<UserInfoDto>(SessionKey.UserInfo);
 #if DEBUG
@@ -145,35 +140,12 @@ namespace Masuit.MyBlogs.Core.Controllers
                 return;
             }
 
-            #region 准备页面数据模型
-
             ViewBag.menus = MenuService.GetQueryFromCache<MenuDto>(m => m.Status == Status.Available).OrderBy(m => m.Sort).ToList(); //菜单
             var model = new PageFootViewModel //页脚
             {
                 Links = LinksService.GetQueryFromCache<LinksDto>(l => l.Status == Status.Available).OrderByDescending(l => l.Recommend).ThenByDescending(l => l.Weight).ThenByDescending(l => new Random().Next()).Take(40).ToList()
             };
             ViewBag.Footer = model;
-
-            #endregion
-
-            ViewData["ActionElapsed"] = Stopwatch.ElapsedMilliseconds + "ms";
-            if (Stopwatch.ElapsedMilliseconds > 5000)
-            {
-                LogManager.Debug($"请求路径:{Request.Scheme}://{Request.Host}{HttpUtility.UrlDecode(Request.Path)}执行耗时{Stopwatch.ElapsedMilliseconds}ms");
-            }
-        }
-
-        /// <summary>Called after the action result executes.</summary>
-        /// <param name="context">The <see cref="T:Microsoft.AspNetCore.Mvc.Filters.ResultExecutedContext" />.</param>
-        public void OnResultExecuted(ResultExecutedContext context)
-        {
-        }
-
-        /// <summary>Called before the action result executes.</summary>
-        /// <param name="context">The <see cref="T:Microsoft.AspNetCore.Mvc.Filters.ResultExecutingContext" />.</param>
-        public void OnResultExecuting(ResultExecutingContext context)
-        {
-            Stopwatch.Restart();
         }
     }
 }

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

@@ -5,7 +5,6 @@
 @using Masuit.MyBlogs.Core.Models.ViewModel
 @using Masuit.Tools
 @using Masuit.Tools.Core.Net
-@inject Stopwatch stop
 @{
     string[] colors = { "success", "info", "warning", "danger", "default" };
     IList<MenuDto> menus = ViewBag.menus;
@@ -263,7 +262,6 @@
             <div class="cd-overlay"></div>
             <footer class="footer wow fadeIn">
                 <div class="container">
-                    <span class="counter">数据耗时:@ViewData["ActionElapsed"],页面耗时:@(stop.ElapsedMilliseconds)ms</span>
                     <section>
                         友情链接:
                         @{

+ 2 - 1
src/Masuit.MyBlogs.Core/ueconfig.json

@@ -57,7 +57,8 @@
         "s-msft.com",
         "geekbang.org",
         "jetbrains.com",
-        "oz-code.com"
+        "oz-code.com",
+        "zhimg.com"
     ],
     "catcherActionName": "catchimage", /* 执行抓取远程图片的action名称 */
     "catcherFieldName": "source", /* 提交的图片列表表单名称 */