@lanyundev/blog-static 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/custom/all.css +1 -1
- package/js/custom/all.js +1 -1
- package/js/sw.js +1 -1
- package/package.json +1 -1
package/js/sw.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
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()}})();
|