Explorar el Código

新闻详情增加上一页下一页

master
zhuoyang.xing hace 2 meses
padre
commit
e41cacd044

+ 10
- 0
templates/articleDetails.ftl Ver fichero

@@ -39,6 +39,16 @@
39 39
             <div class="title">${article.title}</div>
40 40
         </div>
41 41
         ${article.content}
42
+        <#if otherNews??>
43
+        <div class="detail_footer">
44
+            <#if otherNews?keys?seq_contains("upNew")>
45
+                <a href="./${otherNews.upNew.uuid}.html">上一篇:${otherNews.upNew.title}</a>
46
+            </#if>
47
+            <#if otherNews?keys?seq_contains("nextNew")>
48
+                <a href="./${otherNews.nextNew.uuid}.html">下一篇:${otherNews.nextNew.title}</a>
49
+            </#if>
50
+        </div>
51
+        </#if>
42 52
     </div>
43 53
 </div>
44 54
 <#include "./detail/footer.ftl" parse=true encoding="utf-8">

+ 40
- 12
templates/joinList.ftl Ver fichero

@@ -32,20 +32,48 @@
32 32
             </#list>
33 33
         </div>
34 34
     </div>
35
-    <div class="pages">
36
-        <a class="item prev disableBtn iconfont icon-jiantou" href="./news_012.html#newsPos"></a>
37
-        <div class="pageList">
38
-            <a class="item pageItem" href="./news_011.html#newsPos">1</a>
39
-            <a class="item pageItem" href="./news_012.html#newsPos">2</a>
40
-            <a class="item pageItem curPageItem" href="./news_013.html#newsPos">3</a>
41
-            <a class="item pageItem" href="./news_014.html#newsPos">4</a>
42
-            <a class="item pageItem" href="./news_015.html#newsPos">5</a>
35
+    <div class="news_paging">
36
+        <#-- 判断是否有上一页-->
37
+        <#if (currentPage > 1)>
38
+            <a id="previousPage" href="joinList${currentPage-1}.html" class="previousPage">
39
+                <span class="icon iconfont icon-jiantou"></span>
40
+            </a>
41
+        </#if>
42
+        <div id="paging" style="display: flex;align-items: center;">
43
+            <#--                当前页大于5,显示1和... -->
44
+            <#if (currentPage > 5)>
45
+                <#assign start=currentPage-2>
46
+                <a class="pageNum" href="joinList1.html">1</a>
47
+                <a class="pageNum pageNums">...</a>
48
+            <#else >
49
+                <#assign start=1>
50
+            </#if>
51
+            <#--                显示当前页附近的页-->
52
+            <#assign end=currentPage+2>
53
+            <#if (end>totalPage)>
54
+                <#assign end = totalPage>
55
+            </#if>
56
+            <#list start..end as index>
57
+                <#if index == currentPage>
58
+                    <a class="pageNum pageNumActive" href="joinList${index}.html">${index}</a>
59
+                <#else>
60
+                    <a class="pageNum" href="joinList${index}.html">${index}</a>
61
+                </#if>
62
+            </#list>
63
+            <#--                到最后一页相差超过5,显示...-->
64
+            <#if ((totalPage-currentPage)>5)>
65
+                <a class="pageNum pageNums">...</a>
66
+                <a class="pageNum" href="joinList${totalPage}.html">${totalPage}</a>
67
+            </#if>
43 68
         </div>
44
-        <span class="item space">...</span>
45
-        <a class="item last" href="./news_0135.html#newsPos">35</a>
46
-        <a class="item next iconfont icon-jiantou" href="./news_014.html#newsPos"></a>
69
+        <#--                判断是否有下一页-->
70
+        <#if (currentPage < totalPage)>
71
+            <a id="nextPage" href="joinList${currentPage+1}.html" class="nextPage">
72
+                <span class="icon iconfont icon-jiantou"></span>
73
+            </a>
74
+        </#if>
47 75
     </div>
48
-    <a class="pageNext mTxt">加载更多<span class="iconfont icon-jiantou"></span></a></div>
76
+</div>
49 77
 <#include "./footer.ftl" parse=true encoding="utf-8">
50 78
 <script defer="defer" src="./runtime/index.js"></script>
51 79
 <script defer="defer" src="./vendor/index.js"></script>

+ 15
- 1
webstudio-modules/webstudio-modules-staticize/src/main/java/com/webstudio/staticize/controller/StaticizeController.java Ver fichero

@@ -386,9 +386,22 @@ public class StaticizeController {
386 386
         try {
387 387
             Map map = getFooter();
388 388
             List<News> list = staticizeService.getNewsList(uuid);
389
-            for (News news : list) {
389
+            for (int i = 0; i < list.size(); i++) {
390
+                News news = list.get(i);
390 391
                 map.put("article", news);
391 392
                 map.put("type", "news");
393
+                //判断是否有上一页
394
+                Map otherMap = new HashMap();
395
+                if (i == 0 && list.size() > 1){
396
+                    otherMap.put("nextNew",list.get(1));
397
+                }else {
398
+                    otherMap.put("upNew",list.get(i-1));
399
+                    if (i < list.size()-1){
400
+                        otherMap.put("nextNew",list.get(i+1));
401
+                    }
402
+
403
+                }
404
+                map.put("otherNews",otherMap);
392 405
                 // html名字
393 406
                 map.put("fileName", news.getUuid());
394 407
                 // 模板
@@ -396,6 +409,7 @@ public class StaticizeController {
396 409
                 staticizeService.pushHtml(map, "newsDetail");
397 410
                 staticizeService.updatePushStatus(news.getUuid(), "news", "news_");
398 411
             }
412
+
399 413
             index();//首页
400 414
             news();//新闻
401 415
             return true;

Loading…
Cancelar
Guardar