diff --git a/ruoyi-admin/src/main/resources/templates/home/base.html b/ruoyi-admin/src/main/resources/templates/home/base.html index 8d342b6..ab28aaa 100644 --- a/ruoyi-admin/src/main/resources/templates/home/base.html +++ b/ruoyi-admin/src/main/resources/templates/home/base.html @@ -559,21 +559,22 @@ var noticeInner = document.querySelector('.notice__inner'); var noticeItems = Array.from(document.querySelectorAll('.notice__item')); var currentIndex = 0; - function showCurrentNotice() { - var numToShow = Math.min(currentIndex + 1, noticeItems.length); - for (var i = 0; i < noticeItems.length; i++) { - noticeItems[i].style.height = ''; - } - for (var i = 0; i < numToShow; i++) { - noticeItems[i].style.height = 'auto'; + if (noticeItems.length > 1) { + function showCurrentNotice() { + var numToShow = Math.min(currentIndex + 1, noticeItems.length); + for (var i = 0; i < noticeItems.length; i++) { + noticeItems[i].style.height = ''; + } + for (var i = 0; i < numToShow; i++) { + noticeItems[i].style.height = 'auto'; + } + noticeInner.style.transform = "translateY(" + ((-noticeItems[currentIndex].clientHeight * currentIndex)*1.39) + "px)"; + noticeInner.style.transition = "all 2.5s"; + noticeInner.scrollTop = noticeItems[currentIndex].offsetTop; + } - noticeInner.style.transform = "translateY(" + ((-noticeItems[currentIndex].clientHeight * currentIndex)*1.39) + "px)"; - noticeInner.style.transition = "all 2.5s"; - noticeInner.scrollTop = noticeItems[currentIndex].offsetTop; + showCurrentNotice(); - } - showCurrentNotice(); - if (noticeItems.length > 1) { setInterval(() => { currentIndex = (currentIndex + 1) % noticeItems.length; showCurrentNotice();