feat:完善功能

This commit is contained in:
zjc
2025-01-26 01:27:56 +08:00
parent fd726ead46
commit 21fb9a9c59
11 changed files with 165 additions and 23 deletions

View File

@@ -18,6 +18,8 @@
)
const homeStore = useHomeStore()
let timer = null
watch(
() => isConnected.value,
(val) => {
@@ -25,7 +27,7 @@
sendMessage(
JSON.stringify({
action: 'start',
type: 'index',
type: '',
scenicSpot: ''
})
)
@@ -35,8 +37,8 @@
watch(
() => dataRes.value,
(val) => {
console.log(val, '景区接受消息')
if (val) {
console.log(val, '首页接受消息')
switch (val.type) {
case 'userPortrait':
homeStore.setUserPortraitData(val.data)
@@ -78,9 +80,24 @@
homeStore.setHotelData(val.data)
break
}
if (!timer) sendCarShip()
}
}
)
const sendCarShip = (e) => {
timer = setInterval(() => {
if (isConnected.value) {
console.log('定时发送车船消息11')
sendMessage(
JSON.stringify({
action: 'start',
type: 'carShipData',
scenicSpotId: ''
})
)
}
}, 5000)
}
const switchSpot = (e) => {
sendMessage(
JSON.stringify({
@@ -90,4 +107,8 @@
})
)
}
onUnmounted(() => {
if (timer) clearInterval(timer)
})
</script>