|
|
|
@ -162,9 +162,10 @@ import ItemDialogScore from '@/views/classTask/container/classTask/item-dialog-s
|
|
|
|
|
import quizStats from '@/views/classTask/container/quizStats.vue'
|
|
|
|
|
import ClassOverview from '@/views/classTask/container/classOverview.vue'
|
|
|
|
|
import {sessionStore} from '@/utils/store'
|
|
|
|
|
import Chat from '@/utils/chat' // im 登录初始化
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// import Chat from '@/utils/chat' // im 登录初始化
|
|
|
|
|
import MsgEnum from '@/plugins/imChat/msgEnum' // im 消息枚举
|
|
|
|
|
import ChatWs from '@/plugins/socket' // 聊天socket
|
|
|
|
|
if (!ChatWs.ws) ChatWs.init()
|
|
|
|
|
const { proxy } = getCurrentInstance()
|
|
|
|
|
const emit = defineEmits(['cle-click'])
|
|
|
|
|
const props = defineProps({
|
|
|
|
@ -715,25 +716,35 @@ const closeDialog = () => {
|
|
|
|
|
const msgHandle = (msg) => {
|
|
|
|
|
const { type, data } = msg
|
|
|
|
|
switch(type) {
|
|
|
|
|
case 'TIMAddRecvNewMsgCallback': // 收到新消息 data=[]
|
|
|
|
|
{
|
|
|
|
|
(data||[]).forEach(o => {
|
|
|
|
|
const msgArr = o?.message_elem_array||[]
|
|
|
|
|
msgArr.forEach(info => {
|
|
|
|
|
const msgType = info?.elem_type // 消息类型 TIMElemType
|
|
|
|
|
const msgData = !!info.text_elem_content ? JSON.parse(info.text_elem_content)||'' : ''
|
|
|
|
|
// 处理学生端反馈得消息
|
|
|
|
|
//console.log('msgData->', msgData);
|
|
|
|
|
if (msgData.msgKey == "finishHomework"){
|
|
|
|
|
// 刷新
|
|
|
|
|
const data = JSON.parse(localStorage.getItem('teachClassWorkItem'));
|
|
|
|
|
//console.log('data->', data);
|
|
|
|
|
openDialog(data, false);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
break
|
|
|
|
|
case MsgEnum.HEADS.MSG_closed: // 下课:
|
|
|
|
|
window.close() // 关闭窗口
|
|
|
|
|
break
|
|
|
|
|
case MsgEnum.HEADS.MSG_finishHomework: // 跟新作业:
|
|
|
|
|
const data = JSON.parse(localStorage.getItem('teachClassWorkItem'));
|
|
|
|
|
openDialog(data, false);
|
|
|
|
|
break
|
|
|
|
|
case MsgEnum.HEADS.MSG_slideFlapping: // 切换页面
|
|
|
|
|
window.close() // 关闭窗口
|
|
|
|
|
break
|
|
|
|
|
// case 'TIMAddRecvNewMsgCallback': // 收到新消息 data=[]
|
|
|
|
|
// {
|
|
|
|
|
// (data||[]).forEach(o => {
|
|
|
|
|
// const msgArr = o?.message_elem_array||[]
|
|
|
|
|
// msgArr.forEach(info => {
|
|
|
|
|
// const msgType = info?.elem_type // 消息类型 TIMElemType
|
|
|
|
|
// const msgData = !!info.text_elem_content ? JSON.parse(info.text_elem_content)||'' : ''
|
|
|
|
|
// // 处理学生端反馈得消息
|
|
|
|
|
// //console.log('msgData->', msgData);
|
|
|
|
|
// if (msgData.msgKey == "finishHomework"){
|
|
|
|
|
// // 刷新
|
|
|
|
|
// const data = JSON.parse(localStorage.getItem('teachClassWorkItem'));
|
|
|
|
|
// //console.log('data->', data);
|
|
|
|
|
// openDialog(data, false);
|
|
|
|
|
// }
|
|
|
|
|
// })
|
|
|
|
|
// })
|
|
|
|
|
// }
|
|
|
|
|
// break
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -750,11 +761,21 @@ onMounted(() => {
|
|
|
|
|
isReloadTimer();
|
|
|
|
|
|
|
|
|
|
// im监听消息
|
|
|
|
|
if (!Chat.imChat) {
|
|
|
|
|
Chat.init(true, true, msgHandle);
|
|
|
|
|
} else {
|
|
|
|
|
Chat.listenMsg(msgHandle);
|
|
|
|
|
}
|
|
|
|
|
if (ChatWs.ws) {
|
|
|
|
|
ChatWs.watch((msg, e) => {
|
|
|
|
|
try {
|
|
|
|
|
msgHandle(JSON.parse(msg))
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('socket 解析异常 ', error, e)
|
|
|
|
|
msgHandle(msg)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
// if (!Chat.imChat) {
|
|
|
|
|
// Chat.init(true, true, msgHandle);
|
|
|
|
|
// } else {
|
|
|
|
|
// Chat.listenMsg(msgHandle);
|
|
|
|
|
// }
|
|
|
|
|
})
|
|
|
|
|
const isReloadTimer = () =>{
|
|
|
|
|
clearInterval(reloadTimer.value) // 关闭定时器
|
|
|
|
|