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