Chencb1991 8 달 전
부모
커밋
634fe5c37f
1개의 변경된 파일27개의 추가작업 그리고 11개의 파일을 삭제
  1. 27 11
      src/main/resources/templates/theme/audit/index.html

+ 27 - 11
src/main/resources/templates/theme/audit/index.html

@@ -13,7 +13,7 @@
 <!--    <script th:src="@{/police/js/echarts.js}"></script>-->
     <!--    <script src="https://cdnjs.cloudflare.com/ajax/libs/echarts/5.4.1/echarts.min.js" integrity="sha512-OTbGFYPLe3jhy4bUwbB8nls0TFgz10kn0TLkmyA+l3FyivDs31zsXCjOis7YGDtE2Jsy0+fzW+3/OVoPVujPmQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>-->
 </head>
-<body>
+<body onbeforeunload="onBeforeUnload()">
 
 <div class="dialog_ino ishide" th:if="${not #lists.isEmpty(policeNavList) and policeNavList[0] != null}">
     <div>
@@ -708,22 +708,23 @@
 
         });
 
-        if(!sessionStorage.getItem('closeAD')){
+        console.log(sessionStorage.getItem('closeAD'))
+        if(sessionStorage.getItem('closeAD')==false||sessionStorage.getItem('closeAD')==null){
             $('.dialog_ino').show(600)
         }
         $('.dialog_ino .close').on('click',function () {
             $('.dialog_ino').hide(500)
             sessionStorage.setItem('closeAD',true)
-            $('.switch_tc').show()
+            // $('.switch_tc').show()
         })
 
-        if(!sessionStorage.getItem('closeADT')){
+        if(sessionStorage.getItem('closeADT')==false||sessionStorage.getItem('closeADT')==null){
             $('.dialog_ino_two').show(600)
         }
         $('.dialog_ino_two .close').on('click',function () {
             $('.dialog_ino_two').hide(500)
             sessionStorage.setItem('closeADT',true)
-            $('.switch_tc').show()
+            // $('.switch_tc').show()
         })
 
         // $('.switch_tc').on('click',function () {
@@ -734,6 +735,7 @@
         //     //sessionStorage.setItem('closeADT',true)
         // })
 
+
         function getDate(dates) {
             var dd = new Date();
             var n = dates || 0;
@@ -850,6 +852,7 @@
 
 
 <script>
+    let _beforeUnload_time = 0, _gap_time = 0;
     window.onload=function () {
         effect = 0
         var swiper = new Swiper('.swiper-container', {
@@ -898,15 +901,28 @@
                 clickable: true,
             },
         });
-        //
-        // pe = document.getElementById('progressEffect');
-        // pe.onchange = function(){
-        //     effect = this.value
-        //     swiper.update();
-        // }
+
+        _gap_time = new Date().getTime() - _beforeUnload_time;
+        if(_gap_time <= 5){
+            // 刷新时onbeforeunload与onunload的时间差一般都远大于5
+            // 浏览器关闭
+            console.log('浏览器关闭')
+            sessionStorage.removeItem('closeAD')
+            sessionStorage.removeItem('closeADT')
+            //sessionStorage.clear()
+        } else {
+            console.log('浏览器刷新')
+        }
 
 
     }
+    function onBeforeUnload() {
+        // 刷新或关闭页面都会执行,且先于onunload执行
+        _beforeUnload_time = new Date().getTime();
+
+    }
+
+
 </script>
 
 <script>