Explorar o código

优化断线重连处理
取消自动漫游

liling hai 5 meses
pai
achega
4a69163b44

+ 1 - 1
public/conf.js

@@ -1,5 +1,5 @@
 AutoPlayer = false; //开启自动漫游
-ApiServer = "http://192.168.1.66:8080" //http://192.168.66.133:8080"; //服务接口地址
+ApiServer = "http://192.168.66.133:8080" //http://192.168.66.133:8080"; //服务接口地址
 PLAYER3D_URL = "ws://192.168.1.101:8082" // "ws://192.168.66.133:8082"; //
 DEV_ALAR_COLOR = "ff6c00"; //全局设备告警颜色
 DEV_HINT_COLOR = "d69d85"; //设备盘头剩余20-50之间的提示颜色

+ 3 - 3
src/pages/components/Bottom.vue

@@ -28,12 +28,12 @@ export default {
             if(newVal){
                 //模型加载完成
                 console.log('全厂模型加载完成')
+                if(window.CurrentTargetType==null||window.CurrentTargetType=='') window.CurrentTargetType='FAC';
                 for(let i=0;i<navlist.value.length;i++){
-                    if(navlist.value[i].code=='FAC'){
+                    if(navlist.value[i].code==window.CurrentTargetType){
                         navlist.value[i].active=true;
                     }else navlist.value[i].active=false;
                 }
-            window.CurrentTargetType='FAC';
             }
         },{deep:true,immediate:true})
  
@@ -50,7 +50,7 @@ export default {
         }
 
         onMounted(()=>{
-            window.CurrentTargetType='FAC';
+            if(window.CurrentTargetType==null || window.CurrentTargetType=='') window.CurrentTargetType='FAC';
         })
 
         return{

+ 5 - 1
src/pages/components/In02.vue

@@ -1688,6 +1688,10 @@ export default {
         }
         async function init(){
             backMasterViewBy02();
+            for (var i in ANIMATION_DATA) {
+                // 添加关键帧
+                player.Native.CameraAnimation.addKeyFrames([ANIMATION_DATA[i]]);
+            }
             //let cfInfo=await player.Native.Model.getInfo("all");
             //player.Native.NodeProxy.setNodeRotation(cfInfo.nodePtr, [0,0,90]);
             var rootItem = await player.Native.ModelTree.getRootItems();
@@ -3029,7 +3033,7 @@ export default {
         })
         onUnmounted(()=>{
             AutoPlayer.value=false;
-            if(player.Native!=null)  player.Native.CameraAnimation.stop();
+            if(player!=null && player.Native!=null)  player.Native.CameraAnimation.stop();
             clearTimeout(dataTimer1);
             clearTimeout(dataTimer2);
             clearTimeout(dataTimer3);

+ 5 - 3
src/pages/components/In03.vue

@@ -90,9 +90,11 @@ export default {
             }
         }
         onUnmounted(()=>{
-            window.IN03Markers.forEach(async ele=>{
-                await player.Native.GisMarker.destroy(ele);
-            })
+            if(player!=null && player.Native!=null){
+                window.IN03Markers.forEach(async ele=>{
+                    await player.Native.GisMarker.destroy(ele);
+                })
+            }
             window.IN03Markers=null;
         })
     }

+ 5 - 3
src/pages/components/In04.vue

@@ -95,9 +95,11 @@ export default {
             }
         }
         onUnmounted(()=>{
-            window.IN04Markers.forEach(async ele=>{
-                await player.Native.GisMarker.destroy(ele);
-            })
+            if(player!=null && player.Native!=null){
+                window.IN04Markers.forEach(async ele=>{
+                    await player.Native.GisMarker.destroy(ele);
+                })
+            }
             window.IN04Markers=null;
         })
     }

+ 5 - 3
src/pages/components/In05.vue

@@ -94,9 +94,11 @@ export default {
             }
         }
         onUnmounted(()=>{
-            window.IN05Markers.forEach(async ele=>{
-                await player.Native.GisMarker.destroy(ele);
-            })
+            if(player!=null && player.Native!=null){
+                window.IN05Markers.forEach(async ele=>{
+                    await player.Native.GisMarker.destroy(ele);
+                })
+            }
             window.IN05Markers=null;
         })
     }

+ 34 - 17
src/pages/main/index.vue

@@ -10,7 +10,7 @@
         <In03 ref="In03Ele" v-if="currentTargetType=='IN03'" :click-event="In03ClickEvent" :in03-model-load-state="in03modelloadstate" :user-timeout="AutoPlayer"></In03>
         <In04 v-if="currentTargetType=='IN04'" :click-event="In04ClickEvent" :in04-model-load-state="in04modelloadstate" :user-timeout="AutoPlayer"></In04>
         <In05 v-if="currentTargetType=='IN05'" :click-event="In05ClickEvent" :in05-model-load-state="in05modelloadstate" :user-timeout="AutoPlayer"></In05>
-        <Bottom @loadNavModel="loadNavModel" :fac-model-load-state="facModelLoadState"/>
+        <Bottom @loadNavModel="loadNavModel" :fac-model-load-state="isLoaded"/>
     </div>
 </template>
 <script>
@@ -126,7 +126,7 @@ export default {
                 limtMoveCPS: 10, // 限制每秒鼠标移动的消息个数
                 userTimeout: 1000 * 60 * 5, // 用户操作超时设置,毫秒
                 exitTimeout: 1000 * 60 * 60 * 999999, // 用户超时后多久断开会话
-                maxTimeout: 1000, // 会话超时时间,允许掉线后引擎保存多久,在该时间内可重新连接到会话,否则会创建新的会话
+                maxTimeout: 10000, // 会话超时时间,允许掉线后引擎保存多久,在该时间内可重新连接到会话,否则会创建新的会话
                 debug: false // 是否启用调试,开启后调用Native接口时会使用console.log进行记录
             });
             //2.[可选]监听连接成功消息
@@ -143,6 +143,7 @@ export default {
                 reconnect.value = true;
                 isClearEle.value=true;
                 playerConnState = false
+                isLoaded.value = false;
                 facModelLoadState.value=false;
                 in02modelloadstate.value=false;
                 in03modelloadstate.value=false;
@@ -150,14 +151,19 @@ export default {
                 in05modelloadstate.value = false;
                 window.IN03Markers=null;
                 window.IN04Markers=null;
-                window.IN05Markers=null;
+                window.IN05Markers=null;      
+                AutoPlayer.value=false;     
+                EngineContent.value.pause();     
+                if(e=='signal websocket error'){
+                    //服务器网络不通
+                }
                 modelLoadState={};
                 //currentTargetType.value='';
                 //4.[推荐]尝试重新连接
                 reconntimer = setTimeout(function () {
                     console.log('尝试自动重连:', playerConnState)
                     if (playerConnState) return
-                    if(player==null || player.Native==null){
+                    if(player==null ){
                         window.location.reload();
                         return;
                     }
@@ -167,25 +173,40 @@ export default {
 
             //5. [推荐] 响应UserTimeOut消息,引擎接收用户鼠标触屏事件超时发出通知
             player.on("UserTimeOut", () => {
-                console.info('用户长时间没有操作三维视图,会话即将退出,可调用player.resetTimer()取消退出');
-                AutoPlayer.value = true;                
+                console.info('用户长时间没有操作三维视图,可调用player.resetTimer()取消退出');
+                //AutoPlayer.value = true;  //暂时取消自动漫游功能              
             });
             player.on('TimeOutExit',()=>{
                 console.info('长时间没有操作,已断开连接');
             });
+            player.on('ConnectedFailed',(evt)=>{
+                console.info('服务器连接失败');
+            })
             //6.监听远程过程调用加载完成消息
             player.on("NativeLoad", async (Native) => {
                 modelLoadState={};
+                EngineContent.value.play();
                 playerNative.value =Native;
-                var devAllCount = 6 * 12 * 2 - 4 //设备总数
-                //var loadedcnt = document.getElementById("loadedcnt")
-                //var totalcnt = document.getElementById("totalcnt")
-                //totalcnt.innerText = devAllCount;
-                //loadedcnt.innerText="0";
-                loadFacModel(Native);
+                switch(window.CurrentTargetType){
+                    case "IN02":
+                        loadIn02Model(Native);
+                        break;
+                    case "IN03":
+                        loadIn03Model(Native);
+                        break;
+                    case "IN04":
+                        loadIn04Model(Native);
+                        break;
+                    case "IN05":
+                        loadIn05Model(Native);
+                        break;
+                    default:
+                        loadFacModel(Native);
+                        break;
+                }                
                 setTimeout(function(){
                     isLoaded.value=true
-                },4000);
+                },2000);
 
                 //调整视角,使其达到最佳初始效果
                 backMasterView();
@@ -387,10 +408,6 @@ export default {
             }
             await player.Native.Model.setModelVisible(currentTargetType.value,true);
             showMarker(currentTargetType.value);
-            for (var i in ANIMATION_DATA) {
-                // 添加关键帧
-                player.Native.CameraAnimation.addKeyFrames([ANIMATION_DATA[i]]);
-            }
             in02modelloadstate.value=true;
         }
         async function showMarker(type){