|
1
|
-
const allowedHosts=["lanyundev.com","localhost:4000"],delayArray=[1e3,3e3,4e3,5e3,7e3,9e3,11e3,15e3],redirectToMainSite=async()=>{allowedHosts.includes(window.location.host)||window.location.assign("https://lanyundev.com")};redirectToMainSite();const fetchDataAndDisplay=async()=>{document.querySelector.bind(document);const e=localStorage.getItem("load"),t=localStorage.getItem("load_md5");if(e&&"79c92594bbde64996165e18498f754c2"===t)document.body.insertAdjacentHTML("afterbegin",e);else{let e=await fetch("/notice");const t=await e.text();document.body.insertAdjacentHTML("afterbegin",t),localStorage.setItem("load",t),localStorage.setItem("load_md5","79c92594bbde64996165e18498f754c2")}};window.fetchDataAndDisplay=fetchDataAndDisplay,Try_fetchDataAndDisplay=async()=>{setTimeout((async()=>{"function"==typeof Vue&&new Vue({data:function(){this.$notify({title:"⚠️检测到存在过期内容!",message:"即将开始清除全部缓存!",position:"top-left",offset:50,showClose:!1,type:"warning",duration:1e3})}}),"function"==typeof delete_caches_reload?window.delete_caches_reload():setTimeout((async()=>{Try_fetchDataAndDisplay()}),800)}),400)},Check_caches_count=async()=>{caches.keys().then((function(e){e.length>1&&Try_fetchDataAndDisplay()}))},(async()=>{if("serviceWorker"in navigator){const e=await navigator.serviceWorker.register("/sw.js");window.localStorage.getItem("sw")||("function"==typeof window.stop&&window.stop(),fetchDataAndDisplay(),window.localStorage.setItem("sw",1),await navigator.serviceWorker.ready,setTimeout((function(){try{window.location.reload(!0)}catch{window.location.reload()}}),400)),Check_caches_count(),Promise.all(delayArray.map((async e=>{await new Promise((t=>setTimeout(t,e))),await navigator.serviceWorker.ready,Check_caches_count()}))),await e.update()}})();
|
|
1
|
+
"serviceWorker"in navigator&&navigator.serviceWorker.controller&&("function"==typeof window.stop&&window.stop(),navigator.serviceWorker.register("/sw.js"),location.reload()),(async()=>{navigator.serviceWorker.addEventListener("message",(e=>{"reload"===e.data.type&&location.reload()})),await(await navigator.serviceWorker.register("/sw.js")).update()})();
|