zdg #144

Merged
zhengdegang merged 24 commits from zdg into main 2024-08-16 13:42:41 +08:00
4 changed files with 52 additions and 23 deletions
Showing only changes of commit 75caf13d8b - Show all commits

View File

@ -173,3 +173,15 @@ export function endClass(id) {
params: {id} params: {id}
}) })
} }
/**
* @description 获取课堂信息
* @param {*} id
* @returns
*/
export function getClassInfo(id) {
return request({
url: '/smarttalk/classReserv/selectById',
method: 'get',
params: {id}
})
}

View File

@ -37,7 +37,7 @@ export class ImChat {
// this.userSig = sig // this.userSig = sig
this.userID = userID this.userID = userID
window.test = this window.test = this
this.timGroupId = '@TGS#3CYWMK2ON' // 测试使用 // this.timGroupId = '@TGS#3CYWMK2ON' // 测试使用
if (isInit) return this.init() if (isInit) return this.init()
} }
// 设置配置 // 设置配置
@ -131,7 +131,6 @@ export class ImChat {
} else { } else {
if (status == 1) { // 已登录 if (status == 1) { // 已登录
console.log('已登录') console.log('已登录')
this.setGroupMsgReceive()
resolve({status, msg:'已登录'}) resolve({status, msg:'已登录'})
} else if (status == 2) { // 登录中 } else if (status == 2) { // 登录中
console.log('登录中') console.log('登录中')
@ -188,10 +187,10 @@ export class ImChat {
return this.timChat.TIMGroupCreate(option).then(res => { return this.timChat.TIMGroupCreate(option).then(res => {
if (res && res.code == 0) { if (res && res.code == 0) {
const timGroupId = res?.json_param?.create_group_result_groupid const timGroupId = res?.json_param?.create_group_result_groupid
if (!!timGroupId){ if (!!timGroupId && timGroupId != 'undefined'){
this.setConsole('%c创建群组成功', timGroupId) this.setConsole('%c创建群组成功', timGroupId)
this.timGroupId = timGroupId this.timGroupId = timGroupId
this.setGroupMsgReceive() // this.setGroupMsgReceive()
} }
} }
return res return res
@ -206,10 +205,12 @@ export class ImChat {
}) })
} }
// 设置群消息接收 // 设置群消息接收
setGroupMsgReceive() { setGroupMsgReceive(timGroupId) {
if (!this.timGroupId) this.timGroupId = timGroupId || ''
if (!this.timGroupId) return console.log('timGroupId为空')
return this.timChat.TIMMsgSetGroupReceiveMessageOpt({ return this.timChat.TIMMsgSetGroupReceiveMessageOpt({
groupId: this.timGroupId, groupId: this.timGroupId,
opt: TYPES.TIMReceiveMessageOpt.kTIMRecvMsgOpt_Not_Notify, opt: TYPES.TIMReceiveMessageOpt.kTIMRecvMsgOpt_Receive,
data: '', // 用户自定义数据 data: '', // 用户自定义数据
}) })
} }
@ -225,6 +226,8 @@ export class ImChat {
} }
// 发送消息 // 发送消息
sendMsg(conv_id, msg) { sendMsg(conv_id, msg) {
if (!conv_id) return console.log('conv_id为空')
if (typeof msg == 'object') msg = JSON.stringify(msg)
const option = { const option = {
conv_id, conv_id,
conv_type: TYPES.TIMConvType.kTIMConv_Group, conv_type: TYPES.TIMConvType.kTIMConv_Group,
@ -240,12 +243,12 @@ export class ImChat {
user_data: '', // 用户自定义数据 user_data: '', // 用户自定义数据
// callback: (data) => {} // callback: (data) => {}
} }
console.log('发送消息', option)
return this.timChat.TIMMsgSendMessageV2(option) return this.timChat.TIMMsgSendMessageV2(option)
} }
// 发送关闭(下课)消息 // 发送关闭(下课)消息
sendMsgClosed(){ sendMsgClosed(){
const msg = this.getMsgObj(MsgEnum.HEADS.MSG_closed, '下课', MsgEnum.TYPES.TEACHER) const msg = this.getMsgObj(MsgEnum.HEADS.MSG_closed, '下课', MsgEnum.TYPES.TEACHER)
console.log('发送关闭消息', msg)
return this.sendMsg(this.timGroupId, msg) return this.sendMsg(this.timGroupId, msg)
} }
// 获取消息对象 // 获取消息对象

View File

@ -58,7 +58,6 @@ const initImChat = async () => {
const createGroup = async (groupName) => { const createGroup = async (groupName) => {
if (!imChatObj.imChat) return if (!imChatObj.imChat) return
await imChatObj.imChat.createGroup(groupName) await imChatObj.imChat.createGroup(groupName)
// emits('change', {type:'createGroup', data: imChat.timGroupId})
emits('change', 'createGroup', imChatObj.imChat.timGroupId) emits('change', 'createGroup', imChatObj.imChat.timGroupId)
} }
// 退 // 退

View File

@ -39,7 +39,7 @@
// electron // electron
import { onMounted, ref, reactive, watchEffect } from 'vue' import { onMounted, ref, reactive, watchEffect } from 'vue'
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { ElMessageBox, ElMessage } from 'element-plus' import { ElMessageBox, ElMessage, ElLoading } from 'element-plus'
import * as classManageApi from '@/api/classManage' import * as classManageApi from '@/api/classManage'
import logo from '@root/resources/icon.png' // logo import logo from '@root/resources/icon.png' // logo
import boardVue from './components/board.vue' // - import boardVue from './components/board.vue' // -
@ -78,13 +78,26 @@ const btnList = [ // 工具栏按钮列表
// === === // === ===
onMounted(async() => { onMounted(async() => {
setTimeout(() => { setTimeout(() => {
getClassInfo() // ex3
resetStatus() // - resetStatus() // -
}, 200); }, 200);
}) })
// ==== === // ==== ===
// const test = (e) => { console.log('test', e) } //
const getClassInfo = async () => {
const { data } = await classManageApi.getClassInfo(classObj.id)
classObj.data = data
if(!data.ex3 || data.ex3 == 'undefined') { //
await imChatRef.value.imChatObj.imChat.createGroup(data.className)
const timGroupId = imChatRef.value.imChatObj.imChat.timGroupId
classManageApi.startClass(classObj.id, timGroupId) //
} else { //
// console.log(': ', data.ex3)
imChatRef.value.imChatObj.imChat.timGroupId = data.ex3
// imChatRef.value.imChatObj.imChat.setGroupMsgReceive(data.ex3)
}
}
// tab-change // tab-change
const tabChange = (val) => { const tabChange = (val) => {
const bool = !toolStore.isPdfWin && !toolStore.showBoardAll const bool = !toolStore.isPdfWin && !toolStore.showBoardAll
@ -108,7 +121,8 @@ const mouseChange = (bool) => {
// im-chat: {type, data} // im-chat: {type, data}
const chatChange = (type, data) => { const chatChange = (type, data) => {
if (type == 'createGroup') { // - if (type == 'createGroup') { // -
classManageApi.startClass(classObj.id, data) console.log('创建群:', data)
!!data && classManageApi.startClass(classObj.id, data)
} else if (type == 'msg') { // im-chat } else if (type == 'msg') { // im-chat
if (!data) return // msg if (!data) return // msg
const { msgKey:head, msgcontent:msg, senduserid:sendId, msgType } = data const { msgKey:head, msgcontent:msg, senduserid:sendId, msgType } = data
@ -167,18 +181,19 @@ const sideChange = async o => {
}).then(async() => { }).then(async() => {
await imChatRef.value?.imChatObj?.imChat?.sendMsgClosed() // await imChatRef.value?.imChatObj?.imChat?.sendMsgClosed() //
// const elMsg = ElMessage.warning({duration:0,message:'...'}) // const elMsg = ElMessage.warning({duration:0,message:'...'})
// // 2 const elMsg = ElLoading.service({lock: true, text: '正在下课...', background: 'rgba(0, 0, 0, 0.7)'})
// setTimeout(async() => { // 2
// elMsg.close() setTimeout(async() => {
// toolStore.isToolWin = false elMsg.close()
// await classManageApi.endClass(route.query.reservId) toolStore.isToolWin = false
// await imChatRef.value?.deleteGroup() // await classManageApi.endClass(route.query.reservId)
// await imChatRef.value?.logout() // 退im await imChatRef.value?.deleteGroup() //
// ipcMsgSend('tool-sphere:close') // await imChatRef.value?.logout() // 退im
// }, 2000); ipcMsgSend('tool-sphere:close') //
}, 2000);
isOver.value = false // isOver.value = false
setIgnore(true) // -穿 // setIgnore(true) // -穿
}).catch(() => { }).catch(() => {
isOver.value = false isOver.value = false
setIgnore(true) // -穿 setIgnore(true) // -穿