Преглед изворни кода

AngleSharp替代HtmlAgilityPack

懒得勤快 пре 4 година
родитељ
комит
7468693107

+ 34 - 32
src/Masuit.MyBlogs.Core/Common/CommonHelper.cs

@@ -1,6 +1,6 @@
-using AutoMapper;
+using AngleSharp;
+using AutoMapper;
 using Hangfire;
-using HtmlAgilityPack;
 using IP2Region;
 using Masuit.MyBlogs.Core.Common.Mails;
 using Masuit.Tools;
@@ -19,6 +19,7 @@ using System.Linq;
 using System.Net;
 using System.Net.Sockets;
 using System.Text;
+using System.Threading.Tasks;
 using TimeZoneConverter;
 
 namespace Masuit.MyBlogs.Core.Common
@@ -28,7 +29,7 @@ namespace Masuit.MyBlogs.Core.Common
     /// </summary>
     public static class CommonHelper
     {
-        private static readonly FileSystemWatcher _fileSystemWatcher = new(AppContext.BaseDirectory + "App_Data", "*.txt")
+        private static readonly FileSystemWatcher FileSystemWatcher = new(AppContext.BaseDirectory + "App_Data", "*.txt")
         {
             IncludeSubdirectories = true,
             EnableRaisingEvents = true,
@@ -38,10 +39,7 @@ namespace Masuit.MyBlogs.Core.Common
         static CommonHelper()
         {
             Init();
-            _fileSystemWatcher.Changed += (_, _) =>
-            {
-                Init();
-            };
+            FileSystemWatcher.Changed += (_, _) => Init();
         }
 
         private static void Init()
@@ -95,11 +93,6 @@ namespace Masuit.MyBlogs.Core.Common
         /// </summary>
         public static ConcurrentDictionary<string, string> SystemSettings { get; set; } = new();
 
-        /// <summary>
-        /// 网站启动时间
-        /// </summary>
-        public static DateTime StartupTime { get; set; } = DateTime.Now;
-
         /// <summary>
         /// IP黑名单地址段
         /// </summary>
@@ -239,17 +232,26 @@ namespace Masuit.MyBlogs.Core.Common
         /// </summary>
         /// <param name="html"></param>
         /// <returns></returns>
-        public static string ClearImgAttributes(this string html)
+        public static async Task<string> ClearImgAttributes(this string html)
         {
-            var doc = new HtmlDocument();
-            doc.LoadHtml(html);
-            var nodes = doc.DocumentNode.Descendants("img");
+            var context = BrowsingContext.New(Configuration.Default);
+            var doc = await context.OpenAsync(req => req.Content(html));
+            var nodes = doc.DocumentElement.GetElementsByTagName("img");
+            var allows = new[] { "src", "data-original", "width", "style", "class" };
             foreach (var node in nodes)
             {
-                node.Attributes.RemoveWhere(a => !new[] { "src", "data-original", "width", "style", "class" }.Contains(a.Name));
+                for (var i = 0; i < node.Attributes.Length; i++)
+                {
+                    if (allows.Contains(node.Attributes[i].Name))
+                    {
+                        continue;
+                    }
+
+                    node.RemoveAttribute(node.Attributes[i].Name);
+                }
             }
 
-            return doc.DocumentNode.OuterHtml;
+            return doc.Body.InnerHtml;
         }
 
         /// <summary>
@@ -258,24 +260,24 @@ namespace Masuit.MyBlogs.Core.Common
         /// <param name="html"></param>
         /// <param name="title"></param>
         /// <returns></returns>
-        public static string ReplaceImgAttribute(this string html, string title)
+        public static async Task<string> ReplaceImgAttribute(this string html, string title)
         {
-            var doc = new HtmlDocument();
-            doc.LoadHtml(html);
-            var nodes = doc.DocumentNode.Descendants("img");
+            var context = BrowsingContext.New(Configuration.Default);
+            var doc = await context.OpenAsync(req => req.Content(html));
+            var nodes = doc.DocumentElement.GetElementsByTagName("img");
             foreach (var node in nodes)
             {
-                if (node.Attributes.Contains("src"))
+                if (node.HasAttribute("src"))
                 {
                     string src = node.Attributes["src"].Value;
-                    node.Attributes.Remove("src");
-                    node.Attributes.Add("data-original", src);
-                    node.Attributes.Add("alt", SystemSettings["Title"]);
-                    node.Attributes.Add("title", title);
+                    node.RemoveAttribute("src");
+                    node.SetAttribute("data-original", src);
+                    node.SetAttribute("alt", SystemSettings["Title"]);
+                    node.SetAttribute("title", title);
                 }
             }
 
-            return doc.DocumentNode.OuterHtml;
+            return doc.Body.InnerHtml;
         }
 
         /// <summary>
@@ -285,11 +287,11 @@ namespace Masuit.MyBlogs.Core.Common
         /// <param name="length">截取长度</param>
         /// <param name="min">摘要最少字数</param>
         /// <returns></returns>
-        public static string GetSummary(this string html, int length = 150, int min = 10)
+        public static async Task<string> GetSummary(this string html, int length = 150, int min = 10)
         {
-            var doc = new HtmlDocument();
-            doc.LoadHtml(html);
-            var summary = doc.DocumentNode.Descendants("p").FirstOrDefault(n => n.InnerText.Length > min)?.InnerText ?? "没有摘要";
+            var context = BrowsingContext.New(Configuration.Default);
+            var doc = await context.OpenAsync(req => req.Content(html));
+            var summary = doc.DocumentElement.GetElementsByTagName("p").FirstOrDefault(n => n.TextContent.Length > min)?.TextContent ?? "没有摘要";
             if (summary.Length > length)
             {
                 return summary.Substring(0, length) + "...";

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

@@ -93,7 +93,7 @@ namespace Masuit.MyBlogs.Core.Controllers
                     comment.IsMaster = true;
                 }
             }
-            comment.Content = dto.Content.HtmlSantinizerStandard().ClearImgAttributes();
+            comment.Content = await dto.Content.HtmlSantinizerStandard().ClearImgAttributes();
             comment.Browser = dto.Browser ?? Request.Headers[HeaderNames.UserAgent];
             comment.IP = ClientIP;
             comment.Location = Request.Location();

+ 2 - 2
src/Masuit.MyBlogs.Core/Controllers/MiscController.cs

@@ -120,7 +120,7 @@ namespace Masuit.MyBlogs.Core.Controllers
         [MyAuthorize]
         public async Task<ActionResult> Write(Misc model, CancellationToken cancellationToken)
         {
-            model.Content = await ImagebedClient.ReplaceImgSrc(model.Content.Trim().ClearImgAttributes(), cancellationToken);
+            model.Content = await ImagebedClient.ReplaceImgSrc(await model.Content.Trim().ClearImgAttributes(), cancellationToken);
             var e = MiscService.AddEntitySaved(model);
             return e != null ? ResultData(null, message: "发布成功") : ResultData(null, false, "发布失败");
         }
@@ -148,7 +148,7 @@ namespace Masuit.MyBlogs.Core.Controllers
             var entity = await MiscService.GetByIdAsync(misc.Id) ?? throw new NotFoundException("杂项页未找到");
             entity.ModifyDate = DateTime.Now;
             entity.Title = misc.Title;
-            entity.Content = await ImagebedClient.ReplaceImgSrc(misc.Content.ClearImgAttributes(), cancellationToken);
+            entity.Content = await ImagebedClient.ReplaceImgSrc(await misc.Content.ClearImgAttributes(), cancellationToken);
             bool b = await MiscService.SaveChangesAsync() > 0;
             return ResultData(null, b, b ? "修改成功" : "修改失败");
         }

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

@@ -163,7 +163,7 @@ namespace Masuit.MyBlogs.Core.Controllers
                 }
             }
 
-            msg.Content = dto.Content.HtmlSantinizerStandard().ClearImgAttributes();
+            msg.Content = await dto.Content.HtmlSantinizerStandard().ClearImgAttributes();
             msg.Browser = dto.Browser ?? Request.Headers[HeaderNames.UserAgent];
             msg.IP = ClientIP;
             msg.Location = Request.Location();

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

@@ -80,7 +80,7 @@ namespace Masuit.MyBlogs.Core.Controllers
         [MyAuthorize]
         public async Task<ActionResult> Write(Notice notice, CancellationToken cancellationToken)
         {
-            notice.Content = await ImagebedClient.ReplaceImgSrc(notice.Content.ClearImgAttributes(), cancellationToken);
+            notice.Content = await ImagebedClient.ReplaceImgSrc(await notice.Content.ClearImgAttributes(), cancellationToken);
             if (notice.StartTime.HasValue && notice.EndTime.HasValue && notice.StartTime >= notice.EndTime)
             {
                 return ResultData(null, false, "开始时间不能小于结束时间");
@@ -145,7 +145,7 @@ namespace Masuit.MyBlogs.Core.Controllers
             entity.StartTime = notice.StartTime;
             entity.EndTime = notice.EndTime;
             entity.Title = notice.Title;
-            entity.Content = await ImagebedClient.ReplaceImgSrc(notice.Content.ClearImgAttributes(), cancellationToken);
+            entity.Content = await ImagebedClient.ReplaceImgSrc(await notice.Content.ClearImgAttributes(), cancellationToken);
             bool b = await NoticeService.SaveChangesAsync() > 0;
             return ResultData(null, b, b ? "修改成功" : "修改失败");
         }

+ 14 - 7
src/Masuit.MyBlogs.Core/Controllers/PostController.cs

@@ -1,4 +1,4 @@
-using AngleSharp.Text;
+using AngleSharp;
 using CacheManager.Core;
 using Hangfire;
 using JiebaNet.Segmenter;
@@ -69,7 +69,7 @@ namespace Masuit.MyBlogs.Core.Controllers
             var post = await PostService.GetAsync(p => p.Id == id && (p.Status == Status.Published || CurrentUser.IsAdmin)) ?? throw new NotFoundException("文章未找到");
             CheckPermission(post);
             ViewBag.Keyword = post.Keyword + "," + post.Label;
-            ViewBag.Desc = post.Content.GetSummary(200);
+            ViewBag.Desc = await post.Content.GetSummary(200);
             var modifyDate = post.ModifyDate;
             ViewBag.Next = await PostService.GetFromCacheAsync<DateTime, PostModelBase>(p => p.ModifyDate > modifyDate && (p.Status == Status.Published || CurrentUser.IsAdmin), p => p.ModifyDate);
             ViewBag.Prev = await PostService.GetFromCacheAsync<DateTime, PostModelBase>(p => p.ModifyDate < modifyDate && (p.Status == Status.Published || CurrentUser.IsAdmin), p => p.ModifyDate, false);
@@ -315,7 +315,7 @@ namespace Masuit.MyBlogs.Core.Controllers
 
             post.Label = string.IsNullOrEmpty(post.Label?.Trim()) ? null : post.Label.Replace(",", ",");
             post.Status = Status.Pending;
-            post.Content = await ImagebedClient.ReplaceImgSrc(post.Content.HtmlSantinizerStandard().ClearImgAttributes(), cancellationToken);
+            post.Content = await ImagebedClient.ReplaceImgSrc(await post.Content.HtmlSantinizerStandard().ClearImgAttributes(), cancellationToken);
             Post p = post.Mapper<Post>();
             p.IP = ClientIP;
             p.Modifier = p.Author;
@@ -711,7 +711,7 @@ namespace Masuit.MyBlogs.Core.Controllers
         [HttpPost, MyAuthorize]
         public async Task<ActionResult> Edit(PostCommand post, bool reserve = true, CancellationToken cancellationToken = default)
         {
-            post.Content = await ImagebedClient.ReplaceImgSrc(post.Content.Trim().ClearImgAttributes(), cancellationToken);
+            post.Content = await ImagebedClient.ReplaceImgSrc(await post.Content.Trim().ClearImgAttributes(), cancellationToken);
             if (!ValidatePost(post, out var resultData))
             {
                 return resultData;
@@ -720,8 +720,15 @@ namespace Masuit.MyBlogs.Core.Controllers
             Post p = await PostService.GetByIdAsync(post.Id);
             if (reserve && p.Status == Status.Published)
             {
-                var history = p.Mapper<PostHistoryVersion>();
-                p.PostHistoryVersion.Add(history);
+                var context = BrowsingContext.New(Configuration.Default);
+                var doc1 = await context.OpenAsync(req => req.Content(p.Content), cancellationToken);
+                var doc2 = await context.OpenAsync(req => req.Content(post.Content), cancellationToken);
+                if (doc1.Body.TextContent != doc2.Body.TextContent)
+                {
+                    var history = p.Mapper<PostHistoryVersion>();
+                    p.PostHistoryVersion.Add(history);
+                }
+
                 p.ModifyDate = DateTime.Now;
                 var user = HttpContext.Session.Get<UserInfoDto>(SessionKey.UserInfo);
                 p.Modifier = user.NickName;
@@ -765,7 +772,7 @@ namespace Masuit.MyBlogs.Core.Controllers
         [MyAuthorize, HttpPost]
         public async Task<ActionResult> Write(PostCommand post, DateTime? timespan, bool schedule = false, CancellationToken cancellationToken = default)
         {
-            post.Content = await ImagebedClient.ReplaceImgSrc(post.Content.Trim().ClearImgAttributes(), cancellationToken);
+            post.Content = await ImagebedClient.ReplaceImgSrc(await post.Content.Trim().ClearImgAttributes(), cancellationToken);
             if (!ValidatePost(post, out var resultData))
             {
                 return resultData;

+ 18 - 28
src/Masuit.MyBlogs.Core/Controllers/SubscribeController.cs

@@ -6,14 +6,12 @@ using Masuit.MyBlogs.Core.Models.ViewModel;
 using Masuit.Tools;
 using Masuit.Tools.Core.Net;
 using Microsoft.AspNetCore.Mvc;
-using Microsoft.Extensions.Caching.Memory;
 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 using WilderMinds.RssSyndication;
-using Z.EntityFramework.Plus;
 
 namespace Masuit.MyBlogs.Core.Controllers
 {
@@ -22,11 +20,7 @@ namespace Masuit.MyBlogs.Core.Controllers
     /// </summary>
     public class SubscribeController : Controller
     {
-        /// <summary>
-        /// 文章
-        /// </summary>
         public IPostService PostService { get; set; }
-        public ICategoryService CategoryService { get; set; }
         public IAdvertisementService AdvertisementService { get; set; }
 
         /// <summary>
@@ -34,19 +28,19 @@ namespace Masuit.MyBlogs.Core.Controllers
         /// </summary>
         /// <returns></returns>
         [Route("/rss"), ResponseCache(Duration = 3600)]
-        public IActionResult Rss()
+        public async Task<IActionResult> Rss()
         {
             var time = DateTime.Today.AddDays(-1);
             string scheme = Request.Scheme;
             var host = Request.Host;
-            var posts = PostService.GetQueryNoTracking(p => p.Status == Status.Published && p.ModifyDate >= time, p => p.ModifyDate, false).Select(p => new Item()
+            var data = await PostService.GetQueryFromCache(p => p.Status == Status.Published && p.ModifyDate >= time, p => p.ModifyDate, false).SelectAsync(async p => new Item()
             {
                 Author = new Author
                 {
                     Name = p.Author,
-                    Email = p.Email.MaskEmail('*')
+                    Email = p.Email.MaskEmail()
                 },
-                Body = p.Content.GetSummary(300, 50),
+                Body = await p.Content.GetSummary(300, 50),
                 Categories = new List<string>
                 {
                     p.Category.Name
@@ -56,11 +50,9 @@ namespace Masuit.MyBlogs.Core.Controllers
                 Title = p.Title,
                 Permalink = scheme + "://" + host + "/" + p.Id,
                 Guid = p.Id.ToString(),
-                FullHtmlContent = p.Content.GetSummary(300, 50)
-            }).FromCache(new MemoryCacheEntryOptions()
-            {
-                AbsoluteExpirationRelativeToNow = TimeSpan.FromHours(1)
-            }).ToList();
+                FullHtmlContent = await p.Content.GetSummary(300, 50)
+            });
+            var posts = data.ToList();
             InsertAdvertisement(posts);
             var feed = new Feed()
             {
@@ -69,7 +61,7 @@ namespace Masuit.MyBlogs.Core.Controllers
                 Link = new Uri(scheme + "://" + host + "/rss"),
                 Copyright = CommonHelper.SystemSettings["Title"],
                 Language = "zh-cn",
-                Items = posts.ToArray()
+                Items = posts
             };
             var rss = feed.Serialize(new SerializeOption()
             {
@@ -108,20 +100,20 @@ namespace Masuit.MyBlogs.Core.Controllers
         /// </summary>
         /// <returns></returns>
         [Route("/cat/{id}/rss"), ResponseCache(Duration = 3600)]
-        public async Task<IActionResult> CategoryRss(int id)
+        public async Task<IActionResult> CategoryRss([FromServices] ICategoryService categoryService, int id)
         {
             var time = DateTime.Today.AddDays(-1);
             string scheme = Request.Scheme;
             var host = Request.Host;
-            var category = await CategoryService.GetByIdAsync(id) ?? throw new NotFoundException("分类未找到");
-            var posts = PostService.GetQueryNoTracking(p => p.CategoryId == id && p.Status == Status.Published && p.ModifyDate >= time, p => p.ModifyDate, false).Select(p => new Item()
+            var category = await categoryService.GetByIdAsync(id) ?? throw new NotFoundException("分类未找到");
+            var data = await PostService.GetQueryFromCache(p => p.CategoryId == id && p.Status == Status.Published && p.ModifyDate >= time, p => p.ModifyDate, false).SelectAsync(async p => new Item()
             {
                 Author = new Author
                 {
                     Name = p.Author,
-                    Email = p.Email.MaskEmail('*')
+                    Email = p.Email.MaskEmail()
                 },
-                Body = p.Content.GetSummary(300, 50),
+                Body = await p.Content.GetSummary(300, 50),
                 Categories = new List<string>
                 {
                     p.Category.Name
@@ -131,11 +123,9 @@ namespace Masuit.MyBlogs.Core.Controllers
                 Title = p.Title,
                 Permalink = scheme + "://" + host + "/" + p.Id,
                 Guid = p.Id.ToString(),
-                FullHtmlContent = p.Content.GetSummary(300, 50)
-            }).FromCache(new MemoryCacheEntryOptions()
-            {
-                AbsoluteExpirationRelativeToNow = TimeSpan.FromHours(1)
-            }).ToList();
+                FullHtmlContent = await p.Content.GetSummary(300, 50)
+            });
+            var posts = data.ToList();
             InsertAdvertisement(posts, id);
             var feed = new Feed()
             {
@@ -144,7 +134,7 @@ namespace Masuit.MyBlogs.Core.Controllers
                 Link = new Uri(scheme + "://" + host + "/rss"),
                 Copyright = CommonHelper.SystemSettings["Title"],
                 Language = "zh-cn",
-                Items = posts.ToArray()
+                Items = posts
             };
             var rss = feed.Serialize(new SerializeOption()
             {
@@ -163,7 +153,7 @@ namespace Masuit.MyBlogs.Core.Controllers
             string scheme = Request.Scheme;
             var host = Request.Host;
             var p = await PostService.GetAsync(p => p.Status == Status.Published && p.Id == id) ?? throw new NotFoundException("文章未找到");
-            var summary = p.Content.GetSummary(300, 50);
+            var summary = await p.Content.GetSummary(300, 50);
             var item = new Item()
             {
                 Author = new Author

+ 7 - 8
src/Masuit.MyBlogs.Core/Controllers/UploadController.cs

@@ -1,5 +1,5 @@
-using DocumentFormat.OpenXml.Packaging;
-using HtmlAgilityPack;
+using AngleSharp;
+using DocumentFormat.OpenXml.Packaging;
 using Masuit.MyBlogs.Core.Common;
 using Masuit.MyBlogs.Core.Extensions.UEditor;
 using Masuit.MyBlogs.Core.Models.DTO;
@@ -134,11 +134,10 @@ namespace Masuit.MyBlogs.Core.Controllers
         private async Task<string> SaveAsHtml(IFormFile file)
         {
             var html = await ConvertToHtml(file);
-            var doc = new HtmlDocument();
-            doc.LoadHtml(html);
-            var body = doc.DocumentNode.SelectSingleNode("//body");
-            var style = doc.DocumentNode.SelectSingleNode("//style");
-            var nodes = body.SelectNodes("//img");
+            var context = BrowsingContext.New(Configuration.Default);
+            var doc = context.OpenAsync(req => req.Content(html)).Result;
+            var body = doc.Body;
+            var nodes = body.GetElementsByTagName("img");
             if (nodes != null)
             {
                 foreach (var img in nodes)
@@ -159,7 +158,7 @@ namespace Masuit.MyBlogs.Core.Controllers
                 }
             }
 
-            return style.OuterHtml + body.InnerHtml.HtmlSantinizerStandard().HtmlSantinizerCustom(attributes: new[] { "dir", "lang" });
+            return body.InnerHtml.HtmlSantinizerStandard().HtmlSantinizerCustom(attributes: new[] { "dir", "lang" });
         }
 
         private static async Task SaveFile(IFormFile file, string path)

+ 26 - 1
src/Masuit.MyBlogs.Core/Infrastructure/Repository/PostRepository.cs

@@ -1,7 +1,10 @@
-using Masuit.MyBlogs.Core.Infrastructure.Repository.Interface;
+using EFCoreSecondLevelCacheInterceptor;
+using Masuit.MyBlogs.Core.Infrastructure.Repository.Interface;
 using Masuit.MyBlogs.Core.Models.Entity;
 using Microsoft.EntityFrameworkCore;
 using System;
+using System.Collections.Generic;
+using System.Linq;
 using System.Linq.Expressions;
 using System.Threading.Tasks;
 
@@ -30,5 +33,27 @@ namespace Masuit.MyBlogs.Core.Infrastructure.Repository
             return DataContext.Post.Include(p => p.Category).Include(p => p.Seminar).FirstOrDefaultAsync(@where);
         }
 
+        /// <summary>
+        /// 基本查询方法,获取一个集合,优先从二级缓存读取
+        /// </summary>
+        /// <param name="where">查询条件</param>
+        /// <returns>还未执行的SQL语句</returns>
+        public override List<Post> GetQueryFromCache(Expression<Func<Post, bool>> @where)
+        {
+            return DataContext.Post.Include(p => p.Category).Where(where).Cacheable().ToList();
+        }
+
+        /// <summary>
+        /// 基本查询方法,获取一个集合
+        /// </summary>
+        /// <typeparam name="TS">排序</typeparam>
+        /// <param name="where">查询条件</param>
+        /// <param name="orderby">排序字段</param>
+        /// <param name="isAsc">是否升序</param>
+        /// <returns>还未执行的SQL语句</returns>
+        public override IOrderedQueryable<Post> GetQuery<TS>(Expression<Func<Post, bool>> @where, Expression<Func<Post, TS>> @orderby, bool isAsc = true)
+        {
+            return isAsc ? DataContext.Post.Include(p => p.Category).Where(where).OrderBy(orderby) : DataContext.Post.Include(p => p.Category).Where(where).OrderByDescending(orderby);
+        }
     }
 }

+ 1 - 1
src/Masuit.MyBlogs.Core/Views/Misc/Index.cshtml

@@ -53,7 +53,7 @@
 </div>
 <div class="container">
     <article class="content">
-        @Html.Raw(Model.Content.ReplaceImgAttribute(Model.Title))
+        @Html.Raw(await Model.Content.ReplaceImgAttribute(Model.Title))
     </article>
 </div>
 <script src="~/Assets/UEditor/third-party/SyntaxHighlighter/scripts/shCore.min.js"></script>

+ 1 - 1
src/Masuit.MyBlogs.Core/Views/Notice/Details.cshtml

@@ -66,7 +66,7 @@
                 <main>
                     <section>
                         <article class="article" id="article">
-                            @Html.Raw(Model.Content.ReplaceImgAttribute(Model.Title))
+                            @Html.Raw(await Model.Content.ReplaceImgAttribute(Model.Title))
                         </article>
                     </section>
                 </main>

+ 2 - 2
src/Masuit.MyBlogs.Core/Views/Post/CompareVersion.cshtml

@@ -83,7 +83,7 @@
                                     </div>
                                 </header>
                                 <article class="article" id="article">
-                                    @Html.Raw(Model[1].Content.ReplaceImgAttribute(Model[0].Title))
+                                    @Html.Raw(await Model[1].Content.ReplaceImgAttribute(Model[0].Title))
                                 </article>
                             </section>
                             @if (ads.Any())
@@ -169,7 +169,7 @@
                                     </div>
                                 </header>
                                 <article class="article" id="article">
-                                    @Html.Raw(Model[2].Content.ReplaceImgAttribute(Model[0].Title))
+                                    @Html.Raw(await Model[2].Content.ReplaceImgAttribute(Model[0].Title))
                                 </article>
                             </section>
                             @if (ads.Count > 1)

+ 2 - 2
src/Masuit.MyBlogs.Core/Views/Post/Details.cshtml

@@ -107,14 +107,14 @@
                             </div>
                         </header>
                         <article class="article" id="article">
-                            @Html.Raw(Model.Content.ReplaceImgAttribute(Model.Title))
+                            @Html.Raw(await Model.Content.ReplaceImgAttribute(Model.Title))
                             @if (!string.IsNullOrEmpty(Model.ProtectContent))
                             {
                                 <div class="row protected">
                                     @if (!string.IsNullOrEmpty(Context.Session.Get<string>("AccessViewToken")) || Context.Request.Cookies["Email"].MDString3(AppConfig.BaiduAK).Equals(Context.Request.Cookies["PostAccessToken"]))
                                     {
                                         <p class="text-red text-center size20">↓↓↓以下是文章加密部分↓↓↓</p>
-                                        @Html.Raw(Model.ProtectContent.ReplaceImgAttribute(Model.Title))
+                                        @Html.Raw(await Model.ProtectContent.ReplaceImgAttribute(Model.Title))
 
                                     }
                                     else

+ 2 - 2
src/Masuit.MyBlogs.Core/Views/Post/HistoryVersion.cshtml

@@ -84,7 +84,7 @@
                             <p class="text-focus text-center">您目前正在查看该文章的历史版本,文章的历史版本可能无法为您提供最准确及时的资讯,不具备任何参考价值,<a asp-controller="Post" asp-action="Details" asp-route-id="@Model.PostId">点击前往</a>该文章的最新版本。</p>
                         </header>
                         <article class="article" id="article">
-                            @Html.Raw(Model.Content.ReplaceImgAttribute(Model.Title))
+                            @Html.Raw(await Model.Content.ReplaceImgAttribute(Model.Title))
                             @if (!string.IsNullOrEmpty(Model.ProtectContent))
                             {
                                 <div class="row protected">
@@ -124,7 +124,7 @@
                                     else
                                     {
                                         <p class="text-red text-center size20">↓↓↓以下是文章加密部分↓↓↓</p>
-                                        @Html.Raw(Model.ProtectContent.ReplaceImgAttribute(Model.Title))
+                                        @Html.Raw(await Model.ProtectContent.ReplaceImgAttribute(Model.Title))
                                     }
                                 </div>
                             }

+ 1 - 1
src/Masuit.MyBlogs.Core/Views/Shared/_ArticleListItem.cshtml

@@ -47,7 +47,7 @@
                     </span>
                 </div>
                 <p>
-                    @Html.Raw(Model.Content.GetSummary(150, 50))
+                    @Html.Raw(await Model.Content.GetSummary(150, 50))
                 </p>
             </div>
         </div>

+ 1 - 1
src/Masuit.MyBlogs.Core/Views/Shared/_ArticleListItem_Admin.cshtml

@@ -49,7 +49,7 @@
                     </span>
                 </div>
                 <p>
-                    @Html.Raw(Model.Content.GetSummary(150, 50))
+                    @Html.Raw(await Model.Content.GetSummary(150, 50))
                 </p>
             </div>
         </div>

+ 1 - 1
src/Masuit.MyBlogs.Core/Views/Shared/_Aside.cshtml

@@ -21,7 +21,7 @@
                                 @foreach (NoticeDto notice in Model.Notices)
                                 {
                                     <li class="news-item">
-                                        <a class="tippy-scale" title="查看详情" asp-controller="Notice" asp-action="Details" asp-route-id="@notice.Id">@notice.Content.GetSummary(45, 2)</a>
+                                        <a class="tippy-scale" title="查看详情" asp-controller="Notice" asp-action="Details" asp-route-id="@notice.Id">@await notice.Content.GetSummary(45, 2)</a>
                                     </li>
                                 }
                             </ul>

+ 0 - 26
src/Masuit.MyBlogs.Core/bundleconfig.json

@@ -1,26 +0,0 @@
-[
-    {
-        "outputFileName": "wwwroot/Assets/UEditor/ueditor.all.min.js",
-        "inputFiles": [
-            "wwwroot/Assets/UEditor/ueditor.all.min.js"
-        ]
-    },
-    {
-        "outputFileName": "wwwroot/Assets/UEditor/ueditor.config.front.min.js",
-        "inputFiles": [
-            "wwwroot/Assets/UEditor/ueditor.config.front.js"
-        ]
-    },
-    {
-        "outputFileName": "wwwroot/Assets/UEditor/ueditor.config.admin.min.js",
-        "inputFiles": [
-            "wwwroot/Assets/UEditor/ueditor.config.admin.js"
-        ]
-    },
-    {
-        "outputFileName": "wwwroot/Assets/jedate/jedate.min.css",
-        "inputFiles": [
-            "wwwroot/Assets/jedate/jedate.css"
-        ]
-    }
-]