Răsfoiți Sursa

自适应客户端时区

懒得勤快 5 ani în urmă
părinte
comite
3e1195bf7b
23 a modificat fișierele cu 230 adăugiri și 48 ștergeri
  1. 38 1
      src/Masuit.MyBlogs.Core/Common/CommonHelper.cs
  2. 1 1
      src/Masuit.MyBlogs.Core/Configs/MappingProfile.cs
  3. 3 1
      src/Masuit.MyBlogs.Core/Controllers/AdvertisementController.cs
  4. 1 1
      src/Masuit.MyBlogs.Core/Controllers/BaseController.cs
  5. 13 3
      src/Masuit.MyBlogs.Core/Controllers/CommentController.cs
  6. 8 1
      src/Masuit.MyBlogs.Core/Controllers/LoginController.cs
  7. 14 1
      src/Masuit.MyBlogs.Core/Controllers/MergeController.cs
  8. 17 2
      src/Masuit.MyBlogs.Core/Controllers/MiscController.cs
  9. 11 3
      src/Masuit.MyBlogs.Core/Controllers/MsgController.cs
  10. 25 3
      src/Masuit.MyBlogs.Core/Controllers/NoticeController.cs
  11. 32 12
      src/Masuit.MyBlogs.Core/Controllers/PostController.cs
  12. 6 0
      src/Masuit.MyBlogs.Core/Controllers/SearchController.cs
  13. 6 4
      src/Masuit.MyBlogs.Core/Controllers/SubscribeController.cs
  14. 21 2
      src/Masuit.MyBlogs.Core/Extensions/RequestInterceptMiddleware.cs
  15. 1 0
      src/Masuit.MyBlogs.Core/Masuit.MyBlogs.Core.csproj
  16. 5 3
      src/Masuit.MyBlogs.Core/Models/ViewModel/PostDataModel.cs
  17. 1 0
      src/Masuit.MyBlogs.Core/Models/ViewModel/SessionKey.cs
  18. 1 1
      src/Masuit.MyBlogs.Core/Startup.cs
  19. 11 2
      src/Masuit.MyBlogs.Core/Views/Links/Index.cshtml
  20. 4 2
      src/Masuit.MyBlogs.Core/Views/Post/CompareVersion.cshtml
  21. 3 2
      src/Masuit.MyBlogs.Core/Views/Post/HistoryVersion.cshtml
  22. 5 2
      src/Masuit.MyBlogs.Core/Views/Post/HistoryVersion_Admin.cshtml
  23. 3 1
      src/Masuit.MyBlogs.Core/Views/Search/Search.cshtml

+ 38 - 1
src/Masuit.MyBlogs.Core/Common/CommonHelper.cs

@@ -20,6 +20,7 @@ using System.Net;
 using System.Net.Sockets;
 using System.Text;
 using System.Threading;
+using TimeZoneConverter;
 
 #if !DEBUG
 #endif
@@ -138,7 +139,7 @@ namespace Masuit.MyBlogs.Core.Common
         }
 
         private static readonly DbSearcher IPSearcher = new DbSearcher(Path.Combine(AppContext.BaseDirectory + "App_Data", "ip2region.db"));
-        private static readonly DatabaseReader MaxmindReader = new DatabaseReader(Path.Combine(AppContext.BaseDirectory + "App_Data", "GeoLite2-City.mmdb"));
+        public static readonly DatabaseReader MaxmindReader = new DatabaseReader(Path.Combine(AppContext.BaseDirectory + "App_Data", "GeoLite2-City.mmdb"));
 
         public static string GetIPLocation(this string ips)
         {
@@ -172,6 +173,19 @@ namespace Masuit.MyBlogs.Core.Common
             }
         }
 
+        public static string GetClientTimeZone(this IPAddress ip)
+        {
+            switch (ip.AddressFamily)
+            {
+                case AddressFamily.InterNetwork when ip.IsPrivateIP():
+                case AddressFamily.InterNetworkV6 when ip.IsPrivateIP():
+                    return "Asia/Shanghai";
+                default:
+                    var response = MaxmindReader.City(ip);
+                    return response.Location.TimeZone ?? "Asia/Shanghai";
+            }
+        }
+
         /// <summary>
         /// 类型映射
         /// </summary>
@@ -315,5 +329,28 @@ namespace Masuit.MyBlogs.Core.Common
             }
             return stream;
         }
+
+        /// <summary>
+        /// 转换时区
+        /// </summary>
+        /// <param name="time">UTC时间</param>
+        /// <param name="zone">时区id</param>
+        /// <returns></returns>
+        public static DateTime ToTimeZone(this DateTime time, string zone)
+        {
+            return TimeZoneInfo.ConvertTime(time, TZConvert.GetTimeZoneInfo(zone));
+        }
+
+        /// <summary>
+        /// 转换时区
+        /// </summary>
+        /// <param name="time">UTC时间</param>
+        /// <param name="zone">时区id</param>
+        /// <param name="format">时间格式字符串</param>
+        /// <returns></returns>
+        public static string ToTimeZoneF(this DateTime time, string zone, string format = "yyyy-MM-dd HH:mm:ss")
+        {
+            return ToTimeZone(time, zone).ToString(format);
+        }
     }
 }

+ 1 - 1
src/Masuit.MyBlogs.Core/Configs/MappingProfile.cs

@@ -56,7 +56,7 @@ namespace Masuit.MyBlogs.Core.Configs
             CreateMap<PostCommand, PostDto>().ReverseMap();
             CreateMap<PostHistoryVersion, PostDto>().ForMember(p => p.CategoryName, e => e.MapFrom(p => p.Category.Name)).ReverseMap();
             CreateMap<Post, PostViewModel>().ForMember(p => p.CategoryName, e => e.MapFrom(p => p.Category.Name)).ForMember(p => p.PostDate, e => e.MapFrom(p => p.PostDate.ToString("yyyy-MM-dd HH:mm:ss"))).ForMember(p => p.ModifyDate, e => e.MapFrom(p => p.ModifyDate.ToString("yyyy-MM-dd HH:mm:ss"))).ReverseMap();
-            CreateMap<Post, PostDataModel>().ForMember(p => p.ModifyDate, e => e.MapFrom(p => p.ModifyDate.ToString("yyyy-MM-dd HH:mm"))).ForMember(p => p.PostDate, e => e.MapFrom(p => p.PostDate.ToString("yyyy-MM-dd HH:mm"))).ForMember(p => p.Status, e => e.MapFrom(p => p.Status.GetDisplay())).ForMember(p => p.ModifyCount, e => e.MapFrom(p => p.PostHistoryVersion.Count)).ForMember(p => p.ViewCount, e => e.MapFrom(p => p.TotalViewCount));
+            CreateMap<Post, PostDataModel>().ForMember(p => p.ModifyDate, e => e.MapFrom(p => p.ModifyDate)).ForMember(p => p.PostDate, e => e.MapFrom(p => p.PostDate)).ForMember(p => p.Status, e => e.MapFrom(p => p.Status.GetDisplay())).ForMember(p => p.ModifyCount, e => e.MapFrom(p => p.PostHistoryVersion.Count)).ForMember(p => p.ViewCount, e => e.MapFrom(p => p.TotalViewCount));
 
             CreateMap<SearchDetails, SearchDetailsCommand>().ReverseMap();
             CreateMap<SearchDetails, SearchDetailsDto>().ReverseMap();

+ 3 - 1
src/Masuit.MyBlogs.Core/Controllers/AdvertisementController.cs

@@ -47,7 +47,7 @@ namespace Masuit.MyBlogs.Core.Controllers
         /// </summary>
         /// <returns></returns>
         [MyAuthorize]
-        public ActionResult GetPageData([Range(1, int.MaxValue, ErrorMessage = "页数必须大于0")]int page = 1, [Range(1, int.MaxValue, ErrorMessage = "页大小必须大于0")]int size = 10, string kw = "")
+        public ActionResult GetPageData([Range(1, int.MaxValue, ErrorMessage = "页数必须大于0")] int page = 1, [Range(1, int.MaxValue, ErrorMessage = "页大小必须大于0")] int size = 10, string kw = "")
         {
             Expression<Func<Advertisement, bool>> where = p => true;
             if (!string.IsNullOrEmpty(kw))
@@ -61,6 +61,8 @@ namespace Masuit.MyBlogs.Core.Controllers
             foreach (var ad in list.Data.Where(ad => !string.IsNullOrEmpty(ad.CategoryIds)))
             {
                 ad.CategoryNames = ad.CategoryIds.Split(",").Select(c => dic[c]).Join(",");
+                ad.CreateTime = ad.CreateTime.ToTimeZone(HttpContext.Session.Get<string>(SessionKey.TimeZone));
+                ad.UpdateTime = ad.UpdateTime.ToTimeZone(HttpContext.Session.Get<string>(SessionKey.TimeZone));
             }
 
             return Ok(list);

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

@@ -143,7 +143,7 @@ namespace Masuit.MyBlogs.Core.Controllers
             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()
+                Links = LinksService.GetQueryFromCache<LinksDto>(l => l.Status == Status.Available).OrderByDescending(l => l.Recommend).ThenByDescending(l => l.Weight).ThenByDescending(l => new Random().Next()).Take(30).ToList()
             };
             ViewBag.Footer = model;
         }

+ 13 - 3
src/Masuit.MyBlogs.Core/Controllers/CommentController.cs

@@ -99,7 +99,7 @@ namespace Masuit.MyBlogs.Core.Controllers
             emails.Add(email);
             var content = new Template(await System.IO.File.ReadAllTextAsync(HostEnvironment.WebRootPath + "/template/notify.html"))
                 .Set("title", post.Title)
-                .Set("time", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
+                .Set("time", DateTime.Now.ToTimeZoneF(HttpContext.Session.Get<string>(SessionKey.TimeZone)))
                 .Set("nickname", comment.NickName)
                 .Set("content", comment.Content);
             if (comment.Status == Status.Published)
@@ -191,6 +191,7 @@ namespace Masuit.MyBlogs.Core.Controllers
                 if (single.Any())
                 {
                     total = 1;
+                    single[0].CommentDate = single[0].CommentDate.ToTimeZone(HttpContext.Session.Get<string>(SessionKey.TimeZone));
                     return ResultData(new
                     {
                         total,
@@ -207,7 +208,11 @@ namespace Masuit.MyBlogs.Core.Controllers
                 return ResultData(null, false, "没有评论");
             }
             total = parent.TotalCount;
-            var result = parent.Data.SelectMany(c => CommentService.GetSelfAndAllChildrenCommentsByParentId(c.Id).Where(x => (x.Status == Status.Published || CurrentUser.IsAdmin))).ToList();
+            var result = parent.Data.SelectMany(c => CommentService.GetSelfAndAllChildrenCommentsByParentId(c.Id).Where(x => (x.Status == Status.Published || CurrentUser.IsAdmin))).Select(c =>
+            {
+                c.CommentDate = c.CommentDate.ToTimeZone(HttpContext.Session.Get<string>(SessionKey.TimeZone));
+                return c;
+            }).ToList();
             if (total > 0)
             {
                 return ResultData(new
@@ -240,7 +245,7 @@ namespace Masuit.MyBlogs.Core.Controllers
 #if !DEBUG
                 var content = new Template(await System.IO.File.ReadAllTextAsync(Path.Combine(HostEnvironment.WebRootPath, "template", "notify.html")))
                     .Set("title", post.Title)
-                    .Set("time", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
+                    .Set("time", DateTime.Now.ToTimeZoneF(HttpContext.Session.Get<string>(SessionKey.TimeZone)))
                     .Set("nickname", comment.NickName)
                     .Set("content", comment.Content);
                 var emails = CommentService.GetSelfAndAllChildrenCommentsByParentId(pid).Select(c => c.Email).Append(post.ModifierEmail).Except(new List<string> { comment.Email, CurrentUser.Email }).ToHashSet();
@@ -280,6 +285,11 @@ namespace Masuit.MyBlogs.Core.Controllers
         public ActionResult GetPendingComments([Range(1, int.MaxValue, ErrorMessage = "页码必须大于0")] int page = 1, [Range(1, 50, ErrorMessage = "页大小必须在0到50之间")] int size = 15)
         {
             var pages = CommentService.GetPages<DateTime, CommentDto>(page, size, c => c.Status == Status.Pending, c => c.CommentDate, false);
+            foreach (var item in pages.Data)
+            {
+                item.CommentDate = item.CommentDate.ToTimeZone(HttpContext.Session.Get<string>(SessionKey.TimeZone));
+            }
+
             return Ok(pages);
         }
     }

+ 8 - 1
src/Masuit.MyBlogs.Core/Controllers/LoginController.cs

@@ -1,5 +1,7 @@
-using Masuit.MyBlogs.Core.Infrastructure.Services.Interface;
+using Masuit.MyBlogs.Core.Common;
+using Masuit.MyBlogs.Core.Infrastructure.Services.Interface;
 using Masuit.MyBlogs.Core.Models.ViewModel;
+using Masuit.Tools.Core.Net;
 using Microsoft.AspNetCore.Mvc;
 using System;
 using System.Linq;
@@ -27,6 +29,11 @@ namespace Masuit.MyBlogs.Core.Controllers
         {
             var time = DateTime.Now.AddMonths(-1);
             var list = LoginRecordService.GetQueryFromCache<DateTime, LoginRecordViewModel>(r => r.UserInfoId == id && r.LoginTime >= time, r => r.LoginTime, false).ToList();
+            foreach (var item in list)
+            {
+                item.LoginTime = item.LoginTime.ToTimeZone(HttpContext.Session.Get<string>(SessionKey.TimeZone));
+            }
+
             return ResultData(list);
         }
     }

+ 14 - 1
src/Masuit.MyBlogs.Core/Controllers/MergeController.cs

@@ -9,6 +9,8 @@ using Masuit.MyBlogs.Core.Models.Command;
 using Masuit.MyBlogs.Core.Models.DTO;
 using Masuit.MyBlogs.Core.Models.Entity;
 using Masuit.MyBlogs.Core.Models.Enum;
+using Masuit.MyBlogs.Core.Models.ViewModel;
+using Masuit.Tools.Core.Net;
 using Masuit.Tools.Strings;
 using Microsoft.AspNetCore.Hosting;
 using Microsoft.AspNetCore.Mvc;
@@ -34,7 +36,13 @@ namespace Masuit.MyBlogs.Core.Controllers
         [HttpGet("{id}")]
         public ActionResult Get(int id)
         {
-            return ResultData(Mapper.Map<PostMergeRequestDto>(PostMergeRequestService.GetById(id)));
+            var p = Mapper.Map<PostMergeRequestDto>(PostMergeRequestService.GetById(id));
+            if (p != null)
+            {
+                p.SubmitTime = p.SubmitTime.ToTimeZone(HttpContext.Session.Get<string>(SessionKey.TimeZone));
+            }
+
+            return ResultData(p);
         }
 
         /// <summary>
@@ -54,6 +62,11 @@ namespace Masuit.MyBlogs.Core.Controllers
             }
 
             var list = PostMergeRequestService.GetQuery(where).OrderByDescending(d => d.MergeState == MergeStatus.Pending).ThenByDescending(r => r.Id).ToPagedList<PostMergeRequest, PostMergeRequestDtoBase>(page, size, MapperConfig);
+            foreach (var item in list.Data)
+            {
+                item.SubmitTime = item.SubmitTime.ToTimeZone(HttpContext.Session.Get<string>(SessionKey.TimeZone));
+            }
+
             return Ok(list);
         }
 

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

@@ -4,7 +4,9 @@ using Masuit.MyBlogs.Core.Infrastructure.Services.Interface;
 using Masuit.MyBlogs.Core.Models.DTO;
 using Masuit.MyBlogs.Core.Models.Entity;
 using Masuit.MyBlogs.Core.Models.Enum;
+using Masuit.MyBlogs.Core.Models.ViewModel;
 using Masuit.Tools;
+using Masuit.Tools.Core.Net;
 using Masuit.Tools.Html;
 using Microsoft.AspNetCore.Hosting;
 using Microsoft.AspNetCore.Mvc;
@@ -42,6 +44,8 @@ namespace Masuit.MyBlogs.Core.Controllers
         public ActionResult Index(int id)
         {
             var misc = MiscService.GetFromCache(m => m.Id == id) ?? throw new NotFoundException("页面未找到");
+            misc.ModifyDate = misc.ModifyDate.ToTimeZone(HttpContext.Session.Get<string>(SessionKey.TimeZone));
+            misc.PostDate = misc.PostDate.ToTimeZone(HttpContext.Session.Get<string>(SessionKey.TimeZone));
             return View(misc);
         }
 
@@ -171,6 +175,12 @@ namespace Masuit.MyBlogs.Core.Controllers
         public ActionResult GetPageData(int page = 1, int size = 10)
         {
             var list = MiscService.GetPages(page, size, n => true, n => n.ModifyDate, false);
+            foreach (var item in list.Data)
+            {
+                item.ModifyDate = item.ModifyDate.ToTimeZone(HttpContext.Session.Get<string>(SessionKey.TimeZone));
+                item.PostDate = item.PostDate.ToTimeZone(HttpContext.Session.Get<string>(SessionKey.TimeZone));
+            }
+
             return Ok(list);
         }
 
@@ -182,8 +192,13 @@ namespace Masuit.MyBlogs.Core.Controllers
         [MyAuthorize]
         public ActionResult Get(int id)
         {
-            var notice = MiscService.GetById(id);
-            return ResultData(notice.MapTo<MiscDto>());
+            var misc = MiscService.GetById(id);
+            if (misc != null)
+            {
+                misc.ModifyDate = misc.ModifyDate.ToTimeZone(HttpContext.Session.Get<string>(SessionKey.TimeZone));
+                misc.PostDate = misc.PostDate.ToTimeZone(HttpContext.Session.Get<string>(SessionKey.TimeZone));
+            }
+            return ResultData(misc.MapTo<MiscDto>());
         }
     }
 }

+ 11 - 3
src/Masuit.MyBlogs.Core/Controllers/MsgController.cs

@@ -7,14 +7,12 @@ using Masuit.MyBlogs.Core.Models.DTO;
 using Masuit.MyBlogs.Core.Models.Entity;
 using Masuit.MyBlogs.Core.Models.Enum;
 using Masuit.MyBlogs.Core.Models.ViewModel;
-using Masuit.Tools;
 using Masuit.Tools.Core.Net;
 using Masuit.Tools.Html;
 using Masuit.Tools.Logging;
 using Masuit.Tools.Strings;
 using Microsoft.AspNetCore.Hosting;
 using Microsoft.AspNetCore.Mvc;
-using Microsoft.EntityFrameworkCore.Internal;
 using Microsoft.Net.Http.Headers;
 using System;
 using System.Collections.Generic;
@@ -70,6 +68,7 @@ namespace Masuit.MyBlogs.Core.Controllers
                 if (single.Any())
                 {
                     total = 1;
+                    single[0].PostDate = single[0].PostDate.ToTimeZone(HttpContext.Session.Get<string>(SessionKey.TimeZone));
                     return ResultData(new
                     {
                         total,
@@ -86,7 +85,11 @@ namespace Masuit.MyBlogs.Core.Controllers
                 return ResultData(null, false, "没有留言");
             }
             total = parent.TotalCount;
-            var qlist = parent.Data.SelectMany(c => LeaveMessageService.GetSelfAndAllChildrenMessagesByParentId(c.Id)).Where(c => c.Status == Status.Published || CurrentUser.IsAdmin);
+            var qlist = parent.Data.SelectMany(c => LeaveMessageService.GetSelfAndAllChildrenMessagesByParentId(c.Id)).Where(c => c.Status == Status.Published || CurrentUser.IsAdmin).Select(m =>
+            {
+                m.PostDate = m.PostDate.ToTimeZone(HttpContext.Session.Get<string>(SessionKey.TimeZone));
+                return m;
+            });
             if (total > 0)
             {
                 return ResultData(new
@@ -239,6 +242,11 @@ namespace Masuit.MyBlogs.Core.Controllers
         public ActionResult GetPendingMsgs([Range(1, int.MaxValue, ErrorMessage = "页码必须大于0")] int page = 1, [Range(1, 50, ErrorMessage = "页大小必须在0到50之间")] int size = 15)
         {
             var list = LeaveMessageService.GetPages<DateTime, LeaveMessageDto>(page, size, m => m.Status == Status.Pending, l => l.PostDate, false);
+            foreach (var m in list.Data)
+            {
+                m.PostDate = m.PostDate.ToTimeZone(HttpContext.Session.Get<string>(SessionKey.TimeZone));
+            }
+
             return Ok(list);
         }
 

+ 25 - 3
src/Masuit.MyBlogs.Core/Controllers/NoticeController.cs

@@ -5,6 +5,7 @@ using Masuit.MyBlogs.Core.Models;
 using Masuit.MyBlogs.Core.Models.DTO;
 using Masuit.MyBlogs.Core.Models.Entity;
 using Masuit.MyBlogs.Core.Models.Enum;
+using Masuit.MyBlogs.Core.Models.ViewModel;
 using Masuit.Tools.Core.Net;
 using Masuit.Tools.Html;
 using Microsoft.AspNetCore.Hosting;
@@ -38,10 +39,16 @@ namespace Masuit.MyBlogs.Core.Controllers
         /// <param name="size"></param>
         /// <returns></returns>
         [Route("notice"), ResponseCache(Duration = 600, VaryByQueryKeys = new[] { "page", "size" }, VaryByHeader = "Cookie")]
-        public ActionResult Index([Range(1, int.MaxValue, ErrorMessage = "页码必须大于0")]int page = 1, [Range(1, 50, ErrorMessage = "页大小必须在0到50之间")]int size = 15)
+        public ActionResult Index([Range(1, int.MaxValue, ErrorMessage = "页码必须大于0")] int page = 1, [Range(1, 50, ErrorMessage = "页大小必须在0到50之间")] int size = 15)
         {
             var list = NoticeService.GetPages<DateTime, NoticeDto>(page, size, n => n.Status == Status.Display, n => n.ModifyDate, false);
             ViewData["page"] = new Pagination(page, size, list.TotalCount);
+            foreach (var n in list.Data)
+            {
+                n.ModifyDate = n.ModifyDate.ToTimeZone(HttpContext.Session.Get<string>(SessionKey.TimeZone));
+                n.PostDate = n.PostDate.ToTimeZone(HttpContext.Session.Get<string>(SessionKey.TimeZone));
+            }
+
             return CurrentUser.IsAdmin ? View("Index_Admin", list.Data) : View(list.Data);
         }
 
@@ -54,6 +61,8 @@ namespace Masuit.MyBlogs.Core.Controllers
         public ActionResult Details(int id)
         {
             var notice = NoticeService.GetById(id) ?? throw new NotFoundException("页面未找到");
+            notice.ModifyDate = notice.ModifyDate.ToTimeZone(HttpContext.Session.Get<string>(SessionKey.TimeZone));
+            notice.PostDate = notice.PostDate.ToTimeZone(HttpContext.Session.Get<string>(SessionKey.TimeZone));
             if (!HttpContext.Session.TryGetValue("notice" + id, out _))
             {
                 notice.ViewCount += 1;
@@ -124,9 +133,15 @@ namespace Masuit.MyBlogs.Core.Controllers
         /// <param name="page"></param>
         /// <param name="size"></param>
         /// <returns></returns>
-        public ActionResult GetPageData([Range(1, int.MaxValue, ErrorMessage = "页码必须大于0")]int page = 1, [Range(1, 50, ErrorMessage = "页大小必须在0到50之间")]int size = 15)
+        public ActionResult GetPageData([Range(1, int.MaxValue, ErrorMessage = "页码必须大于0")] int page = 1, [Range(1, 50, ErrorMessage = "页大小必须在0到50之间")] int size = 15)
         {
             var list = NoticeService.GetPagesNoTracking(page, size, n => true, n => n.ModifyDate, false);
+            foreach (var n in list.Data)
+            {
+                n.ModifyDate = n.ModifyDate.ToTimeZone(HttpContext.Session.Get<string>(SessionKey.TimeZone));
+                n.PostDate = n.PostDate.ToTimeZone(HttpContext.Session.Get<string>(SessionKey.TimeZone));
+            }
+
             return Ok(list);
         }
 
@@ -138,7 +153,14 @@ namespace Masuit.MyBlogs.Core.Controllers
         [MyAuthorize]
         public ActionResult Get(int id)
         {
-            return ResultData(NoticeService.Get<NoticeDto>(n => n.Id == id));
+            var notice = NoticeService.Get<NoticeDto>(n => n.Id == id);
+            if (notice != null)
+            {
+                notice.ModifyDate = notice.ModifyDate.ToTimeZone(HttpContext.Session.Get<string>(SessionKey.TimeZone));
+                notice.PostDate = notice.PostDate.ToTimeZone(HttpContext.Session.Get<string>(SessionKey.TimeZone));
+            }
+
+            return ResultData(notice);
         }
 
         /// <summary>

+ 32 - 12
src/Masuit.MyBlogs.Core/Controllers/PostController.cs

@@ -75,6 +75,8 @@ namespace Masuit.MyBlogs.Core.Controllers
             var related = PostService.ScoreSearch(1, 11, string.IsNullOrWhiteSpace(post.Keyword + post.Label) ? post.Title : post.Keyword + post.Label);
             related.RemoveAll(p => p.Id == id);
             ViewBag.Related = related;
+            post.ModifyDate = post.ModifyDate.ToTimeZone(HttpContext.Session.Get<string>(SessionKey.TimeZone));
+            post.PostDate = post.PostDate.ToTimeZone(HttpContext.Session.Get<string>(SessionKey.TimeZone));
             if (CurrentUser.IsAdmin)
             {
                 return View("Details_Admin", post);
@@ -102,6 +104,11 @@ namespace Masuit.MyBlogs.Core.Controllers
             var post = await PostService.GetAsync(p => p.Id == id && (p.Status == Status.Published || CurrentUser.IsAdmin)) ?? throw new NotFoundException("文章未找到");
             ViewBag.Primary = post;
             var list = PostHistoryVersionService.GetPages(page, size, v => v.PostId == id, v => v.ModifyDate, false);
+            foreach (var item in list.Data)
+            {
+                item.ModifyDate = item.ModifyDate.ToTimeZone(HttpContext.Session.Get<string>(SessionKey.TimeZone));
+            }
+
             ViewBag.Ads = AdsService.GetByWeightedPrice(AdvertiseType.InPage, post.CategoryId);
             return View(list);
         }
@@ -116,8 +123,10 @@ namespace Masuit.MyBlogs.Core.Controllers
         public async Task<ActionResult> HistoryVersion(int id, int hid)
         {
             var post = await PostHistoryVersionService.GetAsync(v => v.Id == hid) ?? throw new NotFoundException("文章未找到");
-            ViewBag.Next = await PostHistoryVersionService.GetAsync(p => p.PostId == id && p.ModifyDate > post.ModifyDate, p => p.ModifyDate);
-            ViewBag.Prev = await PostHistoryVersionService.GetAsync(p => p.PostId == id && p.ModifyDate < post.ModifyDate, p => p.ModifyDate, false);
+            var next = await PostHistoryVersionService.GetAsync(p => p.PostId == id && p.ModifyDate > post.ModifyDate, p => p.ModifyDate);
+            var prev = await PostHistoryVersionService.GetAsync(p => p.PostId == id && p.ModifyDate < post.ModifyDate, p => p.ModifyDate, false);
+            ViewBag.Next = next;
+            ViewBag.Prev = prev;
             ViewBag.Ads = AdsService.GetByWeightedPrice(AdvertiseType.InPage, post.CategoryId);
             return CurrentUser.IsAdmin ? View("HistoryVersion_Admin", post) : View(post);
         }
@@ -232,7 +241,6 @@ 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());
-            //ViewBag.CategoryId = new SelectList(CategoryService.GetQueryNoTracking(c => c.Status == Status.Available), "Id", "Name", post.CategoryId);
             Post p = post.Mapper<Post>();
             p.IP = ClientIP;
             p.Modifier = p.Author;
@@ -572,13 +580,13 @@ namespace Masuit.MyBlogs.Core.Controllers
             return ResultData(model);
         }
 
-        /// <summary>
-        /// 文章详情
-        /// </summary>
-        /// <param name="id"></param>
-        /// <returns></returns>
-        [MyAuthorize]
-        public ActionResult Read(int id) => ResultData(PostService.GetById(id).Mapper<PostDto>());
+        ///// <summary>
+        ///// 文章详情
+        ///// </summary>
+        ///// <param name="id"></param>
+        ///// <returns></returns>
+        //[MyAuthorize]
+        //public ActionResult Read(int id) => ResultData(PostService.GetById(id).Mapper<PostDto>());
 
         /// <summary>
         /// 获取文章分页
@@ -599,6 +607,12 @@ namespace Masuit.MyBlogs.Core.Controllers
             }
 
             var list = PostService.GetQuery(where).OrderBy($"{nameof(Post.Status)} desc,{nameof(Post.IsFixedTop)} desc,{orderby.GetDisplay()} desc").ToPagedList<Post, PostDataModel>(page, size, MapperConfig);
+            foreach (var item in list.Data)
+            {
+                item.ModifyDate = item.ModifyDate.ToTimeZone(HttpContext.Session.Get<string>(SessionKey.TimeZone));
+                item.PostDate = item.PostDate.ToTimeZone(HttpContext.Session.Get<string>(SessionKey.TimeZone));
+            }
+
             return Ok(list);
         }
 
@@ -619,6 +633,12 @@ namespace Masuit.MyBlogs.Core.Controllers
             }
 
             var pages = PostService.GetQuery(where).OrderByDescending(p => p.IsFixedTop).ThenByDescending(p => p.ModifyDate).ToPagedList<Post, PostDataModel>(page, size, MapperConfig);
+            foreach (var item in pages.Data)
+            {
+                item.ModifyDate = item.ModifyDate.ToTimeZone(HttpContext.Session.Get<string>(SessionKey.TimeZone));
+                item.PostDate = item.PostDate.ToTimeZone(HttpContext.Session.Get<string>(SessionKey.TimeZone));
+            }
+
             return Ok(pages);
         }
 
@@ -763,8 +783,8 @@ namespace Masuit.MyBlogs.Core.Controllers
                 }
 
                 p.Status = Status.Schedule;
-                p.PostDate = timespan.Value;
-                p.ModifyDate = timespan.Value;
+                p.PostDate = timespan.Value.ToUniversalTime();
+                p.ModifyDate = timespan.Value.ToUniversalTime();
                 HangfireHelper.CreateJob(typeof(IHangfireBackJob), nameof(HangfireBackJob.PublishPost), args: p);
                 return ResultData(p.Mapper<PostDto>(), message: $"文章于{timespan.Value:yyyy-MM-dd HH:mm:ss}将会自动发表!");
             }

+ 6 - 0
src/Masuit.MyBlogs.Core/Controllers/SearchController.cs

@@ -7,6 +7,7 @@ using Masuit.MyBlogs.Core.Models.Entity;
 using Masuit.MyBlogs.Core.Models.Enum;
 using Masuit.MyBlogs.Core.Models.ViewModel;
 using Masuit.Tools;
+using Masuit.Tools.Core.Net;
 using Microsoft.AspNetCore.Mvc;
 using System;
 using System.Collections.Generic;
@@ -93,6 +94,11 @@ namespace Masuit.MyBlogs.Core.Controllers
         {
             var where = string.IsNullOrEmpty(search) ? (Expression<Func<SearchDetails, bool>>)(s => true) : s => s.Keywords.Contains(search);
             var pages = SearchDetailsService.GetPages<DateTime, SearchDetailsDto>(page, size, where, s => s.SearchTime, false);
+            foreach (var item in pages.Data)
+            {
+                item.SearchTime = item.SearchTime.ToTimeZone(HttpContext.Session.Get<string>(SessionKey.TimeZone));
+            }
+
             return Ok(pages);
         }
 

+ 6 - 4
src/Masuit.MyBlogs.Core/Controllers/SubscribeController.cs

@@ -2,6 +2,8 @@
 using Masuit.MyBlogs.Core.Extensions;
 using Masuit.MyBlogs.Core.Infrastructure.Services.Interface;
 using Masuit.MyBlogs.Core.Models.Enum;
+using Masuit.MyBlogs.Core.Models.ViewModel;
+using Masuit.Tools.Core.Net;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Extensions.Caching.Memory;
 using System;
@@ -70,7 +72,7 @@ namespace Masuit.MyBlogs.Core.Controllers
                     p.Category.Name
                 },
                 Link = new Uri(scheme + "://" + host + "/" + p.Id),
-                PublishDate = p.ModifyDate.ToUniversalTime(),
+                PublishDate = p.ModifyDate.ToTimeZone(HttpContext.Session.Get<string>(SessionKey.TimeZone)),
                 Title = p.Title,
                 Permalink = scheme + "://" + host + "/" + p.Id,
                 Guid = p.Id.ToString(),
@@ -119,7 +121,7 @@ namespace Masuit.MyBlogs.Core.Controllers
                     p.Category.Name
                 },
                 Link = new Uri(scheme + "://" + host + "/" + p.Id),
-                PublishDate = p.ModifyDate.ToUniversalTime(),
+                PublishDate = p.ModifyDate.ToTimeZone(HttpContext.Session.Get<string>(SessionKey.TimeZone)),
                 Title = p.Title,
                 Permalink = scheme + "://" + host + "/" + p.Id,
                 Guid = p.Id.ToString(),
@@ -168,7 +170,7 @@ namespace Masuit.MyBlogs.Core.Controllers
                     p.Category.Name
                 },
                 Link = new Uri(scheme + "://" + host + "/" + p.Id),
-                PublishDate = p.ModifyDate.ToUniversalTime(),
+                PublishDate = p.ModifyDate.ToTimeZone(HttpContext.Session.Get<string>(SessionKey.TimeZone)),
                 Title = p.Title,
                 Permalink = scheme + "://" + host + "/" + p.Id,
                 Guid = p.Id.ToString(),
@@ -213,7 +215,7 @@ namespace Masuit.MyBlogs.Core.Controllers
                     c.Post.Title
                 },
                 Link = new Uri($"{scheme}://{host}/{post.Id}?cid={c.Id}#comment"),
-                PublishDate = c.CommentDate.ToUniversalTime(),
+                PublishDate = c.CommentDate.ToTimeZone(HttpContext.Session.Get<string>(SessionKey.TimeZone)),
                 Title = c.NickName,
                 Permalink = $"{scheme}://{host}/{post.Id}?cid={c.Id}#comment",
                 Guid = c.Id.ToString(),

+ 21 - 2
src/Masuit.MyBlogs.Core/Extensions/RequestInterceptMiddleware.cs

@@ -2,11 +2,15 @@
 using Masuit.MyBlogs.Core.Common;
 using Masuit.MyBlogs.Core.Configs;
 using Masuit.MyBlogs.Core.Extensions.Hangfire;
+using Masuit.MyBlogs.Core.Models.ViewModel;
 using Masuit.Tools;
 using Masuit.Tools.Core.Net;
 using Microsoft.AspNetCore.Http;
+using Microsoft.EntityFrameworkCore.Internal;
 using Microsoft.Net.Http.Headers;
 using System;
+using System.Collections.Generic;
+using System.Linq;
 using System.Text;
 using System.Text.RegularExpressions;
 using System.Threading.Tasks;
@@ -19,6 +23,7 @@ namespace Masuit.MyBlogs.Core.Extensions
     /// </summary>
     public class RequestInterceptMiddleware
     {
+
         private readonly RequestDelegate _next;
 
         /// <summary>
@@ -79,8 +84,22 @@ namespace Masuit.MyBlogs.Core.Extensions
                 }
             }
 
-            TrackData.RequestLogs.AddOrUpdate(requestUrl, 1, (s, i) => i + 1);
-            await _next.Invoke(context);
+            if (!context.Request.IsRobot())
+            {
+                if (request.QueryString.HasValue)
+                {
+                    var q = request.QueryString.Value.Trim('?');
+                    requestUrl = requestUrl.Replace(q, q.Split('&').Where(s => !s.StartsWith("cid") && !s.StartsWith("uid")).Join("&"));
+                }
+                TrackData.RequestLogs.AddOrUpdate(requestUrl, 1, (s, i) => i + 1);
+            }
+
+            if (string.IsNullOrEmpty(context.Session.Get<string>(SessionKey.TimeZone)))
+            {
+                context.Session.Set(SessionKey.TimeZone, context.Connection.RemoteIpAddress.GetClientTimeZone());
+            }
+
+            await _next(context);
         }
     }
 }

+ 1 - 0
src/Masuit.MyBlogs.Core/Masuit.MyBlogs.Core.csproj

@@ -45,6 +45,7 @@
         <PackageReference Include="PanGu.HighLight" Version="1.0.0" />
         <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="3.1.2" />
         <PackageReference Include="System.Linq.Dynamic.Core" Version="1.2.0" />
+        <PackageReference Include="TimeZoneConverter" Version="3.2.0" />
         <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.56" />

+ 5 - 3
src/Masuit.MyBlogs.Core/Models/ViewModel/PostDataModel.cs

@@ -1,4 +1,6 @@
-namespace Masuit.MyBlogs.Core.Models.ViewModel
+using System;
+
+namespace Masuit.MyBlogs.Core.Models.ViewModel
 {
     /// <summary>
     /// 文章数据模型
@@ -20,12 +22,12 @@
         /// <summary>
         /// 发表时间
         /// </summary>
-        public string PostDate { get; set; }
+        public DateTime PostDate { get; set; }
 
         /// <summary>
         /// 修改时间
         /// </summary>
-        public string ModifyDate { get; set; }
+        public DateTime ModifyDate { get; set; }
 
         /// <summary>
         /// 是否置顶

+ 1 - 0
src/Masuit.MyBlogs.Core/Models/ViewModel/SessionKey.cs

@@ -3,5 +3,6 @@
     public static class SessionKey
     {
         public const string UserInfo = "userinfo";
+        public const string TimeZone = "TimeZone";
     }
 }

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

@@ -200,7 +200,7 @@ namespace Masuit.MyBlogs.Core
                 OnPrepareResponse = context =>
                 {
                     context.Context.Response.Headers[HeaderNames.CacheControl] = "public,no-cache";
-                    context.Context.Response.Headers[HeaderNames.Expires] = DateTime.UtcNow.AddDays(7).ToString("R");
+                    context.Context.Response.Headers[HeaderNames.Expires] = DateTime.Now.AddDays(7).ToString("R");
                 },
                 ContentTypeProvider = new FileExtensionContentTypeProvider(MimeMapper.MimeTypes),
             });

+ 11 - 2
src/Masuit.MyBlogs.Core/Views/Links/Index.cshtml

@@ -16,10 +16,16 @@
     </header>
     <article class="size16 line-height28">
         <p>
-            一、申请友链可以直接在站留言或私信联系站长,内容包括网站名称、链接以及相关说明,为了节约你我的时间,可先做好本站链接并留言,我将尽快答复
+            一、申请友链可以直接在站留言或私信联系站长或<button type="button" class="btn btn-info" onclick="add()">自助上链</button>,内容包括网站名称、链接以及相关说明,为了节约你我的时间,可先做好本站链接并留言,我将尽快答复
         </p>
         <p>
-            二、欢迎申请友情链接,只要是正规站常更新即可,申请首页链接需符合以下几点要求:<br />本站优先招同类原创、内容相近的博客或网站;<br />Baidu和Google有正常收录,百度近期快照,不含有违法国家法律内容的合法网站,TB客,垃圾站不做。<br />如果您的站原创内容少之又少,且长期不更新,申请连接不予受理!
+            二、欢迎申请友情链接,只要是正规站常更新即可,申请首页链接需符合以下几点要求:
+            <br />
+            本站优先招同类原创、内容相近的博客或网站;
+            <br />
+            Baidu和Google有正常收录,百度近期快照,不含有违法国家法律内容的合法网站,TB客,垃圾站不做。
+            <br />
+            如果您的站原创内容少之又少,且长期不更新,申请连接不予受理!
         </p>
         <p>
             友情链接的目的是常来常往,凡是加了友链的朋友,我都会经常访问的,也欢迎你来我的网站参观、留言等。
@@ -39,6 +45,9 @@
         <p>
             PS:链接由于无法访问或您的博客没有发现本站链接等其他原因,将会暂时撤销超链接,恢复请到 <a asp-controller="Msg" asp-action="Index" class="btn btn-info">留言板</a> 通知我,望请谅解,谢谢!
         </p>
+        <p>
+            网站底部的友链列表仅按到访本站次数随机权重抽取30条进行展示,若您的站点上的本站链接长期没有被点击,将影响到您的链接出现在本站底部的概率。
+        </p>
         <p>或者,您也可以尝试<button type="button" class="btn btn-info" onclick="add()">自助通道</button>进行添加友情链接</p>
     </article>
     <section>

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

@@ -1,6 +1,8 @@
 @using System.Diagnostics
 @using Masuit.MyBlogs.Core.Common
 @using Masuit.MyBlogs.Core.Models.Entity
+@using Masuit.MyBlogs.Core.Models.ViewModel
+@using Masuit.Tools.Core.Net
 @model Masuit.MyBlogs.Core.Models.Entity.PostHistoryVersion[]
 @{
     ViewBag.Title = Model[0].Title + "版本对比";
@@ -48,7 +50,7 @@
                                     <div class="row">
                                         <div class="col-sm-7">
                                             <div class="padding-bot10">
-                                                <span class="label label-@colors[new Random().Next() % colors.Length]">@Model[1].Modifier</span>修改于<span class="text-success">@Model[1].ModifyDate.ToString("yyyy-MM-dd HH:mm:ss")</span> | 原分类:<i class="icon-map-pin"></i><a asp-controller="Home" asp-action="Category" asp-route-id="@Model[1].CategoryId" class="label label-@colors[new Random().Next() % colors.Length]">@Model[1].Category.Name</a>
+                                                <span class="label label-@colors[new Random().Next() % colors.Length]">@Model[1].Modifier</span>修改于<span class="text-success">@Model[1].ModifyDate.ToTimeZoneF(Context.Session.Get<string>(SessionKey.TimeZone))</span> | 原分类:<i class="icon-map-pin"></i><a asp-controller="Home" asp-action="Category" asp-route-id="@Model[1].CategoryId" class="label label-@colors[new Random().Next() % colors.Length]">@Model[1].Category.Name</a>
                                                 @if (Model[1].Seminar.Any())
                                                 {
                                                     <span> | 原所属专题:</span>
@@ -134,7 +136,7 @@
                                     <div class="row">
                                         <div class="col-sm-7">
                                             <div class="padding-bot10">
-                                                <span class="label label-@colors[new Random().Next() % colors.Length]">@Model[2].Modifier</span>修改于<span class="text-success">@Model[2].ModifyDate.ToString("yyyy-MM-dd HH:mm:ss")</span> | 原分类:<i class="icon-map-pin"></i><a asp-controller="Home" asp-action="Category" asp-route-id="@Model[2].CategoryId" class="label label-@colors[new Random().Next() % colors.Length]">@Model[2].Category.Name</a>
+                                                <span class="label label-@colors[new Random().Next() % colors.Length]">@Model[2].Modifier</span>修改于<span class="text-success">@Model[2].ModifyDate.ToTimeZoneF(Context.Session.Get<string>(SessionKey.TimeZone))</span> | 原分类:<i class="icon-map-pin"></i><a asp-controller="Home" asp-action="Category" asp-route-id="@Model[2].CategoryId" class="label label-@colors[new Random().Next() % colors.Length]">@Model[2].Category.Name</a>
                                                 @if (Model[2].Seminar.Any())
                                                 {
                                                     <span> | 原所属专题:</span>

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

@@ -1,10 +1,11 @@
 @using System.Diagnostics
 @using Masuit.MyBlogs.Core.Common
 @using Masuit.MyBlogs.Core.Models.Entity
+@using Masuit.MyBlogs.Core.Models.ViewModel
 @using Masuit.Tools.Core.Net
 @model Masuit.MyBlogs.Core.Models.Entity.PostHistoryVersion
 @{
-    ViewBag.Title = Model.Post.Title + "于" + Model.ModifyDate.ToString("yyyy-MM-dd HH:mm:ss") + "的历史版本:" + Model.Title;
+    ViewBag.Title = Model.Post.Title + "于" + Model.ModifyDate.ToTimeZoneF(Context.Session.Get<string>(SessionKey.TimeZone)) + "的历史版本:" + Model.Title;
     Layout = "~/Views/Shared/_Layout.cshtml";
     string[] colors = { "success", "info", "primary", "warning", "danger", "default", "primary" };
     Advertisement ad = ViewBag.Ads;
@@ -46,7 +47,7 @@
                             <div class="row">
                                 <div class="col-sm-7">
                                     <div class="padding-bot10">
-                                        <span class="label label-@colors[new Random().Next() % colors.Length]">@Model.Modifier</span>修改于<span class="text-success">@Model.ModifyDate.ToString("yyyy-MM-dd HH:mm:ss")</span> |
+                                        <span class="label label-@colors[new Random().Next() % colors.Length]">@Model.Modifier</span>修改于<span class="text-success">@Model.ModifyDate.ToTimeZoneF(Context.Session.Get<string>(SessionKey.TimeZone))</span> |
                                         原分类:<i class="icon-map-pin"></i><a asp-controller="Home" asp-action="Category" asp-route-id="@Model.CategoryId" class="label label-@colors[new Random().Next() % colors.Length]">@Model.Category.Name</a>
                                         @if (Model.Seminar.Any())
                                         {

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

@@ -1,8 +1,11 @@
 @using System.Diagnostics
+@using Masuit.MyBlogs.Core.Common
 @using Masuit.MyBlogs.Core.Models.Entity
+@using Masuit.MyBlogs.Core.Models.ViewModel
+@using Masuit.Tools.Core.Net
 @model Masuit.MyBlogs.Core.Models.Entity.PostHistoryVersion
 @{
-    ViewBag.Title = Model.Post.Title + "于" + Model.ModifyDate.ToString("yyyy-MM-dd HH:mm:ss") + "的历史版本:" + Model.Title;
+    ViewBag.Title = Model.Post.Title + "于" + Model.ModifyDate.ToTimeZoneF(Context.Session.Get<string>(SessionKey.TimeZone)) + "的历史版本:" + Model.Title;
     Layout = "~/Views/Shared/_Layout.cshtml";
     string[] colors = { "success", "info", "primary", "warning", "danger", "default", "primary" };
     Advertisement ad = ViewBag.Ads;
@@ -44,7 +47,7 @@
                             <div class="row">
                                 <div class="col-sm-7">
                                     <div class="padding-bot10">
-                                        <span class="label label-@colors[new Random().Next() % colors.Length]">@Model.Modifier</span>修改于<span class="text-success">@Model.ModifyDate.ToString("yyyy-MM-dd HH:mm:ss")</span> |
+                                        <span class="label label-@colors[new Random().Next() % colors.Length]">@Model.Modifier</span>修改于<span class="text-success">@Model.ModifyDate.ToTimeZoneF(Context.Session.Get<string>(SessionKey.TimeZone))</span> |
                                         原分类:<i class="icon-map-pin"></i><a asp-controller="Home" asp-action="Category" asp-route-id="@Model.CategoryId" class="label label-@colors[new Random().Next() % colors.Length]">@Model.Category.Name</a>
                                         @if (Model.Seminar.Any())
                                         {

+ 3 - 1
src/Masuit.MyBlogs.Core/Views/Search/Search.cshtml

@@ -1,8 +1,10 @@
 @using System.Web
+@using Masuit.MyBlogs.Core.Common
 @using Masuit.MyBlogs.Core.Models.DTO
 @using Masuit.MyBlogs.Core.Models.Entity
 @using Masuit.MyBlogs.Core.Models.ViewModel
 @using Masuit.Tools
+@using Masuit.Tools.Core.Net
 @using Microsoft.AspNetCore.Mvc.Rendering
 @model SearchResult<Masuit.MyBlogs.Core.Models.DTO.PostDto>
 @{
@@ -66,7 +68,7 @@
                                 </a>
                                 <div>
                                     作者:
-                                    <label class="label label-info">@Html.Raw(p.Author)</label> | 发表时间:@(p.ModifyDate.ToString("yyyy-MM-dd HH:mm")) | 分类:<a asp-controller="Home" asp-action="Category" asp-route-id="@p.CategoryId">@p.CategoryName</a>
+                                    <label class="label label-info">@Html.Raw(p.Author)</label> | 发表时间:@(p.ModifyDate.ToTimeZoneF(Context.Session.Get<string>(SessionKey.TimeZone))) | 分类:<a asp-controller="Home" asp-action="Category" asp-route-id="@p.CategoryId">@p.CategoryName</a>
                                 </div>
                                 <p class="size14">@Html.Raw(p.Content)</p>
                                 <div class="row">