From 750367c1a9a4b4cde9c5f7502692f1955412091a Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@63.com> Date: 星期三, 28 十二月 2022 10:11:48 +0800 Subject: [PATCH] # --- src/main/webapp/views/index.html | 7 +++ src/main/java/com/zy/asrs/controller/NewsController.java | 22 +++++++++++ src/main/webapp/views/news.html | 55 +++++++++++++++++++++++++-- 3 files changed, 79 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/zy/asrs/controller/NewsController.java b/src/main/java/com/zy/asrs/controller/NewsController.java new file mode 100644 index 0000000..1f025ae --- /dev/null +++ b/src/main/java/com/zy/asrs/controller/NewsController.java @@ -0,0 +1,22 @@ +package com.zy.asrs.controller; + +import com.core.common.R; +import com.zy.core.News; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * Created by vincent on 2022/12/28 + */ +@Slf4j +@RestController +@RequestMapping("/news") +public class NewsController { + + @RequestMapping("/print") + public synchronized R print(){ + return R.ok().add(News.print()); + } + +} diff --git a/src/main/webapp/views/index.html b/src/main/webapp/views/index.html index 3c80877..4c1e33c 100644 --- a/src/main/webapp/views/index.html +++ b/src/main/webapp/views/index.html @@ -7,6 +7,11 @@ <link rel="stylesheet" href="../static/css/layx.min.css" type="text/css" /> <script src="../static/js/jquery/jquery-3.3.1.min.js"></script> <script src="../static/js/tools/layx.min.js"></script> + <style> + .layx-window.layx-skin-news .layx-control-bar { + background-color: #333333; + } + </style> </head> <body> <!-- 瀵艰埅鏍� --> @@ -47,6 +52,8 @@ , "news.html" , { shadow:false + , storeStatus:false + // , skin: 'news' , width:800 , height:600 , position:'rb' diff --git a/src/main/webapp/views/news.html b/src/main/webapp/views/news.html index 3af6366..3aab58e 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,15 +39,31 @@ bottom: 5%; } + .news-desc { + font-size: 14px; + } + .level-1 { + color: #333333; + } + .level-2 { + color: #1E9FFF; + } + .level-3 { + color: red; + } </style> </head> <body> +<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> var autoScroll = true; @@ -59,11 +83,32 @@ }) setInterval(()=>{ - $("body").append(new Date() + "<h4>Hello World</h4>"); - 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: eval(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> - <span>{{v}}</span> + </div> + {{/each}} +</script> </html> -- Gitblit v1.9.1