shaogen1995 11 months ago
parent
commit
fb3bfc84ff

+ 8 - 0
Code/src/assets/styles/base.css

@@ -197,3 +197,11 @@ textarea {
     transform: rotate(90deg) !important;
   }
 }
+#myIframe {
+  position: fixed;
+  top: 0;
+  left: 0;
+  z-index: 99;
+  width: 100vw;
+  height: 100vh;
+}

+ 10 - 0
Code/src/assets/styles/base.less

@@ -241,3 +241,13 @@ textarea {
     transform: rotate(90deg) !important;
   }
 }
+
+// 嵌套unity
+#myIframe {
+  position: fixed;
+  top: 0;
+  left: 0;
+  z-index: 99;
+  width: 100vw;
+  height: 100vh;
+}

+ 20 - 1
Code/src/pages/C1unity/index.tsx

@@ -64,9 +64,28 @@ function C1unity() {
     return arr
   }, [ind, urlId])
 
+  useEffect(() => {
+    if (url) {
+      // 待完善
+      const body = document.querySelector('body')
+      const iframe = document.createElement('iframe')
+      iframe.frameBorder = 'none'
+      iframe.title = '漫游'
+      iframe.id = 'myIframe'
+      iframe.src = url
+      body?.appendChild(iframe)
+    }
+
+    return () => {
+      const iframeDom = document.querySelector('#myIframe')
+
+      iframeDom?.remove()
+    }
+  }, [url])
+
   return (
     <div className={styles.C1unity}>
-      {url ? <iframe frameBorder='none' title='漫游' src={url}></iframe> : null}
+      {/* {url ? <iframe frameBorder='none' title='漫游' src={url}></iframe> : null} */}
 
       {/* 返回按钮 */}
       <BtnRight imgName='back' clickSon={() => history.go(-1)} title='返回' />