From 15bebd1398993db87e72f501d1dc64cc018e46ca Mon Sep 17 00:00:00 2001
From: zwl <1051256694@qq.com>
Date: 星期一, 17 十一月 2025 13:13:00 +0800
Subject: [PATCH] #

---
 src/main/webapp/views/news.html |   58 +++++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 51 insertions(+), 7 deletions(-)

diff --git a/src/main/webapp/views/news.html b/src/main/webapp/views/news.html
index 779e730..e548501 100644
--- a/src/main/webapp/views/news.html
+++ b/src/main/webapp/views/news.html
@@ -4,6 +4,14 @@
     <meta charset="UTF-8">
     <title>NEWS</title>
     <style>
+        /** {*/
+        /*    padding: 0;*/
+        /*    margin: 0;*/
+        /*}*/
+        .container {
+            height: 100%;
+            width: 100%;
+        }
         /*=============== SCROLL UP ===============*/
         .scrollup {
             text-decoration: none;
@@ -31,18 +39,33 @@
             bottom: 5%;
         }
 
+        .news-desc {
+            font-size: 14px;
+        }
+        .level-1 {
+            color: #333333;
+        }
+        .level-2 {
+            color: #0087ec;
+        }
+        .level-3 {
+            color: red;
+        }
     </style>
 </head>
 <body>
-<h1>Hello World</h1>
+<div class="container">
 
+</div>
 <a class="scrollup" id="scroll-up">
     <span>椤堕儴</span>
 </a>
 </body>
 <script src="../static/js/jquery/jquery-3.3.1.min.js"></script>
+<script src="../static/js/handlebars/handlebars-v4.5.3.js"></script>
+<script src="../static/js/common.js"></script>
 <script>
-    let autoScroll = true;
+    var autoScroll = true;
 
     function scrollUp(){
         const scrollUp = document.getElementById('scroll-up');
@@ -60,11 +83,32 @@
     })
 
     setInterval(()=>{
-        $("body").append("<h1>Hello World</h1>");
-        if (autoScroll) {
-            window.scrollTo(0, document.body.scrollHeight)
-        }
-    }, 500)
+        $.ajax({
+            url: baseUrl + "/news/print",
+            // headers: {'token': localStorage.getItem('token')},
+            method: 'GET',
+            success: function (res) {
+                if (res.code === 200) {
+                    let template = Handlebars.compile($('#newsTpl').html());
+                    $('.container').html(template({list: res.data}));
+                    if (autoScroll) {
+                        window.scrollTo(0, document.body.scrollHeight)
+                    }
+                } else if (res.code === 403) {
+                    window.location.href = baseUrl + "/login";
+                } else {
+                    console.error(res.msg);
+                }
+            }
+        })
+    }, 1000)
 
 </script>
+<script type="text/template" id="newsTpl">
+    {{#each list}}
+    <div class="news-desc level-{{l}}">
+        <span>{{t}}</span>&nbsp;-&nbsp;<span>{{v}}</span>
+    </div>
+    {{/each}}
+</script>
 </html>

--
Gitblit v1.9.1