任一存 2 gadi atpakaļ
vecāks
revīzija
e27cdb7ca6

BIN
public/unity/Build/SHIndustryMuseum_2.0.data.unityweb


BIN
public/unity/Build/SHIndustryMuseum_2.0.framework.js.unityweb


BIN
public/unity/Build/SHIndustryMuseum_2.0.wasm.unityweb


BIN
public/unity/Build/SHIndustryMuseum_2.2.data.unityweb


BIN
public/unity/Build/SHIndustryMuseum_2.2.framework.js.unityweb


public/unity/Build/SHIndustryMuseum_2.0.loader.js → public/unity/Build/SHIndustryMuseum_2.2.loader.js


BIN
public/unity/Build/SHIndustryMuseum_2.2.wasm.unityweb


+ 4 - 4
public/unity/ServiceWorker.js

@@ -1,9 +1,9 @@
 const cacheName = "DefaultCompany-SHIndustryMuseum-0.1";
 const contentToCache = [
-    "Build/SHIndustryMuseum_1.9.loader.js",
-    "Build/SHIndustryMuseum_1.9.framework.js.unityweb",
-    "Build/SHIndustryMuseum_1.9.data.unityweb",
-    "Build/SHIndustryMuseum_1.9.wasm.unityweb",
+    "Build/SHIndustryMuseum_2.1.loader.js",
+    "Build/SHIndustryMuseum_2.1.framework.js.unityweb",
+    "Build/SHIndustryMuseum_2.1.data.unityweb",
+    "Build/SHIndustryMuseum_2.1.wasm.unityweb",
     "TemplateData/style.css"
 
 ];

+ 6 - 11
src/App.vue

@@ -9,7 +9,7 @@
     </transition>
 
     <div
-      v-show="$route.meta.isShow3DMap"
+      v-show="$route.meta.isShowUnityModel"
       id="unity-container"
     >
       <canvas
@@ -133,11 +133,11 @@ export default {
       var canvas = document.querySelector("#unity-canvas")
 
       var buildUrl = "unity/Build"
-      var loaderUrl = buildUrl + "/SHIndustryMuseum_2.0.loader.js"
+      var loaderUrl = buildUrl + "/SHIndustryMuseum_2.2.loader.js"
       var config = {
-        dataUrl: buildUrl + "/SHIndustryMuseum_2.0.data.unityweb",
-        frameworkUrl: buildUrl + "/SHIndustryMuseum_2.0.framework.js.unityweb",
-        codeUrl: buildUrl + "/SHIndustryMuseum_2.0.wasm.unityweb",
+        dataUrl: buildUrl + "/SHIndustryMuseum_2.2.data.unityweb",
+        frameworkUrl: buildUrl + "/SHIndustryMuseum_2.2.framework.js.unityweb",
+        codeUrl: buildUrl + "/SHIndustryMuseum_2.2.wasm.unityweb",
         streamingAssetsUrl: "StreamingAssets",
         companyName: "DefaultCompany",
         productName: "SHIndustryMuseum",
@@ -170,12 +170,7 @@ export default {
           }
         }).then((unityInstance) => {
           window.gUnityInst = unityInstance
-
-          for (let index = 1; index <= 36; index++) {
-            unityInstance.SendMessage('Panel1', 'ShowEnterprise', index) //显示id为index的企业
-          // unityInstance.SendMessage('Panel1', 'HideEnterprise', index); //隐藏id为index的企业
-          }
-
+          utils.loadUnitySceneGeneral()
         }).catch((message) => {
           alert(message)
         })

+ 26 - 9
src/router/index.js

@@ -9,6 +9,8 @@ import TestView from '../views/Test.vue'
 
 // import store from '@/store/index.js'
 
+let lastUnityScene = null
+
 const routes = [
   { path: '/', redirect: '/general' }, // todo: 这个会导致/history也匹配到?!
   {
@@ -16,8 +18,15 @@ const routes = [
     name: 'GeneralView',
     component: GeneralView,
     meta: {
-      isShow3DMap: true,
+      isShowUnityModel: true,
       belongNavGroup: 0,
+    },
+    beforeEnter() {
+      if (lastUnityScene !== 1) {
+        utils.loadUnitySceneGeneral()
+      }
+      lastUnityScene = 1
+      return true
     }
   },
   {
@@ -34,7 +43,7 @@ const routes = [
     component: TreasureView,
     meta: {
       belongNavGroup: 2,
-    }
+    },
   },
   {
     path: '/Treasure-detail',
@@ -42,7 +51,7 @@ const routes = [
     component: TreasureDetail,
     meta: {
       belongNavGroup: 2,
-    }
+    },
   },
   {
     path: '/record',
@@ -58,7 +67,15 @@ const routes = [
     name: 'MetaverseView',
     component: MetaverseView,
     meta: {
+      isShowUnityModel: true,
       belongNavGroup: 3,
+    },
+    beforeEnter() {
+      if (lastUnityScene !== 4) {
+        utils.loadUnitySceneMetaverse()
+      }
+      lastUnityScene = 4
+      return true
     }
   },
   {
@@ -73,11 +90,11 @@ const router = createRouter({
   routes
 })
 
-// router.beforeEach((to, from) => {
-//   // 生产环境下强制每次都从首页进入
-//   if (process.env.NODE_ENV === 'production' && !from.name && to.name !== 'home-view') {
-//     return '/'
-//   }
-// })
+router.beforeEach((to, from) => {
+  // 非开发环境下强制每次都从首页进入
+  if (process.env.NODE_ENV === 'production' && !from.name && to.name !== 'GeneralView') {
+    return '/'
+  }
+})
 
 export default router

+ 34 - 0
src/utils.js

@@ -1,3 +1,6 @@
+
+import { ElLoading } from 'element-plus'
+
 export default {
   /**
    * 返回一个自带消抖效果的函数,用res表示。
@@ -94,4 +97,35 @@ export default {
       document.msExitFullscreen()
     }
   },
+  loadUnitySceneGeneral() {
+    const loadingInstance = ElLoading.service({
+      background: 'black',
+    })
+
+    window.gUnityInst && window.gUnityInst.SendMessage('SceneManager', 'LoadPage1')
+    window.onSceneLoaded = () => {
+      console.log('unity scene loaded')
+    }
+    window.onRequestApiSuccess = () => { // unity模型里拿到了后端数据
+      for (let index = 1; index <= 36; index++) {
+        window.gUnityInst.SendMessage('Panel1', 'ShowEnterprise', index) //显示id为index的企业
+        // window.gUnityInst.SendMessage('Panel1', 'HideEnterprise', index); //隐藏id为index的企业
+      }
+      loadingInstance.close()
+    }	//场景加载完毕回调
+  },
+  loadUnitySceneMetaverse() {
+    const loadingInstance = ElLoading.service({
+      background: 'black',
+    })
+
+    window.gUnityInst && window.gUnityInst.SendMessage('SceneManager', 'LoadPage4')
+    window.onSceneLoaded = () => {
+      console.log('unity scene loaded')
+    }
+    window.onRequestApiSuccess = () => { // unity模型里拿到了后端数据
+      console.log('沙比 !!!!!!!!!!!!!!!!!!')
+      loadingInstance.close()
+    }
+  },
 }

+ 23 - 1
src/views/General.vue

@@ -91,6 +91,12 @@
         v-html="activeCorpInfo.description || ''"
       />
     </article>
+
+    <!-- element-ui的loading效果从调用到出现有延时,这期间要遮盖住组件 -->
+    <div
+      v-show="isShowLoadingMask"
+      class="loading-mask"
+    />
   </div>
 </template>
 
@@ -102,7 +108,6 @@ import {
   reactive,
   ref,
 } from 'vue'
-import deepClone from 'lodash/cloneDeep'
 
 export default {
   name: 'GeneralView',
@@ -168,6 +173,13 @@ export default {
     }
     window.onCorpOnMapClicked = onClickCorpItem
 
+    const isShowLoadingMask = ref(true)
+    onMounted(() => {
+      setTimeout(() => {
+        isShowLoadingMask.value = false
+      }, 200)
+    })
+
     return {
       filterKeyword,
 
@@ -177,6 +189,8 @@ export default {
       onClickCorpItem,
 
       isShowDesc,
+
+      isShowLoadingMask,
     }
   },
   data() {
@@ -468,5 +482,13 @@ export default {
       }
     }
   }
+  .loading-mask {
+    position: absolute;
+    left: 0;
+    top: 0;
+    width: 100%;
+    height: 100%;
+    background: black;
+  }
 }
 </style>

+ 23 - 0
src/views/Metaverse.vue

@@ -31,6 +31,12 @@
         v-html="desc.detail || ''"
       />
     </article>
+
+    <!-- element-ui的loading效果从调用到出现有延时,这期间要遮盖住组件 -->
+    <div
+      v-show="isShowLoadingMask"
+      class="loading-mask"
+    />
   </div>
 </template>
 
@@ -59,11 +65,20 @@ export default {
       isShowDesc.value = true
     }
 
+    const isShowLoadingMask = ref(true)
+    onMounted(() => {
+      setTimeout(() => {
+        isShowLoadingMask.value = false
+      }, 200)
+    })
+
     return {
       rawData,
       isShowDesc,
       desc,
       onClickStar,
+
+      isShowLoadingMask,
     }
   }
 }
@@ -140,5 +155,13 @@ export default {
       }
     }
   }
+  .loading-mask {
+    position: absolute;
+    left: 0;
+    top: 0;
+    width: 100%;
+    height: 100%;
+    background: black;
+  }
 }
 </style>