shaogen1995 4 周之前
父節點
當前提交
fc29e744f9
共有 3 個文件被更改,包括 44 次插入18 次删除
  1. 22 13
      src/pages/A0base/data.ts
  2. 15 5
      src/pages/A6ybwx/index.tsx
  3. 7 0
      src/pages/A7wjwj/conponents/Discover/index.tsx

+ 22 - 13
src/pages/A0base/data.ts

@@ -24,26 +24,35 @@ export const unityShow = (val: boolean) => {
   }
 }
 
+// 获取当前场景key
+export const getUnityKey = () => {
+  let key = ''
+
+  const dom: any = document.getElementById('modalIframe')
+  if (dom && dom.contentWindow) {
+    const iframeWindow = dom.contentWindow
+
+    if (iframeWindow.sceneStaRes) {
+      key = iframeWindow.sceneStaRes()
+    }
+  }
+  return key
+}
+
 // 切换unity
 export const cutUnityFu = (
   val: 'TombstoneView' | 'RoomScene' | 'DrawingBoard',
   backFu: () => void
 ) => {
   const dom: any = document.getElementById('modalIframe')
-
+  
   if (dom.src.includes('unity')) {
-    if (dom && dom.contentWindow) {
-      const iframeWindow = dom.contentWindow
-
-      if (iframeWindow.sceneStaRes) {
-        const res: any = iframeWindow.sceneStaRes()
-
-        if (res !== val) {
-          unityShow(true)
-          callIframeFu('loadScene', val)
-          backFu()
-        }
-      }
+    const res = getUnityKey()
+
+    if (res !== val) {
+      unityShow(true)
+      callIframeFu('loadScene', val)
+      backFu()
     }
   } else {
     // 被销毁了,需要重新加载

+ 15 - 5
src/pages/A6ybwx/index.tsx

@@ -9,7 +9,7 @@ import { isPc } from '@/utils/http'
 import MenuSider from '@/components/MenuSider'
 import Skip from '@/components/Skip'
 import { domDelOwnFu } from '@/utils/utilsSome'
-import { cutUnityFu } from '../A0base/data'
+import { cutUnityFu, getUnityKey } from '../A0base/data'
 import Zloding from '@/components/Zloding'
 
 function A6ybwx() {
@@ -18,6 +18,16 @@ function A6ybwx() {
 
   const [isEnter, setIsEnter] = useState(false)
 
+  // 是否还需要重新加载场景
+  const [lodingScene, setLodingScene] = useState(true)
+
+  useEffect(() => {
+    const unityKey = getUnityKey()
+    if (unityKey === 'RoomScene') {
+      setLodingScene(false)
+    }
+  }, [])
+
   useEffect(() => {
     if (videoRefLast.current) videoRefLast.current.play()
   }, [])
@@ -65,11 +75,11 @@ function A6ybwx() {
     if (isEnter) {
       // 销毁视频
       videoRefLast.current?.pause()
-      setTimeout(()=>{
+      setTimeout(() => {
         domDelOwnFu('.videoBox')
-      },100)
+      }, 100)
       // 切换场景
-      cutUnityFu('RoomScene',()=>{})
+      cutUnityFu('RoomScene', () => {})
     }
   }, [isEnter])
 
@@ -127,7 +137,7 @@ function A6ybwx() {
       {gotoTab === 3 && <SangzangHome setGotoTab={setGotoTab} />}
 
       {/* 进度条 */}
-       <Zloding isShow={isEnter} bacNum={2} /> 
+      <Zloding isShow={isEnter&&lodingScene} bacNum={2} />
     </div>
   )
 }

+ 7 - 0
src/pages/A7wjwj/conponents/Discover/index.tsx

@@ -4,9 +4,16 @@ import { isPc } from '@/utils/http'
 import classNames from 'classnames'
 import { useSelector } from 'react-redux'
 import { RootState } from '@/store'
+// import { cutUnityFu } from '@/pages/A0base/data'
 // import { domDelOwnFu } from '@/utils/utilsSome'
 
 function Discover(props: { style?: React.CSSProperties }) {
+
+  // 待完善 这个时候应该跳空场景
+  useEffect(()=>{
+    // cutUnityFu()
+  },[])
+
   const { myData } = useSelector((state: RootState) => state.A0Layout)
 
   // 将隐藏的页面打开,全景图->诗歌->大场景