From dfc30d5d9e28dd9a321ca7500e828494b8b98cc8 Mon Sep 17 00:00:00 2001 From: Anyon Date: Mon, 25 Apr 2022 14:14:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/static/login.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/public/static/login.js b/public/static/login.js index 410e61aed..91a305de3 100644 --- a/public/static/login.js +++ b/public/static/login.js @@ -18,17 +18,19 @@ $(function () { /*! 登录界面背景切换 */ $('[data-bg-transition]').each(function (i, el) { - el.idx = 0, el.imgs = [], el.lazy = setInterval(function () { - el.imgs.length > 0 && el.setImg(el.imgs[++el.idx] || el.imgs[el.idx = 0]); - }, 5000) && el.dataset.bgTransition.split(',').forEach(function (url) { - layui.img(url, function () { - el.imgs.push(url); + el.idx = 0, el.imgs = [], el.SetBackImage = function (css) { + window.setTimeout(function () { + $(el).removeClass(el.imgs.join(' ')).addClass(css) + }, 1000) && $body.removeClass(el.imgs.join(' ')).addClass(css) + }, window.setInterval(function () { + el.imgs.length > 0 && el.SetBackImage(el.imgs[++el.idx] || el.imgs[el.idx = 0]); + }, 5000) && el.dataset.bgTransition.split(',').forEach(function (image) { + layui.img(image, function (img, cssid, style) { + style = document.createElement('style'), cssid = 'LoginBackImage' + (el.imgs.length + 1); + style.innerHTML = '.' + cssid + '{background-image:url("' + encodeURI(image) + '")!important}'; + document.head.appendChild(style) && el.imgs.push(cssid); }); - }), el.setImg = function (url) { - setTimeout(function () { - el.style.backgroundImage = 'url(' + url + ')'; - }, 1000) && $body.css({backgroundImage: 'url(' + url + ')'}); - }; + }); }); /*! 后台加密登录处理 */