类型:开发
描述:
This commit is contained in:
@@ -3,7 +3,7 @@ export function useWebSocket(url) {
|
||||
let socket = ref(null) // socket对象
|
||||
let isConnected = ref(false) // 是否连接成功
|
||||
let dataRes = ref(null) // 存储推送数据
|
||||
|
||||
let timer=null;
|
||||
const connectWebSocket = () => {
|
||||
socket.value = new WebSocket(url, 'echo-protocol', {
|
||||
headers: {
|
||||
@@ -28,6 +28,19 @@ export function useWebSocket(url) {
|
||||
socket.value.onclose = (event) => {
|
||||
isConnected.value = false
|
||||
console.log('WebSocket close:',url, event)
|
||||
if(!timer){
|
||||
timer =setInterval(() => {
|
||||
if(!isConnected.value){
|
||||
console.log('重连中...')
|
||||
connectWebSocket()
|
||||
}else if(isConnected.value){
|
||||
clearInterval(timer)
|
||||
timer = null;
|
||||
}
|
||||
}, 5000);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -105,9 +105,9 @@
|
||||
alt=""
|
||||
/>
|
||||
<img v-if="scenicSpotId == '龙桥河'" class="map-img" src="@/assets/images/lqh.jpg" alt="" /> -->
|
||||
<iframe v-if="scenicSpotId == 'root000000'" width="100%" height="100%" src="/map/sxzd/bdc.html"></iframe>
|
||||
<iframe v-if="scenicSpotId == 'root00000000'" width="100%" height="100%" src="/map/sxzd/sxzd.html"></iframe>
|
||||
<iframe v-if="scenicSpotId == '龙桥河'" width="100%" height="100%" src="/map/lqh/lqh.html"></iframe>
|
||||
<iframe v-if="scenicSpotId == 'root000000'" width="100%" height="100%" src="http://192.168.77.200/map/sxzd/bdc.html"></iframe>
|
||||
<iframe v-if="scenicSpotId == 'root00000000'" width="100%" height="100%" src="http://192.168.77.200/map/sxzd/sxzd.html"></iframe>
|
||||
<iframe v-if="scenicSpotId == '龙桥河'" width="100%" height="100%" src="http://192.168.77.200/map/lqh/lqh.html"></iframe>
|
||||
</div>
|
||||
<div class="flex">
|
||||
<div class="monitor">
|
||||
|
||||
@@ -25,9 +25,9 @@
|
||||
<!-- 查看详情-->
|
||||
<img src="@/assets/images/d-icon-1.png" />
|
||||
</a>
|
||||
<iframe v-if="scenicSpotId == 'root000000'" width="100%" height="100%" src="/map/sxzd/bdc.html"></iframe>
|
||||
<iframe v-if="scenicSpotId == 'root00000000'" width="100%" height="100%" src="/map/sxzd/sxzd.html"></iframe>
|
||||
<iframe v-if="scenicSpotId == '龙桥河'" width="100%" height="100%" src="/map/lqh/lqh.html"></iframe>
|
||||
<iframe v-if="scenicSpotId == 'root000000'" width="100%" height="100%" src="http://192.168.77.200/map/sxzd/bdc.html"></iframe>
|
||||
<iframe v-if="scenicSpotId == 'root00000000'" width="100%" height="100%" src="http://192.168.77.200//map/sxzd/sxzd.html"></iframe>
|
||||
<iframe v-if="scenicSpotId == '龙桥河'" width="100%" height="100%" src="http://192.168.77.200/map/lqh/lqh.html"></iframe>
|
||||
</div>
|
||||
<div class="footer">
|
||||
<div class="flex">
|
||||
|
||||
Reference in New Issue
Block a user