From 4fb4ea0e10691f1253c20f76edbba6057a36ae8b Mon Sep 17 00:00:00 2001 From: augushong Date: Sun, 5 Sep 2021 00:37:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=80=9A=E7=94=A8js=E5=BA=93?= =?UTF-8?q?:=20loading=E5=B0=81=E8=A3=85,=20=E8=87=AA=E5=8A=A8=E7=BB=91?= =?UTF-8?q?=E5=AE=9Ajs=E8=B7=B3=E8=BD=AC,=20=E6=89=8B=E6=9C=BA=E7=AB=AF/?= =?UTF-8?q?=E7=94=B5=E8=84=91=E7=AB=AF=E6=A3=80=E6=B5=8B,=20=E5=AF=B9js?= =?UTF-8?q?=E8=B7=B3=E8=BD=AC=E7=BB=91=E5=AE=9Aloading?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/static/js/common.js | 49 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/public/static/js/common.js b/public/static/js/common.js index 5ae9298..40b92ed 100644 --- a/public/static/js/common.js +++ b/public/static/js/common.js @@ -109,4 +109,53 @@ function renderUpload(target, params) { layer.close(window.uploading) } }) +} + + +const loading = {}; +loading.index = 0; +loading.show = function () { + if (loading.index != 0) { + layer.close(loading.index) + } + + loading.index = layer.load() +} + +loading.hide = function () { + layer.close(loading.index); + loading.index = 0; +} + +$(function () { + $('[data-href]').click(function () { + var item = this; + + loading.show() + + var href = $(item).data('href') + + location.href = href + }) +}) + +function isPC() { + var userAgentInfo = navigator.userAgent; + var Agents = ["Android", "iPhone", + "SymbianOS", "Windows Phone", + "iPad", "iPod"]; + var flag = true; + for (var v = 0; v < Agents.length; v++) { + if (userAgentInfo.indexOf(Agents[v]) > 0) { + flag = false; + break; + } + } + return flag; +} + +top.onbeforeunload = function (e) { + setTimeout(() => { + loading.show() + }, 2000); } \ No newline at end of file