bill il y a 1 an
Parent
commit
5760389a25
2 fichiers modifiés avec 10 ajouts et 6 suppressions
  1. 9 5
      src/model/app.vue
  2. 1 1
      src/model/platform.ts

+ 9 - 5
src/model/app.vue

@@ -44,6 +44,7 @@ export const Model = defineComponent({
             } catch(e) {
               console.error(e)
             }
+            url.value = ""
             setTimeout(() => url.value = newURL, 300)
           } else {
             url.value = newURL
@@ -97,8 +98,8 @@ export const Model = defineComponent({
 
     // 处理iframe 定制页面
     watch(
-      () => scene.value && scene.value.type, 
-      (type, oldType, onCleanup) => {
+      () => [scene.value && scene.value.type, url.value], 
+      ([type], oldType, onCleanup) => {
         if (type === false) {
           // 手动渲染融合场景
           console.log("手动渲染!");
@@ -108,8 +109,10 @@ export const Model = defineComponent({
         };
 
         const interval = setInterval(async () => {
-          const target = iframeRef.value?.contentWindow?.document?.head
-          if (!target) return;
+          const doc = iframeRef.value?.contentWindow?.document!
+          if (!doc || !doc.querySelector("div")) return;
+          console.error(doc, doc.head)
+          const target = doc.head
           clearInterval(interval);
           ;(window as any).iframeCreated && (window as any).iframeCreated(iframeRef.value);
           if (type === SceneType.SWSS) {
@@ -122,11 +125,12 @@ export const Model = defineComponent({
             `);
             $style.appendChild(textNode);
             target.appendChild($style);
+            console.error(target, $style)
           }
         }, 16);
         onCleanup(() => clearInterval(interval));
       }, 
-      {flush: 'post'}
+      {flush: 'post', immediate: true}
     )
 
     return {

+ 1 - 1
src/model/platform.ts

@@ -158,7 +158,7 @@ export async function exposeFactory(type: ModelType, win?: any): Promise<ModelEx
   }
 
   const sdk: any = await Promise.race([
-    asyncTimeout(10000)
+    asyncTimeout(100000)
       .then(() => Promise.reject(new Error('加载超时'))),
     platforms[sceneType].getSDK()
   ])