diff --git a/ruoyi-admin/src/main/resources/templates/home/base.html b/ruoyi-admin/src/main/resources/templates/home/base.html
index 49534f4..2f8cf62 100644
--- a/ruoyi-admin/src/main/resources/templates/home/base.html
+++ b/ruoyi-admin/src/main/resources/templates/home/base.html
@@ -71,7 +71,7 @@
- 关闭
+ 关闭
@@ -523,42 +523,47 @@
$('.myscroll').myScroll({
speed: 30,
});
+ document.addEventListener('DOMContentLoaded',function(){
+ var el = document.querySelector('#ad');
+ if (el){
+ var styleTop = 0;
+ var styleLeft = 0;
+ var verticalFlag = true;
+ var horizontalFlag = true;
+ var isMouseOver = false; // 新变量用于跟踪鼠标是否在元素上
- var el = document.querySelector('#ad');
- var styleTop = 0;
- var styleLeft = 0;
- var verticalFlag = true;
- var horizontalFlag = true;
- var isMouseOver = false; // 新变量用于跟踪鼠标是否在元素上
+ // 设置定时器的函数
+ function moveElement() {
+ if (!isMouseOver) { // 如果鼠标不在元素上,则继续移动
+ verticalFlag ? styleTop++ : styleTop--;
+ horizontalFlag ? styleLeft++ : styleLeft--;
- // 设置定时器的函数
- function moveElement() {
- if (!isMouseOver) { // 如果鼠标不在元素上,则继续移动
- verticalFlag ? styleTop++ : styleTop--;
- horizontalFlag ? styleLeft++ : styleLeft--;
+ (styleTop <= 0 || styleTop >= window.innerHeight - el.offsetHeight) && (verticalFlag = !verticalFlag);
+ (styleLeft <= 0 || styleLeft >= window.innerWidth - el.offsetWidth) && (horizontalFlag = !horizontalFlag);
- (styleTop <= 0 || styleTop >= window.innerHeight - el.offsetHeight) && (verticalFlag = !verticalFlag);
- (styleLeft <= 0 || styleLeft >= window.innerWidth - el.offsetWidth) && (horizontalFlag = !horizontalFlag);
-
- el.style.top = styleTop +'px';
- el.style.left = styleLeft + 'px';
- }
- }
+ el.style.top = styleTop +'px';
+ el.style.left = styleLeft + 'px';
+ }
+ }
- setInterval(moveElement, 20);
+ setInterval(moveElement, 20);
- // 添加事件监听器以检测鼠标是否在元素上
- el.addEventListener('mouseover', function () {
- isMouseOver = true;
- });
+ // 添加事件监听器以检测鼠标是否在元素上
+ el.addEventListener('mouseover', function () {
+ isMouseOver = true;
+ });
- el.addEventListener('mouseout', function () {
- isMouseOver = false;
- });
- function closeAd(){
- isMouseOver = true;
- el.style.display = 'none'
- }
+ el.addEventListener('mouseout', function () {
+ isMouseOver = false;
+ });
+ }
+ function closeAd(){
+ isMouseOver = true;
+ el.style.display = 'none'
+ }
+ // 绑定关闭广告的按钮
+ document.getElementById('closeButton').addEventListener('click', closeAd);
+ })
document.addEventListener('DOMContentLoaded', function() {
var noticeInner = document.querySelector('.notice__inner');
var noticeItems = Array.from(document.querySelectorAll('.notice__item'));