修改websocket上行方式

dev
26947 2024-10-09 21:29:22 +08:00
parent 431d639248
commit d3c39863b3
3 changed files with 24 additions and 21 deletions

View File

@ -678,9 +678,11 @@
console.log("消息发送成功");
})
} catch (e) {
console.log("eee:", e);
}
} catch (e) {
console.log("消息发送错误:", e);
proxy.$store.dispatch('webSockerInfo')
}
}
}

View File

@ -70,31 +70,34 @@ const fileTypeInfo2 = ref("video")
const QNDomain = store.state.user.QNDomain
const bgColor = ref('#6AA2FF');
const sendercont = ref([]);
//
watch(
() => proxy.$store.state.chat.userMessageinfo,
(newVal, oldVal) => {
console.log("新消息22", newVal);
console.log("旧数据:", sendercont.value);
newMessageInfo(newVal);
refresh();
},
{ deep: true }
);
console.log("新消息223", newVal);
newMessageInfo(newVal);
refresh();
}, {
deep: true
}
);
const newMessageInfo = (e) => {
const userIndex = sendercont.value.findIndex(user => user.receiverId == e.senderId);
console.log("数据12旧数据",sendercont.value);
const userIndex = sendercont.value.findIndex(user => user.receiverId == e.receiverId);
if(userIndex !== -1) {
sendercont.value[userIndex].messageText = e.messageText;
sendercont.value[userIndex].sendTime = e.sendTime;
console.log("数据13",sendercont.value[userIndex]);
//
//
if(e.status == 1){
sendercont.value[userIndex].statusone = 0
}else {
endercont.value[userIndex].statusone = 1
}
if (e.status == 0) {
sendercont.value[userIndex].statusone = 0
} else {
sendercont.value[userIndex].statusone = 1
}
refresh();
}
console.log("原始数据:",sendercont.value);
}
function refresh() {
//
@ -152,11 +155,10 @@ onShow(() => {
getUserRoles()
onWebSocket();
GetListSend();
// timer = setInterval(GetListSend, 60000);
})
function GetListSend() {
listmysend().then(res => {
console.log("信息:",res);
sendercont.value = res.rows;
})
}

View File

@ -61,7 +61,6 @@ const chat = {
});
socket.onMessage((event) => {
console.log("收到WebSocket消息", event.data);
const jsonObject = JSON.parse(event.data);
if (jsonObject.messageType == 51 || jsonObject.messageType == 52) {
console.log("聊天新消息111:", jsonObject);