Explorar el Código

自定义延迟

PUGE hace 1 año
padre
commit
ab37c9b141
Se han modificado 1 ficheros con 28 adiciones y 24 borrados
  1. 28 24
      back/insert.js

+ 28 - 24
back/insert.js

@@ -62,20 +62,22 @@ if (localStorage.getItem('owoLoadData')) {
   const element = JSON.parse(localStorage.getItem('owoLoadData'))
   let urlStr = window.location.href
   if (new RegExp(element.url).test(urlStr)) {
-      
-    if (element.script) {
-      element.script.forEach(element => {
-        loadJS(element)
-      });
-    }
-    if (element.style) {
-      element.style.forEach(element => {
-        loadCSS(element)
-      });
-    }
     setTimeout(() => {
-      if (element.data) addScr(element.data)
+      if (element.script) {
+        element.script.forEach(element => {
+          loadJS(element)
+        });
+      }
+      if (element.style) {
+        element.style.forEach(element => {
+          loadCSS(element)
+        });
+      }
+      setTimeout(() => {
+        if (element.data) addScr(element.data)
+      }, 0);
     }, element.delay || 0);
+    
   }
 } else {
   // 尝试网络加载
@@ -85,20 +87,22 @@ if (localStorage.getItem('owoLoadData')) {
     let urlStr = window.location.href
     dataTemp.forEach(element => {
       if (new RegExp(element.url).test(urlStr)) {
-        
-        if (element.script) {
-          JSON.parse(element.script).forEach(element => {
-            loadJS(element)
-          });
-        }
-        if (element.style) {
-          JSON.parse(element.style).forEach(element => {
-            loadCSS(element)
-          });
-        }
         setTimeout(() => {
-          if (element.data) addScr(element.data)
+          if (element.script) {
+            JSON.parse(element.script).forEach(element => {
+              loadJS(element)
+            });
+          }
+          if (element.style) {
+            JSON.parse(element.style).forEach(element => {
+              loadCSS(element)
+            });
+          }
+          setTimeout(() => {
+            if (element.data) addScr(element.data)
+          }, 0);
         }, element.delay || 0);
+        
         return
       }
     })