From 389a99a6beacc84e261a395b2c1ab188c6e19b66 Mon Sep 17 00:00:00 2001 From: augushong Date: Fri, 4 Mar 2022 17:12:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9Eloading=E6=93=8D=E4=BD=9C;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/static/common/js/app.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 public/static/common/js/app.js diff --git a/public/static/common/js/app.js b/public/static/common/js/app.js new file mode 100644 index 0000000..00bd757 --- /dev/null +++ b/public/static/common/js/app.js @@ -0,0 +1,30 @@ + +const loading = {}; +loading.index = 0; +loading.showCount = 0; +loading.show = function (count) { + + if (typeof count == 'undefined') { + count = 1; + } + + if (loading.showCount == 0) { + loading.index = layer.load() + } + + loading.showCount += count; +} + +loading.hide = function () { + + loading.showCount--; + + if (loading.showCount < 0) { + loading.showCount = 0; + } + + if (loading.showCount == 0) { + layer.close(loading.index); + } + +} \ No newline at end of file