From 874ff5b3f6b1437173debcd4c52e32e4a47f5fcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E7=B2=BE=E5=8D=8E?= <842761733@qq.com> Date: Mon, 31 Mar 2025 15:28:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=9A=E8=A7=A3=E5=86=B3?= =?UTF-8?q?=E9=83=A8=E5=88=86=E5=9C=BA=E6=99=AF=E4=B8=8B,=20=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E5=85=83=E7=B4=A0=E5=8F=98=E5=8C=96=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E6=B0=B4=E5=8D=B0=E8=A6=86=E7=9B=96=E4=B8=8D=E5=85=A8=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/web/commonHeader.ftl | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/server/src/main/resources/web/commonHeader.ftl b/server/src/main/resources/web/commonHeader.ftl index 3932776b..473aa288 100644 --- a/server/src/main/resources/web/commonHeader.ftl +++ b/server/src/main/resources/web/commonHeader.ftl @@ -8,7 +8,19 @@ */ function initWaterMark() { let watermarkTxt = '${watermarkTxt}'; - if (watermarkTxt !== '') { + if (watermarkTxt === '') { + return; + } + let lastWidth = 0; + let lastHeight = 0; + const checkResize = () => { + const currentWidth = document.documentElement.scrollWidth; + const currentHeight = document.documentElement.scrollHeight; + // 检测尺寸是否变化 + if (currentWidth === lastWidth && currentHeight === lastHeight) { + return; + } + // 如果变化了, 重新初始化水印 watermark.init({ watermark_txt: '${watermarkTxt}', watermark_x: 0, @@ -25,7 +37,11 @@ watermark_height: ${watermarkHeight}, watermark_angle: ${watermarkAngle}, }); - } + // 更新存储的宽口大小 + lastWidth = currentWidth; + lastHeight = currentHeight; + }; + setInterval(checkResize, 1000); }