From 1b8a45bf8c75cbb1ebc7810fcc2524d94a023139 Mon Sep 17 00:00:00 2001 From: popcorner <351633+popcorner@user.noreply.gitee.com> Date: Thu, 18 Jun 2020 04:10:27 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20HTML5=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E5=8A=9F=E8=83=BD=E5=9C=A8=E7=8E=B0=E4=BB=A3=E6=B5=8F?= =?UTF-8?q?=E8=A7=88=E5=99=A8=E4=B8=8D=E5=8F=AF=E7=94=A8=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- upload/static/js/html5notification.js | 40 +++++++++++++-------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/upload/static/js/html5notification.js b/upload/static/js/html5notification.js index 42225357a..e72dda21b 100644 --- a/upload/static/js/html5notification.js +++ b/upload/static/js/html5notification.js @@ -9,29 +9,29 @@ function Html5notification() { var h5n = new Object(); h5n.issupport = function() { - var is = !!window.webkitNotifications; - if(is) { - if(window.webkitNotifications.checkPermission() > 0) { - window.onclick = function() { - window.webkitNotifications.requestPermission(); - } - } - } - return is; + return "Notification" in window; }; h5n.shownotification = function(replaceid, url, imgurl, subject, message) { - if(window.webkitNotifications.checkPermission() > 0) { - window.webkitNotifications.requestPermission(); - } else { - var notify = window.webkitNotifications.createNotification(imgurl, subject, message); - notify.replaceId = replaceid; - notify.onclick = function() { - window.focus(); - window.location.href = url; - notify.cancel(); - }; - notify.show(); + if (Notification.permission === 'granted') { + sendit(); + } else if (Notification.permission !== 'denied') { + Notification.requestPermission().then(function (perm) { + if (perm === 'granted') { + sendit(); + } + }); + } + function sendit() { + var n = new Notification(subject, { + tag: replaceid, + icon: imgurl, + body: message + }); + n.onclick = function (e) { + e.preventDefault(); + window.open(url, '_blank'); + } } }; -- Gitee From 1c54b88ea59d70952e8cfb1db12d1e88d146630c Mon Sep 17 00:00:00 2001 From: popcorner <351633+popcorner@user.noreply.gitee.com> Date: Fri, 19 Jun 2020 04:00:40 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E9=83=A8=E5=88=86?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- upload/static/js/html5notification.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/upload/static/js/html5notification.js b/upload/static/js/html5notification.js index e72dda21b..1ff383396 100644 --- a/upload/static/js/html5notification.js +++ b/upload/static/js/html5notification.js @@ -9,7 +9,7 @@ function Html5notification() { var h5n = new Object(); h5n.issupport = function() { - return "Notification" in window; + return 'Notification' in window; }; h5n.shownotification = function(replaceid, url, imgurl, subject, message) { @@ -31,7 +31,7 @@ function Html5notification() { n.onclick = function (e) { e.preventDefault(); window.open(url, '_blank'); - } + }; } }; -- Gitee