lcw
This commit is contained in:
@ -19,11 +19,11 @@
|
||||
// 测试div组件,用于在后台和大屏页面都显示
|
||||
import { ref, onMounted, onUnmounted } from 'vue'
|
||||
import { Close } from '@element-plus/icons-vue'
|
||||
import WebSoketClass from '@/utils/webSocket.js'
|
||||
import emitter from "@/utils/eventBus.js"; // 导入事件总线
|
||||
import { qcckGet } from '@/api/qcckApi'
|
||||
import Item from './item.vue'
|
||||
import { AudioPlayerClass } from '@/utils/audioPlayer.js'
|
||||
const webSoket = new WebSoketClass()
|
||||
import {getItem} from '@/utils/storage.js'
|
||||
const dataList = ref([])
|
||||
const timekeeping = ref(null)
|
||||
const countdown = ref(0) // 倒计时时间(秒)
|
||||
@ -90,24 +90,56 @@ const resetCountdown = () => {
|
||||
}
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
|
||||
// 做一个定时器15s一次
|
||||
const checkNews = ref(null)
|
||||
const checkNewsInterval = 15000 // 15秒
|
||||
checkNews.value = setInterval(() => {
|
||||
dataModel()
|
||||
}, checkNewsInterval)
|
||||
onMounted(() => {
|
||||
// 初始化音频播放器
|
||||
initAudioPlayers()
|
||||
|
||||
emitter.on('webSocketMessage', (newsDate) => {
|
||||
if (newsDate) {
|
||||
dataList.value.unshift({...newsDate.data,typeMasgeLx:newsDate.type})
|
||||
// 根据消息类型播放音频
|
||||
playAudioByType(newsDate.type)
|
||||
dataList.value = newsDate
|
||||
// dataList.value.unshift({...newsDate.data,typeMasgeLx:newsDate.type})
|
||||
// 根据消息类型播放音频
|
||||
playAudioByType(newsDate[0].typeMasgeLx)
|
||||
resetCountdown()
|
||||
}
|
||||
})
|
||||
// 组件挂载时执行的操作
|
||||
webSoket.connect()
|
||||
console.log('组件挂载时执行的操作')
|
||||
})
|
||||
const idEntityCard = ref(getItem('idEntityCard'))
|
||||
const dataModel = () => {
|
||||
qcckGet({}, '/mosty-gsxt/dsjJbxx/message').then(res => {
|
||||
if (res) {
|
||||
const yjmasg = res.filter(item => item.type === '01')
|
||||
if (yjmasg.length > 0) {
|
||||
emitter.emit('openYp', yjmasg[0].obj); // 触发音频播放
|
||||
} else {
|
||||
const data=res.filter(item=>item.sfzList.includes(idEntityCard.value))
|
||||
const infoMasge =data.map(item => {
|
||||
return {
|
||||
...item.obj,
|
||||
typeMasgeLx: item.type
|
||||
}
|
||||
})
|
||||
console.log(infoMasge);
|
||||
emitter.emit('webSocketMessage', infoMasge)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
// if (newsDate.type === '01') {
|
||||
// // 触发音频播放
|
||||
// console.log('触发音频播放');
|
||||
// emitter.emit('openYp', newsDate.data); // 传递消息数据
|
||||
// } else {
|
||||
onUnmounted(() => {
|
||||
webSoket.closeConnection()
|
||||
emitter.off('webSocketMessage')
|
||||
if (timekeeping.value) {
|
||||
clearInterval(timekeeping.value)
|
||||
@ -118,6 +150,11 @@ onUnmounted(() => {
|
||||
player.destroy()
|
||||
}
|
||||
})
|
||||
// 清除定时器
|
||||
if (checkNews.value) {
|
||||
clearInterval(checkNews.value)
|
||||
checkNews.value = null
|
||||
}
|
||||
// 组件卸载时执行的操作
|
||||
console.log('组件卸载时执行的操作')
|
||||
})
|
||||
@ -143,6 +180,7 @@ onUnmounted(() => {
|
||||
transform: translateX(100%);
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
to {
|
||||
transform: translateX(0);
|
||||
opacity: 1;
|
||||
@ -180,11 +218,14 @@ onUnmounted(() => {
|
||||
}
|
||||
|
||||
@keyframes pulse {
|
||||
0%, 100% {
|
||||
|
||||
0%,
|
||||
100% {
|
||||
opacity: 1;
|
||||
transform: scale(1);
|
||||
box-shadow: 0 0 10px rgba(0, 255, 255, 0.8);
|
||||
}
|
||||
|
||||
50% {
|
||||
opacity: 0.8;
|
||||
transform: scale(1.2);
|
||||
@ -230,11 +271,14 @@ onUnmounted(() => {
|
||||
max-height: 150px;
|
||||
overflow-y: auto;
|
||||
padding: 12px;
|
||||
scrollbar-width: none; /* Firefox */
|
||||
-ms-overflow-style: none; /* IE and Edge */
|
||||
scrollbar-width: none;
|
||||
/* Firefox */
|
||||
-ms-overflow-style: none;
|
||||
/* IE and Edge */
|
||||
|
||||
&::-webkit-scrollbar {
|
||||
display: none; /* Chrome, Safari and Opera */
|
||||
display: none;
|
||||
/* Chrome, Safari and Opera */
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user