From 027d0ebe07d940b40a31d2c303a33b2b1cd3a4ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Czouyf=E2=80=9D?= <80906036@qq.com> Date: Thu, 24 Oct 2024 14:44:53 +0800 Subject: [PATCH] =?UTF-8?q?[ppt=E4=B8=8A=E8=AF=BE]=20-=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E4=BD=9C=E4=B8=9A=E5=9B=9E=E7=AD=94=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E6=A3=80=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/src/utils/chat.js | 14 +-- .../src/views/classTask/teachClassTask.vue | 89 +++++++++++++------ 2 files changed, 70 insertions(+), 33 deletions(-) diff --git a/src/renderer/src/utils/chat.js b/src/renderer/src/utils/chat.js index b3b06a8..aaefa2c 100644 --- a/src/renderer/src/utils/chat.js +++ b/src/renderer/src/utils/chat.js @@ -18,13 +18,13 @@ export class Chat { } return Chat.instance; } - /** - * 初始化 获取IM签名 - * @param {*} isInit : 是否初始化IM - * @param {*} isLogin : 是否登录IM - * @param {*} callback: 监听消息回调函数 - * @returns Promise - */ + /** + * 初始化 获取IM签名 + * @param {*} isInit : 是否初始化IM + * @param {*} isLogin : 是否登录IM + * @param {*} callback: 监听消息回调函数 + * @returns Promise + */ async init(isInit = true, isLogin = true, callback) { // 特殊处理,只传1个参数且为函数,则默认为callback,isInit和isLogin默认为true if (typeof isInit == 'function'){ diff --git a/src/renderer/src/views/classTask/teachClassTask.vue b/src/renderer/src/views/classTask/teachClassTask.vue index 34c1acf..75afdcd 100644 --- a/src/renderer/src/views/classTask/teachClassTask.vue +++ b/src/renderer/src/views/classTask/teachClassTask.vue @@ -157,6 +157,7 @@ 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 登录初始化 const { proxy } = getCurrentInstance() @@ -204,35 +205,38 @@ const classWorkAnalysisScore = reactive({ // form.name = newValue.label // } // ) -const openDialog = (data) => { +const openDialog = (data, isInit=true) => { console.log(data, '点击的item完成情况') + + if (isInit) { + classWorkAnalysis.title = data.uniquekey ? data.uniquekey + '--' : '' + classWorkAnalysis.worktype = data.worktype + classWorkAnalysis.workclass = data.workclass + // 重置学生列表 + tableRadio.list = [] + tableRadio.value = '1' + tableRadio.num0 = 0 + tableRadio.num1 = 0 - classWorkAnalysis.title = data.uniquekey ? data.uniquekey + '--' : '' - classWorkAnalysis.worktype = data.worktype - classWorkAnalysis.workclass = data.workclass - // 重置学生列表 - tableRadio.list = [] - tableRadio.value = '1' - tableRadio.num0 = 0 - tableRadio.num1 = 0 + classWorkAnalysis.open = true + // 默认显示是学生作业反馈 + classWorkAnalysis.view = 'studentview' + // 当前学习任务所包含的试题ID + classWorkAnalysis.entpcourseworklistarray = data.entpcourseworklistarray + // 默认选中的学生 + classWorkAnalysis.activeStudentQuizlist = [] + // 默认选中的试题 + classWorkAnalysis.activeQuizAnalysisData = [] - classWorkAnalysis.open = true - // 默认显示是学生作业反馈 - classWorkAnalysis.view = 'studentview' - // 当前学习任务所包含的试题ID - classWorkAnalysis.entpcourseworklistarray = data.entpcourseworklistarray - // 默认选中的学生 - classWorkAnalysis.activeStudentQuizlist = [] - // 默认选中的试题 - classWorkAnalysis.activeQuizAnalysisData = [] - - classWorkAnalysis.row = data - window.test = this - // zdg: 学生列表 - const studentArr = data.classworkdatastudentids - ? JSON.parse(`[${data.classworkdatastudentids}]`) - : [] - classWorkActiveData.studentList = studentArr + classWorkAnalysis.row = data + window.test = this + // zdg: 学生列表 + const studentArr = data.classworkdatastudentids + ? JSON.parse(`[${data.classworkdatastudentids}]`) + : [] + classWorkActiveData.studentList = studentArr + } + /** 学生完成情况分析--获取作业学生list数据 */ getClassWorkStudentList(data.id) @@ -638,6 +642,32 @@ const closeDialog = () => { emit('cle-click') } +// im监听消息回调 +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 + } +} + const reloadTimer = ref(0); // 开启定时查询,作业id是否刷新了,刷新了就重新获取 const cutid = ref(0); // 当前初始化的作业id onMounted(() => { @@ -649,6 +679,13 @@ onMounted(() => { // 开始定时查询 cutid.value = data.id; isReloadTimer(); + + // im监听消息 + if (!Chat.imChat) { + Chat.init(true, true, msgHandle); + } else { + Chat.listenMsg(msgHandle); + } }) const isReloadTimer = () =>{ clearInterval(reloadTimer.value) // 关闭定时器 -- 2.44.0.windows.1