浏览代码

文章详情页优化

懒得勤快 5 年之前
父节点
当前提交
0817fcb53a

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

@@ -949,6 +949,20 @@ namespace Masuit.MyBlogs.Core.Controllers
             return ResultData(null, false, "文章不存在");
             return ResultData(null, false, "文章不存在");
         }
         }
 
 
+        /// <summary>
+        /// 刷新文章
+        /// </summary>
+        /// <param name="id">文章id</param>
+        /// <returns></returns>
+        [Authority]
+        public ActionResult Refresh(int id)
+        {
+            var post = PostService.GetById(id) ?? throw new NotFoundException("文章未找到");
+            post.ModifyDate = DateTime.Now;
+            PostService.SaveChanges();
+            return RedirectToAction("Details", new { id });
+        }
+
         #endregion
         #endregion
     }
     }
 }
 }

+ 2 - 2
src/Masuit.MyBlogs.Core/Masuit.MyBlogs.Core.csproj

@@ -53,7 +53,7 @@
     <PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="7.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.Microsoft.Extensions.Caching.Memory" Version="2.0.0-beta-1629" />
     <PackageReference Include="CacheManager.Serialization.Json" Version="2.0.0-beta-1629" />
     <PackageReference Include="CacheManager.Serialization.Json" Version="2.0.0-beta-1629" />
-    <PackageReference Include="CSRedisCore" Version="3.2.0" />
+    <PackageReference Include="CSRedisCore" Version="3.2.1" />
     <PackageReference Include="DocxToHtml" Version="1.0.4" />
     <PackageReference Include="DocxToHtml" Version="1.0.4" />
     <PackageReference Include="EFSecondLevelCache.Core" Version="2.9.0" />
     <PackageReference Include="EFSecondLevelCache.Core" Version="2.9.0" />
     <PackageReference Include="Hangfire" Version="1.7.8" />
     <PackageReference Include="Hangfire" Version="1.7.8" />
@@ -69,7 +69,7 @@
     <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="3.1.0" />
     <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="3.1.0" />
     <PackageReference Include="System.Linq.Dynamic.Core" Version="1.0.19" />
     <PackageReference Include="System.Linq.Dynamic.Core" Version="1.0.19" />
     <PackageReference Include="WilderMinds.RssSyndication" Version="1.6.0" />
     <PackageReference Include="WilderMinds.RssSyndication" Version="1.6.0" />
-    <PackageReference Include="WinInsider.System.Net.Http.Formatting" Version="1.0.13" />
+    <PackageReference Include="WinInsider.System.Net.Http.Formatting" Version="1.0.14" />
   </ItemGroup>
   </ItemGroup>
 
 
   <ItemGroup>
   <ItemGroup>

+ 7 - 0
src/Masuit.MyBlogs.Core/Masuit.MyBlogs.Core.xml

@@ -1477,6 +1477,13 @@
             <param name="id">文章id</param>
             <param name="id">文章id</param>
             <returns></returns>
             <returns></returns>
         </member>
         </member>
+        <member name="M:Masuit.MyBlogs.Core.Controllers.PostController.Refresh(System.Int32)">
+            <summary>
+            刷新文章
+            </summary>
+            <param name="id">文章id</param>
+            <returns></returns>
+        </member>
         <member name="T:Masuit.MyBlogs.Core.Controllers.SearchController">
         <member name="T:Masuit.MyBlogs.Core.Controllers.SearchController">
             <summary>
             <summary>
             站内搜索
             站内搜索

+ 30 - 67
src/Masuit.MyBlogs.Core/Views/Post/Details_Admin.cshtml

@@ -15,19 +15,9 @@
     string cid = string.IsNullOrEmpty(Context.Request.Query["cid"]) ? "0" : Context.Request.Query["cid"].ToString();
     string cid = string.IsNullOrEmpty(Context.Request.Query["cid"]) ? "0" : Context.Request.Query["cid"].ToString();
     Advertisement ad = ViewBag.Ads;
     Advertisement ad = ViewBag.Ads;
 }
 }
-<style>
-    #gooey-h {
-        position: fixed;
-        bottom: 250px;
-        right: 0;
-        z-index: 3;
-    }
-</style>
 <link href="~/Assets/layui/css/layui.min.css" rel="stylesheet" />
 <link href="~/Assets/layui/css/layui.min.css" rel="stylesheet" />
-<link href="~/Assets/gooey/gooey.min.css" rel="stylesheet" />
 <link href="~/Assets/jquery.tocify/jquery.tocify.min.css" rel="stylesheet" />
 <link href="~/Assets/jquery.tocify/jquery.tocify.min.css" rel="stylesheet" />
 <script src="~/Assets/layui/layui.all.js"></script>
 <script src="~/Assets/layui/layui.all.js"></script>
-<script src="~/Assets/gooey/gooey.min.js"></script>
 <link href="~/Assets/UEditor/third-party/SyntaxHighlighter/styles/shCore.min.css" rel="stylesheet" />
 <link href="~/Assets/UEditor/third-party/SyntaxHighlighter/styles/shCore.min.css" rel="stylesheet" />
 <link href="~/Assets/highlight/css/highlight.css" rel="stylesheet" />
 <link href="~/Assets/highlight/css/highlight.css" rel="stylesheet" />
 <link href="~/Assets/share/share.css" rel="stylesheet" />
 <link href="~/Assets/share/share.css" rel="stylesheet" />
@@ -66,19 +56,19 @@
                                 @{
                                 @{
                                     if (!string.IsNullOrEmpty(Model.Label))
                                     if (!string.IsNullOrEmpty(Model.Label))
                                     {
                                     {
-                                        <div class="pull-right margin-right20">
-                                            <div>
-                                                @foreach (string s in Model.Label.Split(',', ',', ' '))
+                                    <div class="pull-right margin-right20">
+                                        <div>
+                                            @foreach (string s in Model.Label.Split(',', ',', ' '))
                                                 {
                                                 {
                                                     if (!string.IsNullOrEmpty(s))
                                                     if (!string.IsNullOrEmpty(s))
                                                     {
                                                     {
-                                                        <a asp-controller="Home" asp-action="Tag" asp-route-id="@s">
-                                                            <span class="label label-@colors[new Random().Next() % colors.Length]">@s</span>
-                                                        </a>
+                                            <a asp-controller="Home" asp-action="Tag" asp-route-id="@s">
+                                                <span class="label label-@colors[new Random().Next() % colors.Length]">@s</span>
+                                            </a>
                                                     }
                                                     }
                                                 }
                                                 }
-                                            </div>
                                         </div>
                                         </div>
+                                    </div>
                                     }
                                     }
                                 }
                                 }
                             </div>
                             </div>
@@ -87,15 +77,28 @@
                                     分类:<i class="icon-map-pin"></i>@Html.ActionLink(Model.Category.Name, "Category", "Home", new { id = Model.CategoryId }, new { @class = "label label-" + colors[new Random().Next() % colors.Length] }) | 评论总数:<span class="text-danger">@Model.Comment.Count</span>条 | 热度:<span class="text-danger">@Model.TotalViewCount</span>℃ | 状态:@Model.Status.GetDisplay()
                                     分类:<i class="icon-map-pin"></i>@Html.ActionLink(Model.Category.Name, "Category", "Home", new { id = Model.CategoryId }, new { @class = "label label-" + colors[new Random().Next() % colors.Length] }) | 评论总数:<span class="text-danger">@Model.Comment.Count</span>条 | 热度:<span class="text-danger">@Model.TotalViewCount</span>℃ | 状态:@Model.Status.GetDisplay()
                                     @if (Model.Seminar.Any())
                                     @if (Model.Seminar.Any())
                                     {
                                     {
-                                        <span> | 所属专题:</span>
+                                    <span> | 所属专题:</span>
                                         var seminars = Model.Seminar;
                                         var seminars = Model.Seminar;
                                         foreach (var s in seminars)
                                         foreach (var s in seminars)
                                         {
                                         {
-                                            @Html.ActionLink(s.Seminar.Title, "Index", "Seminar", new { id = s.SeminarId }, new { @class = "label label-" + colors[new Random().Next() % colors.Length] })<text> </text>
+                                    @Html.ActionLink(s.Seminar.Title, "Index", "Seminar", new { id = s.SeminarId }, new { @class = "label label-" + colors[new Random().Next() % colors.Length] })<text> </text>
                                         }
                                         }
                                     }
                                     }
                                     <div class="pull-right margin-right20">
                                     <div class="pull-right margin-right20">
-                                        @Html.ActionLink("我要编辑", "PushMerge", "Post", new { id = Model.Id }, new { @class = "btn btn-danger" })
+                                        <div class="btn-group">
+                                            @Html.ActionLink("刷新", "Refresh", "Post", new { id = Model.Id }, new { @class = "btn btn-info" })
+                                            @if(Model.IsFixedTop) {
+                                            <button class="btn btn-success" id="pin">取消置顶</button>
+                                            }else {
+                                            <button class="btn btn-success" id="pin">置顶</button>
+                                            }
+                                            @if (Model.Status == Status.Pending)
+                                            {
+                                            <button class="btn btn-primary" id="pass">通过</button>
+                                            }
+                                            <a asp-controller="Dashboard" asp-action="Index" asp-fragment="/post/[email protected]" class="btn btn-primary" target="_blank">修改</a>
+                                            <button class="btn btn-danger" id="del">删除</button>
+                                        </div>
                                     </div>
                                     </div>
                                 </div>
                                 </div>
                             </div>
                             </div>
@@ -104,9 +107,9 @@
                             @Html.Raw(Model.Content)
                             @Html.Raw(Model.Content)
                             @if (!string.IsNullOrEmpty(Model.ProtectContent))
                             @if (!string.IsNullOrEmpty(Model.ProtectContent))
                             {
                             {
-                                <div class="row protected">
-                                    @Html.Raw(Model.ProtectContent)
-                                </div>
+                            <div class="row protected">
+                                @Html.Raw(Model.ProtectContent)
+                            </div>
                             }
                             }
                         </article>
                         </article>
                         <h3>分享到:</h3>
                         <h3>分享到:</h3>
@@ -297,23 +300,6 @@
         </form>
         </form>
     </div>
     </div>
 </div>
 </div>
-<nav id="gooey-h" style="max-height: 100px;">
-    <input type="checkbox" class="menu-open" name="menu-open2" id="menu-open2" />
-    <label class="open-button" for="menu-open2">
-        <span class="burger burger-1"></span>
-        <span class="burger burger-2"></span>
-        <span class="burger burger-3"></span>
-    </label>
-    <a class="gooey-menu-item" id="pin"> <i class="icon icon-pushpin"></i></a>
-    @{
-        if (Model.Status == Status.Pending)
-        {
-            <a class="gooey-menu-item" id="pass"> <i class="icon icon-checkmark"></i></a>
-        }
-    }
-    <a asp-controller="Dashboard" asp-action="Index" asp-fragment="/post/[email protected]" class="gooey-menu-item" target="_blank"> <i class="icon icon-pencil"></i></a>
-    <a class="gooey-menu-item" id="del"> <i class="icon icon-bin"></i></a>
-</nav>
 <script src="https://cdn.bootcss.com/jqueryui/1.12.1/jquery-ui.min.js"></script>
 <script src="https://cdn.bootcss.com/jqueryui/1.12.1/jquery-ui.min.js"></script>
 <script src="~/Assets/UEditor/third-party/SyntaxHighlighter/scripts/shCore.min.js"></script>
 <script src="~/Assets/UEditor/third-party/SyntaxHighlighter/scripts/shCore.min.js"></script>
 <script src="~/Assets/UEditor/third-party/SyntaxHighlighter/scripts/bundle.min.js"></script>
 <script src="~/Assets/UEditor/third-party/SyntaxHighlighter/scripts/bundle.min.js"></script>
@@ -321,8 +307,7 @@
 <script src="~/Scripts/global/article.js"></script>
 <script src="~/Scripts/global/article.js"></script>
 <script src="~/Assets/highlight/js/highlight.js"></script>
 <script src="~/Assets/highlight/js/highlight.js"></script>
 <script>
 <script>
-
-	function getcomments() {
+    function getcomments() {
 		$.post("/comment/getcomments", {
 		$.post("/comment/getcomments", {
 			id: $("#postId").val(),
 			id: $("#postId").val(),
 			page: 1,
 			page: 1,
@@ -360,28 +345,6 @@
 				});
 				});
 			}
 			}
 		});
 		});
-		$("#gooey-h").gooeymenu({
-			bgColor: "#681ddf",
-			contentColor: "white",
-			style: "circle",
-			horizontal: {
-				menuItemPosition: "glue"
-			},
-			vertical: {
-				menuItemPosition: "spaced",
-				direction: "up"
-			},
-			circle: {
-				radius: 85
-			},
-			margin: "small",
-			size: 80,
-			bounce: true,
-			bounceLength: "small",
-			transitionStep: 100,
-			hover: "#2d1d89"
-		});
-		$("#gooey-h").insertAfter($("body"));
 		$("#del").on("click", function (e) {
 		$("#del").on("click", function (e) {
 			swal({
 			swal({
 				title: "确认删除这篇文章吗?",
 				title: "确认删除这篇文章吗?",
@@ -413,17 +376,17 @@
 					text: data.Message,
 					text: data.Message,
 					time: 4
 					time: 4
 				});
 				});
+                location.reload();
 			});
 			});
 		});
 		});
 		$("#pin").on("click", function (e) {
 		$("#pin").on("click", function (e) {
-			$.post("/post/Fixtop", {
-				id: @Model.Id
-			}, function (data) {
+			$.post("/post/Fixtop", { id: @Model.Id }, function (data) {
 				window.notie.alert({
 				window.notie.alert({
 					type: 1,
 					type: 1,
 					text: data.Message,
 					text: data.Message,
 					time: 4
 					time: 4
 				});
 				});
+                location.reload();
 			});
 			});
 		});
 		});
 		loadingDone();
 		loadingDone();

文件差异内容过多而无法显示
+ 0 - 0
src/Masuit.MyBlogs.Core/wwwroot/Assets/gooey/gooey.min.css


+ 0 - 15
src/Masuit.MyBlogs.Core/wwwroot/Assets/gooey/gooey.min.js

@@ -1,15 +0,0 @@
-(function(g){g.gooeymenu=function(h,q){var k=g(h);k.addClass("navimenu");var b=this,a=b.options=g.extend({},g.gooeymenu.defaults,q);b.els={item:k.find(".gooey-menu-item"),checkbox:k.find(".menu-open"),button:k.find(".open-button")};b.methods={setup:function(){var d={small:1.4,medium:1.8,large:2.1},f={small:1.3,medium:1.6,large:2.1},c;for(c in d)a.margin===c?a.margin=d[c]:null;for(var e in f)a.bounceLength===e?a.bounceLength=f[e]:null;b.methods.responsiveStyles();b.els.item.hover(function(){a.currentBg=
-b.els.item.css("background-color");g(this).css("background-color",a.hover)},function(){g(this).css("background-color",a.currentBg)});!0===a.bounce&&b.methods.bounce()},setEvents:function(){["open","close"].forEach(function(d,b){k.on(d,function(){a[d]&&a[d].apply(this,arguments)})})},bounce:function(){if(!0===a.bounce){var d=b.els.item.css("transition-timing-function");b.els.checkbox.on("change",function(){g(this).is(":checked")?b.els.item.css({"transition-timing-function":"cubic-bezier(0.8, 0.84, 0.44,  "+
-a.bounceLength+")","-o-transition-timing-function":"cubic-bezier(0.8, 0.84, 0.44,  "+a.bounceLength+")","-moz-transition-timing-function":"cubic-bezier(0.8, 0.84, 0.44,  "+a.bounceLength+")","-webkit-transition-timing-function":"cubic-bezier(0.8, 0.84, 0.44,  "+a.bounceLength+")","-ms-transition-timing-function":"cubic-bezier(0.8, 0.84, 0.44,  "+a.bounceLength+")"}):b.els.item.css({"transition-timing-function":d,"-moz-transition-timing-function":d,"-o-transition-timing-function":d,"-webkit-transition-timing-function":d})})}},
-circle:function(){k.trigger("open");var d,f,c,e,m,h,n,r=b.els.item.length,l=a.transitionStep,q=Math.PI,t=360/r,p=t=360/r;f=a.circle.radius;b.els.item.each(function(){b.els.checkbox.is(":checked")?(d=q*p/180,c=Math.abs(Math.cos(d)),e=f*c,m=Math.sqrt(f*f-e*e),h=b.methods.periodCalc(p).x,n=b.methods.periodCalc(p).y,g(this).css({transform:"translate3d("+h+e+"px,"+n+m+"px,0)","-o-transform":"translate3d("+h+e+"px,"+n+m+"px,0)","-webkit-transform":"translate3d("+h+e+"px,"+n+m+"px,0)","-moz-transform":"translate3d("+
-h+e+"px,"+n+m+"px,0)","-ms-transform":"translate3d("+h+e+"px,"+n+m+"px,0)","transition-duration":l+"ms","-o-transition-duration":l+"ms","-webkit-transition-duration":l+"ms","-moz-transition-duration":l+"ms"}),p+=t,l+=a.transitionStep):(b.els.item.css({transform:"translate3d(0, 0, 0)","-moz-transform":"translate3d(0, 0, 0)","-webkit-transform":"translate3d(0, 0, 0)","-ms-transform":"translate3d(0, 0, 0)","-o-transform":"translate3d(0, 0, 0)"}),p=360/r,l=a.transitionStep,k.trigger("close"))})},periodCalc:function(a){return{x:90>
-a||270<a?"":"-",y:180<a?"":"-"}},linear:function(d){k.trigger("open");var f="horizontal"===a.style?a.horizontal.menuItemPosition:a.vertical.menuItemPosition,c=d[f].init,e=a.transitionStep;b.els.item.each(function(){b.els.checkbox.is(":checked")?"horizontal"===a.style?(g(this).css({transform:"translate3d("+c+"px, 0, 0)","-ms-transform":"translate3d("+c+"px, 0, 0)","-o-transform":"translate3d("+c+"px, 0, 0)","-moz-transform":"translate3d("+c+"px, 0, 0)","-webkit-transform":"translate3d("+c+"px, 0, 0)",
-"transition-duration":e+"ms","-o-transition-duration":e+"ms","-webkit-transition-duration":e+"ms","-moz-transition-duration":e+"ms"}),c+=d[f].init,e+=a.transitionStep):"vertical"===a.style&&(g(this).css({"transition-duration":e+"ms","-moz-transition-duration":e+"ms","-o-transition-duration":e+"ms","-webkit-transition-duration":e+"ms"}),"down"===a.vertical.direction?g(this).css({transform:"translate3d(0, "+c+"px, 0)","-moz-transform":"translate3d(0, "+c+"px, 0)","-o-transform":"translate3d(0, "+c+
-"px, 0)","-webkit-transform":"translate3d(0, "+c+"px, 0)","-ms-transform":"translate3d(0, "+c+"px, 0)"}):"up"===a.vertical.direction&&g(this).css({transform:"translate3d(0,-"+c+"px, 0)","-moz-transform":"translate3d(0,-"+c+"px, 0)","-webkit-transform":"translate3d(0,-"+c+"px, 0)","-o-transform":"translate3d(0,-"+c+"px, 0)","-ms-transform":"translate3d(0,-"+c+"px, 0)"}),c+=d[f].init,e+=a.transitionStep):(b.els.item.css({transform:"translate3d(0, 0, 0)","-moz-transform":"translate3d(0, 0, 0)","-webkit-transform":"translate3d(0, 0, 0)",
-"-ms-transform":"translate3d(0, 0, 0)","-o-transform":"translate3d(0, 0, 0)"}),c=d[f].init,e=a.transitionStep,k.trigger("close"))})},translate:function(){var d={glue:{init:a.size},spaced:{init:a.size*a.margin}};b.els.checkbox.on("change",function(){b._callbacks[a.style](d)})},createOn:function(a,b,c,e){b=document.createElementNS("http://www.w3.org/2000/svg",b);for(var g in c)c.hasOwnProperty(g)&&b.setAttribute(g,c[g]);e&&b.appendChild(document.createTextNode(e));return a.appendChild(b)},responsiveStyles:function(){var d=
-0<window.innerWidth?window.innerWidth:screen.width;320<=d&&480>=d?(a.size/=1.4,a.circle.radius/=1.2):480<d&&768>=d?a.size/=1.2:780<d&&1024>=d&&(a.circle.radius/=1.2,a.size/=1.1);b.els.item.css({width:a.size+"px",height:a.size+"px",color:a.contentColor,"background-color":a.bgColor,"line-height":a.size+"px"});b.els.button.css({width:a.size+"px",height:a.size+"px","background-color":a.bgColor,"line-height":a.size+"px"});k.find(".burger").css({"font-size":".8em",width:a.size/2+"px",height:"3px",left:a.size/
-4+"px"})}};b._callbacks={vertical:b.methods.linear,horizontal:b.methods.linear,circle:b.methods.circle};b.init=function(){var a=document.createElementNS("http://www.w3.org/2000/svg","svg"),f=g(".navimenu").index(k);a.setAttribute("id","gooeySVG"+f);a.setAttribute("class","gooeySVG");k.append(a);a=document.getElementById("gooeySVG"+f);b.methods.createOn(a,"defs",{id:"defs"+f});a=document.getElementById("defs"+f);b.methods.createOn(a,"filter",{id:"goo-shadow"+f,overflow:"hidden"});var c=document.getElementById("goo-shadow"+
-f);b.methods.createOn(c,"feGaussianBlur",{"in":"SourceGraphic",result:"blur",stdDeviation:"10"});b.methods.createOn(c,"feColorMatrix",{"in":"blur",mode:"matrix",values:"1 0 0 0 0  0 1 0 0 0  0 0 1 0 0  0 0 0 18 -8",result:"goo"});b.methods.createOn(c,"feGaussianBlur",{"in":"goo",stdDeviation:"2",result:"shadow"});b.methods.createOn(c,"feColorMatrix",{"in":"shadow",mode:"matrix",values:"0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0 0",result:"shadow"});b.methods.createOn(c,"feOffset",{"in":"shadow",dx:"1",
-dy:"1",result:"shadow"});b.methods.createOn(c,"feComposite",{in2:"shadow","in":"goo",result:"goo"});b.methods.createOn(c,"feComposite",{in2:"goo","in":"SourceGraphic",result:"mix"});b.methods.createOn(a,"filter",{id:"goo"+f});a=document.getElementById("goo"+f);b.methods.createOn(a,"feGaussianBlur",{"in":"SourceGraphic",result:"blur",stdDeviation:"10"});b.methods.createOn(a,"feColorMatrix",{"in":"blur",mode:"matrix",values:"1 0 0 0 0  0 1 0 0 0  0 0 1 0 0  0 0 0 18 -7",result:"goo"});b.methods.createOn(a,
-"feComposite",{in2:"goo","in":"SourceGraphic",result:"mix"});k.css({"-webkit-filter":"url('#goo-shadow"+f+"')",filter:"url('#goo-shadow"+f+"')","-ms-filter":"url('#goo-shadow"+f+"')","-o-filter":"url('#goo-shadow"+f+"')"});b.methods.setEvents();b.methods.setup();b.methods.translate.apply(this,arguments)};b.init()};g.gooeymenu.defaults={style:"horizontal",size:70,margin:"medium",bgColor:"steelblue",contentColor:"white",transitionStep:100,bounce:!1,bounceLength:"medium",hover:"white",circle:{radius:80},
-horizontal:{menuItemPosition:"glue"},vertical:{menuItemPosition:"spaced",direction:"up"},open:function(){},close:function(){}};g.fn.gooeymenu=function(h){void 0===h&&(h={});if(h&&"object"===typeof h)return this.each(function(){new g.gooeymenu(this,h)})}})(jQuery);

部分文件因为文件数量过多而无法显示