diff --git a/src/renderer/src/assets/iconfont/iconfont.css b/src/renderer/src/assets/iconfont/iconfont.css index 26de097..c1fab69 100644 --- a/src/renderer/src/assets/iconfont/iconfont.css +++ b/src/renderer/src/assets/iconfont/iconfont.css @@ -1,9 +1,9 @@ @font-face { font-family: "iconfont"; /* Project id 2794390 */ - src: url('iconfont.woff2?t=1724134927539') format('woff2'), - url('iconfont.woff?t=1724134927539') format('woff'), - url('iconfont.ttf?t=1724134927539') format('truetype'), - url('iconfont.svg?t=1724134927539#iconfont') format('svg'); + src: url('iconfont.woff2?t=1724212790213') format('woff2'), + url('iconfont.woff?t=1724212790213') format('woff'), + url('iconfont.ttf?t=1724212790213') format('truetype'), + url('iconfont.svg?t=1724212790213#iconfont') format('svg'); } .iconfont { @@ -14,6 +14,22 @@ -moz-osx-font-smoothing: grayscale; } +.icon-yiwen:before { + content: "\e687"; +} + +.icon-yiwen-01:before { + content: "\e688"; +} + +.icon-yihuo:before { + content: "\e689"; +} + +.icon-a-yiwen:before { + content: "\e6b1"; +} + .icon-zan:before { content: "\e658"; } diff --git a/src/renderer/src/assets/iconfont/iconfont.js b/src/renderer/src/assets/iconfont/iconfont.js index 03be20d..2ad9df4 100644 --- a/src/renderer/src/assets/iconfont/iconfont.js +++ b/src/renderer/src/assets/iconfont/iconfont.js @@ -1 +1 @@ -window._iconfont_svg_string_2794390='',(l=>{var h=(c=(c=document.getElementsByTagName("script"))[c.length-1]).getAttribute("data-injectcss"),c=c.getAttribute("data-disable-injectsvg");if(!c){var a,v,t,z,i,p=function(h,c){c.parentNode.insertBefore(h,c)};if(h&&!l.__iconfont__svg__cssinject__){l.__iconfont__svg__cssinject__=!0;try{document.write("")}catch(h){console&&console.log(h)}}a=function(){var h,c=document.createElement("div");c.innerHTML=l._iconfont_svg_string_2794390,(c=c.getElementsByTagName("svg")[0])&&(c.setAttribute("aria-hidden","true"),c.style.position="absolute",c.style.width=0,c.style.height=0,c.style.overflow="hidden",c=c,(h=document.body).firstChild?p(c,h.firstChild):h.appendChild(c))},document.addEventListener?~["complete","loaded","interactive"].indexOf(document.readyState)?setTimeout(a,0):(v=function(){document.removeEventListener("DOMContentLoaded",v,!1),a()},document.addEventListener("DOMContentLoaded",v,!1)):document.attachEvent&&(t=a,z=l.document,i=!1,d(),z.onreadystatechange=function(){"complete"==z.readyState&&(z.onreadystatechange=null,M())})}function M(){i||(i=!0,t())}function d(){try{z.documentElement.doScroll("left")}catch(h){return void setTimeout(d,50)}M()}})(window); \ No newline at end of file +window._iconfont_svg_string_2794390='',(c=>{var h=(l=(l=document.getElementsByTagName("script"))[l.length-1]).getAttribute("data-injectcss"),l=l.getAttribute("data-disable-injectsvg");if(!l){var a,t,z,p,i,v=function(h,l){l.parentNode.insertBefore(h,l)};if(h&&!c.__iconfont__svg__cssinject__){c.__iconfont__svg__cssinject__=!0;try{document.write("")}catch(h){console&&console.log(h)}}a=function(){var h,l=document.createElement("div");l.innerHTML=c._iconfont_svg_string_2794390,(l=l.getElementsByTagName("svg")[0])&&(l.setAttribute("aria-hidden","true"),l.style.position="absolute",l.style.width=0,l.style.height=0,l.style.overflow="hidden",l=l,(h=document.body).firstChild?v(l,h.firstChild):h.appendChild(l))},document.addEventListener?~["complete","loaded","interactive"].indexOf(document.readyState)?setTimeout(a,0):(t=function(){document.removeEventListener("DOMContentLoaded",t,!1),a()},document.addEventListener("DOMContentLoaded",t,!1)):document.attachEvent&&(z=a,p=c.document,i=!1,d(),p.onreadystatechange=function(){"complete"==p.readyState&&(p.onreadystatechange=null,M())})}function M(){i||(i=!0,z())}function d(){try{p.documentElement.doScroll("left")}catch(h){return void setTimeout(d,50)}M()}})(window); \ No newline at end of file diff --git a/src/renderer/src/assets/iconfont/iconfont.json b/src/renderer/src/assets/iconfont/iconfont.json index ef8e263..30d5f43 100644 --- a/src/renderer/src/assets/iconfont/iconfont.json +++ b/src/renderer/src/assets/iconfont/iconfont.json @@ -5,6 +5,34 @@ "css_prefix_text": "icon-", "description": "", "glyphs": [ + { + "icon_id": "20574719", + "name": "疑问", + "font_class": "yiwen", + "unicode": "e687", + "unicode_decimal": 59015 + }, + { + "icon_id": "21052326", + "name": "yiwen-01", + "font_class": "yiwen-01", + "unicode": "e688", + "unicode_decimal": 59016 + }, + { + "icon_id": "30456317", + "name": "疑惑", + "font_class": "yihuo", + "unicode": "e689", + "unicode_decimal": 59017 + }, + { + "icon_id": "33439935", + "name": "[疑问]", + "font_class": "a-yiwen", + "unicode": "e6b1", + "unicode_decimal": 59057 + }, { "icon_id": "1242129", "name": "赞", diff --git a/src/renderer/src/assets/iconfont/iconfont.svg b/src/renderer/src/assets/iconfont/iconfont.svg index e544243..8201a34 100644 --- a/src/renderer/src/assets/iconfont/iconfont.svg +++ b/src/renderer/src/assets/iconfont/iconfont.svg @@ -14,6 +14,14 @@ /> + + + + + + + + diff --git a/src/renderer/src/assets/iconfont/iconfont.ttf b/src/renderer/src/assets/iconfont/iconfont.ttf index f0461d5..43f8dc3 100644 Binary files a/src/renderer/src/assets/iconfont/iconfont.ttf and b/src/renderer/src/assets/iconfont/iconfont.ttf differ diff --git a/src/renderer/src/assets/iconfont/iconfont.woff b/src/renderer/src/assets/iconfont/iconfont.woff index e5f87d9..9fc1445 100644 Binary files a/src/renderer/src/assets/iconfont/iconfont.woff and b/src/renderer/src/assets/iconfont/iconfont.woff differ diff --git a/src/renderer/src/assets/iconfont/iconfont.woff2 b/src/renderer/src/assets/iconfont/iconfont.woff2 index 426cc8c..e1759ea 100644 Binary files a/src/renderer/src/assets/iconfont/iconfont.woff2 and b/src/renderer/src/assets/iconfont/iconfont.woff2 differ diff --git a/src/renderer/src/plugins/imChat/index.js b/src/renderer/src/plugins/imChat/index.js index 900f89b..ed48817 100644 --- a/src/renderer/src/plugins/imChat/index.js +++ b/src/renderer/src/plugins/imChat/index.js @@ -9,6 +9,7 @@ import * as TYPES from './enumbers' // sdk相关枚举 import MsgEnum from './msgEnum' // 消息相关枚举(自定义) import IMListeners from './imLiseners' // im消息-监听器 +// @ts-ignore const API = window.api // TIM生成签名 // import * as GenerateUserSig from './userSig' // 引入签名生成器 @@ -31,16 +32,23 @@ export class ImChat { } + /** + * @description 构造函数 + * @param {number} SDKAppID + * @param {string} userSig + * @param {string} userID + * @param {boolean} isInit + */ constructor(SDKAppID, userSig, userID, isInit) { this.SDKAppID = SDKAppID this.userSig = userSig this.userID = userID // window.test = this - if (isInit) return this.init() + if (isInit) this.init() } // 设置配置 async setConfig() { - const res=await this.timChat.TIMSetConfig({ // TIMSetConfigParam + await this.timChat.TIMSetConfig({ // TIMSetConfigParam json_config: { // JSONCongfig set_config_log_level: TYPES.TIMLogLevel.kTIMLog_Test, set_config_callback_log_level: TYPES.TIMLogLevel.kTIMLog_Error, @@ -87,15 +95,18 @@ export class ImChat { } // 生成签名 genTestUserSig() { - const options = { - SDKAppID: this.SDKAppID, - secretKey: this.secretKey, - userID: this.userID, - } - const { userSig } = GenerateUserSig.genTestUserSig(options) - this.userSig = userSig + // const options = { + // SDKAppID: this.SDKAppID, + // secretKey: this.secretKey, + // userID: this.userID, + // } + // const { userSig } = GenerateUserSig.genTestUserSig(options) + // this.userSig = userSig } - // 监听 + /** + * @description 监听消息 + * @param {Function} callback + */ watch(callback) { // // 先移除监听 // this.timChat.TIMRemoveRecvNewMsgCallback() @@ -167,7 +178,11 @@ export class ImChat { return error }) } - // 创建群组 群名和初始成员 userID + /** + * @description 创建群组 群名和初始成员 userID + * @param {any} name + * @param {any[]} memberList + */ createGroup(name, memberList=[]) { if (!this.timChat) return if (!!this.timGroupId) return console.log('群组已存在') @@ -216,7 +231,10 @@ export class ImChat { data: '', // 用户自定义数据 }) } - // 设置群消息接收 + /** + * @description 设置群消息接收 + * @param {string} timGroupId + */ setGroupMsgReceive(timGroupId) { if (!this.timGroupId) this.timGroupId = timGroupId || '' if (!this.timGroupId) return console.log('timGroupId为空') @@ -236,7 +254,11 @@ export class ImChat { return error }) } - // 发送消息 + /** + * @description 发送消息 + * @param {any} conv_id + * @param {any} msg + */ sendMsg(conv_id, msg) { if (!conv_id) return console.log('conv_id为空') if (typeof msg == 'object') msg = JSON.stringify(msg) @@ -255,15 +277,33 @@ export class ImChat { user_data: '', // 用户自定义数据 // callback: (data) => {} } - console.log('发送消息', option) + // console.log('发送消息', option) + this.setConsole('%cim-chat: 发送消息', option) return this.timChat.TIMMsgSendMessageV2(option) } + /** + * @description 发送群消息 + * @param {any} msg + * @param {*} head + * @param {*} type + */ + sendMsgGroup(msg, head, type) { + const msgObj = this.getMsgObj(head, msg, type) + // console.log('发送群消息', msgObj) + return this.sendMsg(this.timGroupId, msgObj) + } // 发送关闭(下课)消息 sendMsgClosed(){ - const msg = this.getMsgObj(MsgEnum.HEADS.MSG_closed, '下课', MsgEnum.TYPES.TEACHER) + const msg = this.getMsgObj(MsgEnum.HEADS.MSG_closed, '下课') return this.sendMsg(this.timGroupId, msg) } - // 获取消息对象 + /** + * @description 获取消息对象 + * @param {string} msgHead + * @param {string} msg + * @param {string} type + * @param {string|number} sender + */ getMsgObj(msgHead, msg, type, sender, option={}) { if (!msgHead) throw new Error('msgHead is required') if (!msg) throw new Error('msg is required') @@ -271,19 +311,27 @@ export class ImChat { return { msgKey: msgHead, msgcontent: msg, - msgType: type ?? MsgEnum.TYPES.STUDENT, // 默认为学生 + msgType: type || MsgEnum.TYPES.TEACHER, // 默认为老师 senduserid: sender ?? this.userID, ...option } } - // 设置控制台样式 + /** + * @description 设置控制台样式 + * @param {string} hearStr + * @param {string[]} args + */ setConsole(hearStr,...args) { const css = 'color: #fff;background-color:#2ccb92;padding:3px 5px;border-radius:3px;' const time = new Date().toLocaleTimeString() if (!hearStr) hearStr = '%c' + time console.log(hearStr, css, ...args) } - // 获取数据字符串 + /** + * @description 获取数据字符串 + * @param {*} data + * @returns + */ toStr = (data) => { if (typeof data === 'string') data = {type: data} return JSON.stringify(data) diff --git a/src/renderer/src/plugins/imChat/msgEnum.js b/src/renderer/src/plugins/imChat/msgEnum.js index dec2ba8..da8e486 100644 --- a/src/renderer/src/plugins/imChat/msgEnum.js +++ b/src/renderer/src/plugins/imChat/msgEnum.js @@ -95,6 +95,7 @@ export class MsgEnum { // === 新定义-消息头 === /** @desc: 点赞 */ MSG_0001: 0x0001, + /** @desc: 疑惑 */ MSG_0002: 0x0002, MSG_0003: 0x0003, MSG_0004: 0x0004, @@ -109,6 +110,7 @@ export class MsgEnum { MSG_0013: 0x000d, MSG_0014: 0x000e, MSG_0015: 0x000f, + /** @desc: 作业推送 */ MSG_0016: 0x0010, MSG_0017: 0x0011, MSG_0018: 0x0012, diff --git a/src/renderer/src/views/tool/components/homework.vue b/src/renderer/src/views/tool/components/homework.vue index 1ecbcf8..955b03b 100644 --- a/src/renderer/src/views/tool/components/homework.vue +++ b/src/renderer/src/views/tool/components/homework.vue @@ -77,14 +77,14 @@ import { getSmarttalkPage, getPrepareById } from '@/api/file' import SetHomework from '@/views/prepare/container/set-homework.vue' import FileImage from '@/components/file-image/index.vue' import { useGetHomework } from '@/hooks/useGetHomework' -import { ipcMsgSend } from '@/utils/tool' +import { ipcMsgSend, ipcMsgInvoke } from '@/utils/tool' import { useToolState } from '@/store/modules/tool' import { asyncLocalFile } from '@/utils/talkFile' import Lesson from './lesson.vue'; import { parseCataByNode } from '@/utils/talkFile' import outLink from '@/utils/linkConfig' +import MsgEnum from '@/plugins/imChat/msgEnum' // 消息枚举 -import { ipcMsgSend2 } from '@/utils/tool' const route = useRoute(); const usertore = useUserStore().user const toolStore = useToolState() @@ -110,8 +110,10 @@ const sendHomework = (row) => { setDialog.value = true } // -const closeHomework = () => { +const closeHomework = async() => { ipcMsgSend('tool-sphere:set:ignore', true) + // 发送im消息-推送作业(app|平板) + await ipcMsgInvoke('im-chat:msg', curRow.value.id, MsgEnum.HEADS.MSG_0016) setDialog.value = false } diff --git a/src/renderer/src/views/tool/components/imChat.vue b/src/renderer/src/views/tool/components/imChat.vue index ebb5407..b23b031 100644 --- a/src/renderer/src/views/tool/components/imChat.vue +++ b/src/renderer/src/views/tool/components/imChat.vue @@ -4,7 +4,7 @@ import { onMounted, ref, reactive, watchEffect } from 'vue' import { ImChat } from '@/plugins/imChat' import useUserStore from '@/store/modules/user' import * as http from '@/api/apiService' // 自定义api service -// import { ipcMsgSend, ipcHandle, ipcMain, ipcMsgInvoke } from '@/utils/tool' // 相关工具 +import { ipcMsgSend, ipcHandle, ipcMain, ipcMsgInvoke } from '@/utils/tool' // 相关工具 const userStore = useUserStore() const emits = defineEmits(['change']) const props = defineProps({ @@ -12,8 +12,7 @@ const props = defineProps({ }) const imChatObj = reactive({imChat:null}) onMounted(() => { - // console.log(imChatObj) - // initImChat() + ipcMainHandle() // 绑定-监听ipcMain im相关消息 }) // 初始化 im-chat const initImChat = async (timGroupId) => { @@ -95,6 +94,14 @@ const logout = () => imChatObj.imChat?.logout() // 解散群 const deleteGroup = () => imChatObj.imChat?.deleteGroup() +// 绑定-监听ipcMain im相关消息 +const ipcMainHandle = () => { + ipcMain?.removeHandler?.('im-chat:msg') // 先移除已有的 ipcMain 消息 + ipcMain?.handle?.('im-chat:msg', (e, msg, head, type) => { // 重新绑定 ipcMain 消息 + return imChatObj.imChat?.sendMsgGroup(msg, head, type) + }) +} + defineExpose({ initImChat, logout, deleteGroup, imChatObj }) diff --git a/src/renderer/src/views/tool/components/side.vue b/src/renderer/src/views/tool/components/side.vue index 4ab64a7..4da860f 100644 --- a/src/renderer/src/views/tool/components/side.vue +++ b/src/renderer/src/views/tool/components/side.vue @@ -1,8 +1,8 @@