Bläddra i källkod

插广告优化

懒得勤快 5 år sedan
förälder
incheckning
8ec21d4709

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

@@ -52,7 +52,7 @@
                     var rnd = new Random().Next(Model.Results.Count > 2 ? 2 : 1, Model.Results.Count);
                     for (var i = 0; i < Model.Results.Count; i++)
                     {
-                        if (rnd == i && ad != null)
+                        if (rnd > 2 && rnd == i && ad != null)
                         {
                             await Html.RenderPartialAsync("_ArticleListAdvertisement", ad);
                         }

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

@@ -68,10 +68,10 @@
     <div class="wrapper-content  animated bounceInUp blog">
         @if (Model.Data.Any())
         {
-            var rnd = new Random().Next(2, Model.CurrentCount);
+            var rnd = new Random().Next(Model.CurrentCount > 2 ? 2 : 0, Model.CurrentCount);
             for (var i = 0; i < Model.CurrentCount; i++)
             {
-                if (rnd == i && ad != null)
+                if (rnd > 2 && rnd == i && ad != null)
                 {
                     await Html.RenderPartialAsync("_ArticleListAdvertisement", ad);
                 }

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

@@ -8,7 +8,7 @@
             var rnd = new Random().Next(Model.Posts.CurrentCount > 2 ? 2 : 0, Model.Posts.CurrentCount);
             for (var index = 0; index < Model.Posts.CurrentCount; index++)
             {
-                if (rnd == index && Model.ListAdvertisement != null)
+                if (rnd > 2 && rnd == index && Model.ListAdvertisement != null)
                 {
                     await Html.RenderPartialAsync("_ArticleListAdvertisement", Model.ListAdvertisement);
                 }