diff --git a/src/renderer/src/layout/components/Header.vue b/src/renderer/src/layout/components/Header.vue index 2d813af..26ff23e 100644 --- a/src/renderer/src/layout/components/Header.vue +++ b/src/renderer/src/layout/components/Header.vue @@ -80,6 +80,8 @@ import { updateUserInfo } from '@/api/system/user' import logoIco from '@/assets/images/logo.png' import { listEvaluation } from '@/api/classManage/index' import { sessionStore } from '@/utils/store' +import Chat from '@/utils/chat' // im 登录初始化 +if (!Chat.imChat) Chat.init() let homeTitle = ref(import.meta.env.VITE_APP_TITLE) const { ipcRenderer } = window.electron || {} @@ -143,6 +145,7 @@ function handleCommand(command) { break case 'logout': logout() + Chat?.logout() // im 退出登录 break default: break diff --git a/src/renderer/src/layout/index.vue b/src/renderer/src/layout/index.vue index 09b8df4..c09647d 100644 --- a/src/renderer/src/layout/index.vue +++ b/src/renderer/src/layout/index.vue @@ -19,8 +19,11 @@ import AppMain from './components/AppMain.vue' import Uploader from './components/Uploader.vue' import AiChart from '@/components/ai-chart/index.vue' import uploaderState from '@/store/modules/uploader' +// import Chat from '@/utils/chat' let uploaderStore = ref(uploaderState()) +// window.test = Chat +// Chat.init() diff --git a/src/renderer/src/plugins/imChat/index.js b/src/renderer/src/plugins/imChat/index.js index 6cf8934..83f007f 100644 --- a/src/renderer/src/plugins/imChat/index.js +++ b/src/renderer/src/plugins/imChat/index.js @@ -70,7 +70,10 @@ export class ImChat { // 日志监听 this.timChat.TIMSetLogCallback({ callback: data => { - this.setConsole('%cchat-log ', data[1]) + const [type, log] = data + if (type == log_level) { // 打印对应日志 + this.setConsole('%cchat-log ', log) + } }, user_data: '' }) @@ -86,7 +89,7 @@ export class ImChat { if (code == 0) { // 初始化成功 this.setConsole('%cim-chat: init', '初始化成功') this.status.isConnect = true - this.setConfig() // 设置日志级别 + // this.setConfig() // 设置日志级别 resolve(this) } else { // 失败:具体请看code console.error('[im-chat]:初始化失败', code) @@ -227,10 +230,11 @@ export class ImChat { }) } // 删除群组 - deleteGroup() { - if (!this.timGroupId) return + deleteGroup(timGroupId) { + const groupId = timGroupId || this.timGroupId + if (!groupId) return return this.timChat.TIMGroupDelete({ - groupId: this.timGroupId, + groupId, data: '', // 用户自定义数据 }) } @@ -249,7 +253,7 @@ export class ImChat { } // 获取群组列表 getGroupList() { - return this.timChat.getGroupList().then(res => { + return this.timChat.TIMGroupGetJoinedGroupList().then(res => { console.log('获取群组列表', res) return res }).catch(error => { diff --git a/src/renderer/src/utils/chat.js b/src/renderer/src/utils/chat.js new file mode 100644 index 0000000..44d962f --- /dev/null +++ b/src/renderer/src/utils/chat.js @@ -0,0 +1,98 @@ +/** +* 实现单例模式 +*/ +import useUserStore from '@/store/modules/user' +import { ImChat } from '@/plugins/imChat' +import * as http from '@/api/apiService' // 自定义api service + +export class Chat { + instance = null; + sdkAppId = 0; // 应用id + sign = ''; // 签名 + imUserId = ''; // 用户id + imChat = null; // IM实例 + + constructor() { + if (!Chat.instance) { // 存在的时候 + Chat.instance = this; + } + return Chat.instance; + } + /** + * 初始化 获取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'){ + callback = isInit + isInit = true + isLogin = true + } + const userStore = useUserStore() + const { timuserid: imUserId } = userStore.user + // 获取腾讯云签名 + const res = await http.imChat.getTxCloudSign({imUserId}) + if (res && res.code == 200) { + const { sdkAppId, sign } = res.data + this.sdkAppId = sdkAppId + this.sign = sign + this.imUserId = imUserId + // 初始化IM + if (isInit) return await this.initIM(isLogin, callback) + } + } + // 初始化IM + async initIM(isLogin, callback) { + const imChat = new ImChat(this.sdkAppId, this.sign, this.imUserId) + this.imChat = imChat + await imChat.init() // 初始化IM + callback && this.listenMsg(callback) // 监听消息 + if(isLogin) await imChat.login() // 登录IM + return imChat + } + // 监听消息 + async listenMsg(callback) { + if (!callback) return + if (!this.imChat) return + await this.imChat?.watch(msg => callback(msg)) + } + // 解散群 + async dismissGroup(groupId) { + if (!this.imChat) return + await this.imChat?.deleteGroup(groupId) + } + // 退出登录 + async logout() { + if (!this.imChat) return + await this.imChat?.logout() + imChat = null + this.imChat = null + } + // 发群消息 + async sendMsg(conv_id, msg) { + if (!this.imChat) return + await this.imChat?.sendMsg(conv_id, msg) + } + // 发群消息 + async sendMsgGroup(msg, head, type) { + if (!this.imChat) return + this.imChat?.sendMsgGroup(msg, head, type) + } + // 发群消息 + async sendMsgGroupId(groupId, msg, head, type) { + if (!this.imChat) return + const msgObj = this.imChat?.getMsgObj(head, msg, type) + this.imChat?.sendMsg(groupId, msgObj) + } + // 获取群列表 + async getGroupList() { + if (!this.imChat) return + return await this.imChat?.getGroupList() + } +} + +export default new Chat() \ No newline at end of file diff --git a/src/renderer/src/views/classManage/classReserv.vue b/src/renderer/src/views/classManage/classReserv.vue index b5c6e53..ccb539c 100644 --- a/src/renderer/src/views/classManage/classReserv.vue +++ b/src/renderer/src/views/classManage/classReserv.vue @@ -11,6 +11,7 @@ v-if="item.bookImg" @open-edit="reservDialog.openDialog(item)" @delete-reserv="deleteReserv(item)" + @change="(...o) => emit('change', ...o)" > @@ -34,6 +36,10 @@ import Reserv from '@/views/prepare/container/reserv.vue' import { useToolState } from '@/store/modules/tool' import useUserStore from '@/store/modules/user' import ReservItemApt from '@/views/classManage/reserv-item-apt.vue' +// import Chat from '@/utils/chat' // im 登录初始化 +// if (!Chat.imChat) Chat.init() + +const emit = defineEmits(['change']) const reservDialog = ref(null) const tabOptions = ref(['进行中', '已结束']) const tabActive = ref('进行中') diff --git a/src/renderer/src/views/classManage/reserv-item-apt.vue b/src/renderer/src/views/classManage/reserv-item-apt.vue index 879b406..57f2596 100644 --- a/src/renderer/src/views/classManage/reserv-item-apt.vue +++ b/src/renderer/src/views/classManage/reserv-item-apt.vue @@ -7,14 +7,14 @@ {{item.caption}}
- 已结束 + 已结束 上课中 继续上课 - 下课下课{{ loading?'中...':'' }}
@@ -25,13 +25,14 @@
\ No newline at end of file diff --git a/src/renderer/src/views/classTask/container/item-dialog-score.vue b/src/renderer/src/views/classTask/container/classTask/item-dialog-score.vue similarity index 99% rename from src/renderer/src/views/classTask/container/item-dialog-score.vue rename to src/renderer/src/views/classTask/container/classTask/item-dialog-score.vue index dd8851b..0238d55 100644 --- a/src/renderer/src/views/classTask/container/item-dialog-score.vue +++ b/src/renderer/src/views/classTask/container/classTask/item-dialog-score.vue @@ -196,7 +196,7 @@
-
+
温馨提示:点击此处 可预览其他类型附件! @@ -245,7 +245,7 @@
-
+
温馨提示:点击此处 可预览其他类型附件! diff --git a/src/renderer/src/views/classTask/container/classTask/prevReadImgFileDialog.vue b/src/renderer/src/views/classTask/container/classTask/prevReadImgFileDialog.vue new file mode 100644 index 0000000..2205b17 --- /dev/null +++ b/src/renderer/src/views/classTask/container/classTask/prevReadImgFileDialog.vue @@ -0,0 +1,179 @@ + + + + + diff --git a/src/renderer/src/views/classTask/container/task-item.vue b/src/renderer/src/views/classTask/container/classTask/task-item.vue similarity index 100% rename from src/renderer/src/views/classTask/container/task-item.vue rename to src/renderer/src/views/classTask/container/classTask/task-item.vue diff --git a/src/renderer/src/views/classTask/container/item-dialog.vue b/src/renderer/src/views/classTask/container/item-dialog.vue index baf2a41..e8624f5 100644 --- a/src/renderer/src/views/classTask/container/item-dialog.vue +++ b/src/renderer/src/views/classTask/container/item-dialog.vue @@ -167,7 +167,7 @@ import useUserStore from '@/store/modules/user' import { ElMessage } from 'element-plus' import { getCurrentTime, getAfterMinutes } from '@/utils/date' import { processList } from '@/hooks/useProcessList' -import ItemDialogScore from '@/views/classTask/container/item-dialog-score.vue' +import ItemDialogScore from '@/views/classTask/container/classTask/item-dialog-score.vue' // zdg: 组件导入 import quizStats from '@/views/classTask/container/quizStats.vue' import ClassOverview from '@/views/classTask/container/classOverview.vue' diff --git a/src/renderer/src/views/classTask/container/newTask/prevReadMsg-Dialog.vue b/src/renderer/src/views/classTask/container/newTask/prevReadMsg-Dialog.vue new file mode 100644 index 0000000..a96cd04 --- /dev/null +++ b/src/renderer/src/views/classTask/container/newTask/prevReadMsg-Dialog.vue @@ -0,0 +1,148 @@ + + + + + diff --git a/src/renderer/src/views/classTask/container/newTask/taskTypeView.vue b/src/renderer/src/views/classTask/container/newTask/taskTypeView.vue index 493c9f0..022bc4d 100644 --- a/src/renderer/src/views/classTask/container/newTask/taskTypeView.vue +++ b/src/renderer/src/views/classTask/container/newTask/taskTypeView.vue @@ -222,25 +222,8 @@
- - - -
- -
- - -
+ +
@@ -260,16 +243,16 @@ import { listKnowledgePoint } from "@/api/knowledge/knowledgePoint"; import { useGetHomework } from '@/hooks/useGetHomework' import { processList } from '@/hooks/useProcessList' import { getCurrentTime } from '@/utils/date' -import FlowChart from "@/components/Flowchart/index.vue"; import FileUpload from "@/components/FileUpload/index.vue"; import whiteboard from '@/components/whiteboard/whiteboard.vue' - +import prevReadMsgDialog from '@/views/classTask/container/newTask/prevReadMsg-Dialog.vue' import { useToolState } from '@/store/modules/tool' import useUserStore from '@/store/modules/user' const userStore = useUserStore().user const { proxy } = getCurrentInstance() const router = useRouter() +const toolStore = useToolState() const props = defineProps({ bookobj: { @@ -286,12 +269,8 @@ const props = defineProps({ } }) +const prevReadMsgDialogRef = ref(null);// 预览框ref -const isDialogOpen = ref(false) -const toolStore = useToolState() -const openDialog = () => { - isDialogOpen.value = true -} const classWorkFormRef = ref(null); const entpCourseWorkTypeList = ref([ {value: 0, label: "不限"}, @@ -372,12 +351,6 @@ const listWorkType = ref(['习题训练', '框架梳理', '课堂展示', '常 // 课堂展示------- const boardLoading = ref(false); -const prevReadMsg = reactive({ - visible: false, - type: "" -});// 预览msg -// 框架梳理---------- -const flowData = ref({})// 框架梳理 //常规作业---------- const fileLoading = ref(false); // 常规作业loading @@ -388,8 +361,6 @@ const changeFormType = (val) => { classWorkForm.worktype = val; } -console.log(props.propsformobj) -console.log(classWorkForm,'==============zizujian===================') /** * @desc: 根据查询参数查询试题 * @return: {*} @@ -565,61 +536,7 @@ const handleClassWorkQuizAdd = (fromsrc, entpcourseworkid) => { * 预览资源 */ const prevRead = async (item) => { - prevReadMsg.visible = true; - prevReadMsg.type = item.worktype; - if (item.worktype==='课标研读'){ - //获取教材文件和批注信息 - listEvaluation({itemkey: 'subject', edusubject: userStore.edusubject, edustage: userStore.edustage}).then(res => { - // TODO 课标研读-还未接入 - console.log("课标研读-还未接入",res); - // this.versionObj = res.rows[0]; - // // 读取出课标文件的每一行 - // if (this.versionObj.fileurl.length > 0) { - // readFile({cluelink: this.versionObj.fileurl}).then(fileres => { - // this.versionObj.bookdata = fileres; - // this.activeTeachResOfStandard = item; - // }) - // } - }) - } - if (item.worktype==='目标设定'){ - // TODO 目标设定-还未接入 - // this.activeTeachResOfStandard = item; - } - if (item.worktype==='教材研读'){ - // TODO 教材研读-还未接入 - // getEvaluation(this.courseObj.evalrootid).then(bookres => { - // this.versionObj = bookres.data; - // if (this.versionObj.fileurl.length > 0) { - // readFile({cluelink: this.versionObj.fileurl}).then(fileres => { - // this.versionObj.bookdata = fileres; - // this.activeTeachResOfStandard = item; - // }) - // } - // }) - } - if (item.worktype==='框架梳理'){ - flowData.value = {}; - const { chapterId } = await useGetHomework(props.bookobj.node) - // this.entpcourseid = chapterId - let queryParams = { - entpcourseid: chapterId, - ppttype: '教材分析', - parentid: item.id, - title: '逻辑框架建构', - filetype: 'draw' - } - listEntpcoursefile(queryParams).then(response=>{ - if (response.rows.length == 0) { - return; - } - flowData.value = JSON.parse(response.rows[0].datacontent) - }) - } - if (item.worktype==='学科定位'){ - // TODO 学科定位-还未接入 - // this.activeTeachResOfStandard = item; - } + proxy.$refs.prevReadMsgDialogRef.openDialog(item); }; /** * 添加到作业 @@ -831,7 +748,10 @@ const handleClassWorkSave = async () => { } }); }; - +/** + * 编辑作业内容 + * @param cform 表单数据 + */ const editWork = async (cform) =>{ // 基础参数 cform.id= classWorkForm.id; diff --git a/src/renderer/src/views/classTask/teachClassTask.vue b/src/renderer/src/views/classTask/teachClassTask.vue index 732f322..e4944a9 100644 --- a/src/renderer/src/views/classTask/teachClassTask.vue +++ b/src/renderer/src/views/classTask/teachClassTask.vue @@ -152,7 +152,7 @@ import useUserStore from '@/store/modules/user' import { ElMessage } from 'element-plus' import { getCurrentTime, getAfterMinutes } from '@/utils/date' import { processList } from '@/hooks/useProcessList' -import ItemDialogScore from '@/views/classTask/container/item-dialog-score.vue' +import ItemDialogScore from '@/views/classTask/container/classTask/item-dialog-score.vue' // zdg: 组件导入 import quizStats from '@/views/classTask/container/quizStats.vue' import ClassOverview from '@/views/classTask/container/classOverview.vue' diff --git a/src/renderer/src/views/prepare/container/class-start.vue b/src/renderer/src/views/prepare/container/class-start.vue index b4c6d7c..ec0d01d 100644 --- a/src/renderer/src/views/prepare/container/class-start.vue +++ b/src/renderer/src/views/prepare/container/class-start.vue @@ -24,9 +24,10 @@ @@ -118,7 +119,9 @@ const dt = reactive({ // 其他数据 isHistory: false, // 是否显示-历史记录 loading: false, // 加载-loading loadingDel: false, // 删除-loading + atClass: {}, // 当前班级 atCourse: {}, // 当前课程 + ctCourse: null, // 继续课程 }) let chat = null // im-chat 对象 @@ -128,9 +131,10 @@ onMounted(() => { }) /** * @description 暴露方法-打开对话框 - * @param row 课件对象 + * @param id 课件id + * @param classObj 课程对象-用于继续上课 */ -const open = async (id) => { +const open = async (id, classObj) => { visible.value = true if (id) { // 重置数据 @@ -139,6 +143,11 @@ const open = async (id) => { await getAptInfo(id) // 获取班级列表 getClassList() + // 继续上课 + if (!!classObj) { + dt.ctCourse = classObj + teacherForm.form.classcourseid = classObj.id + } // 初始化im-chat nextTick(async() => { chat = await imChatRef.value?.initImChat() @@ -148,8 +157,9 @@ const open = async (id) => { // 关闭弹窗 const handleClose = async () => { reset() // 重置数据 - await chat?.logout() - chat = null + // await chat?.logout() + // chat = null + dt.ctCourse = null emit('close') } // 初始化-数据 @@ -177,8 +187,10 @@ const reset = () => { teacherForm.form = { classcourseid: 0 } dt.isCreate = false dt.isHistory = false + dt.atClass = {} dt.atCourse = {} } + // 获取课件APT const getAptInfo = async (id) => { const res = await Http_Entpcoursefile.getEntpcoursefile(id) @@ -338,9 +350,9 @@ const chatChange = (type, data, ...args) => { // 监听-班级id watch(() => classForm.form.classid, (val)=> { // 获取选中课程 - dt.atCourse = listData.classList.find(o => o.id === val) || {} + dt.atClass = listData.classList.find(o => o.id === val) || {} // 获取选中课程-学生列表 - listData.activeStudentList = dt.atCourse?.classstudentlist || [] + // listData.activeStudentList = dt.atClass?.classstudentlist || [] // 清空课程列表 listData.classcourseList = [] // 如果当前显示历史, 就从新获取 diff --git a/src/renderer/src/views/prepare/container/kj-list-item.vue b/src/renderer/src/views/prepare/container/kj-list-item.vue index 57bbc7d..80fbb50 100644 --- a/src/renderer/src/views/prepare/container/kj-list-item.vue +++ b/src/renderer/src/views/prepare/container/kj-list-item.vue @@ -102,7 +102,7 @@ import { deleteSmarttalk, updateSmarttalk, getPrepareById } from '@/api/file' import useUserStore from '@/store/modules/user' import outLink from '@/utils/linkConfig' import { sessionStore } from '@/utils/store' -import { listClasscourseNew } from '@/api/teaching/classcourse' +import { listClasscourseNew, updateClasscourse } from '@/api/teaching/classcourse' import { endClass, getSelfReserv } from '@/api/classManage' import { listEntpcourse } from '@/api/teaching/classwork' import { createWindow } from '@/utils/tool' @@ -137,7 +137,7 @@ export default { } }, expose: ['openFileWin'], - emits: { 'on-start-class': null, 'on-delete': null, 'on-set': null, 'on-delhomework': null,'on-filearg': null }, + emits: { 'on-start-class': null, 'on-delete': null, 'on-set': null, 'on-delhomework': null,'on-filearg': null, 'change': null }, data() { return { listenList: [], @@ -148,27 +148,24 @@ export default { this.userInfo = useUserStore().user }, methods: { - getOpenCourse() { - return Promise.all([listClasscourseNew({teacherid: this.userInfo.userId,status:"open",evalid: this.curNode.id,pageSize:1000}), getSelfReserv({ex2:this.curNode.id})]).then(([res1,res2])=>{ - let list2 = res1.rows || [] - let list = res2.data || [] - let one = list.find(item1 => { - if (item1.status === "上课中") { - return true - } + // 获取当前上课的课程列表 + getOpenCourse(isApt) { + const curNodeId = this.curNode.id + if (isApt) { // APT课程 + const params = {teacherid: this.userInfo.userId,status:"open",evalid: curNodeId,pageSize:1000} + return listClasscourseNew(params).then(res => { + return (res.rows || []) }) - if (one) { - return one - } - if (list2.length>0) { - one = list2[0] - } - return one - }) + } else { // 普通课程PPT + return getSelfReserv({ex2: curNodeId}).then(res => { + return (res.data || []).filter(o => o.status === "上课中") + }) + } }, clickStartClass(item) { - this.getOpenCourse().then(res=>{ - if(!res){ + const isApt = item.fileFlag === 'apt' + this.getOpenCourse(isApt).then(res => { + if(!res || res.length === 0){ this.$emit('on-start-class', item) }else{ ElMessageBox.alert('上次课程尚未结束,是否继续上课?', '', { @@ -185,51 +182,80 @@ export default { confirmButtonClass: "el-button--danger", center: true, beforeClose: (action, instance, done) => { + const obj = res[0] + // console.log(action, obj, item) if (action === 'confirm'){ // 下课 - if (res.bookImg) { - //PPT - endClass(res.id).then((res1) => { - if (res1.data === true) { - ElMessage({ - message: '下课成功', - type: 'success' - }) - res.status = '已结束' - done() - } - }) - }else { - //APT - } + this.$emit('change', 'close', obj, { type: 1, instance, done }) + // if (obj.bookImg) { + // // //PPT + // // endClass(obj.id).then((res1) => { + // // if (res1.data === true) { + // // ElMessage({ + // // message: '下课成功', + // // type: 'success' + // // }) + // // obj.status = '已结束' + // // done() + // // } + // // }) + // }else { + // //APT 结束课程-父组件触发 + // // this.$emit('change', 'close', obj, { type: 1, instance, done }) + // // this.closeCourse(obj, instance, done) + // } } if (action === 'cancel'){ // 继续上课 - if (res.bookImg) { + if (obj.bookImg) { + console.log('PPT') //PPT listEntpcourse({ - evalid: res.ex2, + evalid: obj.ex2, edituserid: useUserStore().user.userId, pageSize: 500 }).then(async res1=>{ if (res1.rows[0].id) { - createWindow('tool-sphere', { url: '/tool/sphere?entpcourseid=' + res1.rows[0].id + "&reservId=" + res.id }) + createWindow('tool-sphere', { url: '/tool/sphere?entpcourseid=' + res1.rows[0].id + "&reservId=" + obj.id }) done() } }) }else { //APT + this.$emit('on-start-class', item, obj) + done() } } if (action === 'close') { done() } }, - }) + }).catch(() => {}) } }) // this.$emit('on-start-class', item) }, + // 结束课程(下课) + // async closeCourse(row, instance, done) { + // instance.confirmButtonLoading = true + // instance.confirmButtonText = '下课中...' + // // 发送-下课消息 + // if (!!row.timgroupid) { + // const msg = { msgKey: 'closed', actor: 'teacher', classcourseid: row.id } + // Chat.sendMsg(row.timgroupid, msg) + // } + // // 接口-修改状态 + // const params = { id: row.id, status: 'closed', timgroupid: '' } + // await updateClasscourse(params) + // // 解散群 + // setTimeout(async() => { + // if (!!row.timgroupid) await Chat.dismissGroup(row.timgroupid) + // instance.confirmButtonLoading = false + // instance.confirmButtonText = '下课' + // done() + // ElMessage({ type: 'success', message: `下课成功!` }) + // }, 1000) + // }, editTalk(item) { ElMessageBox.prompt('请输入新的标签', '添加标签', { confirmButtonText: '确认', diff --git a/src/renderer/src/views/prepare/index.vue b/src/renderer/src/views/prepare/index.vue index c5f4dcc..06e709f 100644 --- a/src/renderer/src/views/prepare/index.vue +++ b/src/renderer/src/views/prepare/index.vue @@ -28,12 +28,14 @@ :curNode="currentNode" @on-delete="deleteTalk" @on-start-class="startClass" + @change="changeClass" >
- +
@@ -161,16 +163,21 @@ import { parseCataByNode, creatPPT, asyncLocalFile } from '@/utils/talkFile' import FileOperBatch from '@/views/prepare/container/file-oper-batch.vue' import SetHomework from '@/components/set-homework/index.vue' import outLink from '@/utils/linkConfig' -import { createWindow, sessionStore, getAppInstallUrl } from '@/utils/tool' +import { createWindow, sessionStore, getAppInstallUrl, ipcMsgSend } from '@/utils/tool' import { cloneDeep } from 'lodash' import { delClasswork, listEntpcourse } from '@/api/teaching/classwork' -import { getClassInfo, getSelfReserv } from '@/api/classManage' +import { updateClasscourse } from '@/api/teaching/classcourse' +import { getClassInfo, getSelfReserv, endClass } from '@/api/classManage' import { useGetHomework } from '@/hooks/useGetHomework' import { addEntpcoursefileReturnId } from '@/api/education/entpcoursefile' import ClassReserv from '@/views/classManage/classReserv.vue' import classStart from './container/class-start.vue' // 预备上课 -const toolStore = useToolState() +import MsgEnum from '@/plugins/imChat/msgEnum' // im 消息枚举 +import Chat from '@/utils/chat' // im 登录初始化 +import msgEnum from '@/plugins/imChat/msgEnum' +if (!Chat.imChat) Chat.init() +const toolStore = useToolState() const fs = require('fs') const { ipcRenderer } = window.electron || {} @@ -279,7 +286,8 @@ export default { // } // }, methods: { - startClass(item) { + // 开始上课 + startClass(item, classObj) { // 关闭状态,打开上课相关功能(已打开,忽略) const id = sessionStore.has('activeClass.id') ? sessionStore.get('activeClass.id') : null if (id && id == item.id) return ElMessage.warning('当前正在上课,请勿重复操作') @@ -290,11 +298,68 @@ export default { this.openReserv() } if(item.fileFlag === 'apt') { - this.$refs.calssRef.open(item.fileId) + this.$refs.calssRef.open(item.fileId, classObj) + } + }, + // 继续上课-apt + async changeClass(type, row, other) { + switch(type) { + case 'continue': { // 继续上课 + const aptFileId = row.entpcoursefileid + this.$refs.calssRef.open(aptFileId, row) + break + } + case 'close': { // 关闭上课 + const head = MsgEnum.HEADS.MSG_closed // closed + const msgT = msgEnum.TYPES.TEACHER // teacher + const isApt = !row.bookImg // bookImg ppt 否则Apt + row.ex3 == 'undefined' && (row.ex3 = null) + const timgroupid = isApt ? row.timgroupid : row.ex3 // ex3 ppt 否则Apt + if (other.type == 1) { // 弹窗-下课 + other.instance.confirmButtonLoading = true + other.instance.confirmButtonText = '下课中...' + } else { // 列表-下课 + other.loading.value = true + } + // 发送-下课消息 + if (!!timgroupid) { + const msg = { msgKey: head, actor: msgT, classcourseid: row.id } + Chat.sendMsg(timgroupid, msg) + } + if (isApt) { // Apt + // 接口-修改状态 + await updateClasscourse({ id: row.id, status: head, timgroupid: '' }) + } else { // PPT + const toolStore = useToolState() + // 窗口已打开,直接关闭 + if (toolStore.isToolWin) { + toolStore.resetDef() // 重置状态 + ipcMsgSend('tool-sphere:close') // 关闭窗口 + } + // 接口-修改状态 + await endClass(row.id) + } + // 解散群 + setTimeout(async() => { + if (!!timgroupid) await Chat.dismissGroup(timgroupid) + if (other.type == 1) { // 弹窗-下课 + other.instance.confirmButtonLoading = false + other.instance.confirmButtonText = '下课' + other.done() + } else { + other.loading.value = false + row.status = isApt ? head : '已结束' + } + ElMessage({ type: 'success', message: `下课成功!` }) + }, 1000) + break + } + default: + break } }, closeChange() { // 上课弹窗被关闭-触发 - console.log('关闭上课弹窗') + // console.log('关闭上课弹窗') // this.activeClass = null sessionStore.delete('activeClass') }, diff --git a/src/renderer/src/views/tool/sphere.vue b/src/renderer/src/views/tool/sphere.vue index 1cc6d71..0a152e5 100644 --- a/src/renderer/src/views/tool/sphere.vue +++ b/src/renderer/src/views/tool/sphere.vue @@ -239,7 +239,7 @@ const sideChange = async o => { // 延迟2秒后关闭窗口,如果马上解散群,会导致群组不存在 setTimeout(async() => { await imChatRef.value?.deleteGroup() // 解散群 - await imChatRef.value?.logout() // 退出im + // await imChatRef.value?.logout() // 退出im elMsg.close() ipcMsgSend('tool-sphere:close') // 关闭窗口 }, 500);