From 5d6c946e0814f86b13cbf6a0a4fe2b1485a2cea8 Mon Sep 17 00:00:00 2001 From: zdg Date: Mon, 16 Dec 2024 17:49:04 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/src/AixPPTist/src/api/chat.ts | 23 +++++++++++++++++++ src/renderer/src/AixPPTist/src/api/index.ts | 10 +++++++- src/renderer/src/AixPPTist/src/api/watcher.ts | 1 + .../AixPPTist/src/views/Screen/BaseView.vue | 11 +++++++++ .../src/views/Screen/PresenterView.vue | 10 ++++++++ src/renderer/src/plugins/socket/index.js | 3 --- src/renderer/src/utils/tool.js | 2 +- .../src/views/classTask/teachClassTask.vue | 7 +++++- 8 files changed, 61 insertions(+), 6 deletions(-) create mode 100644 src/renderer/src/AixPPTist/src/api/chat.ts diff --git a/src/renderer/src/AixPPTist/src/api/chat.ts b/src/renderer/src/AixPPTist/src/api/chat.ts new file mode 100644 index 0000000..92a5806 --- /dev/null +++ b/src/renderer/src/AixPPTist/src/api/chat.ts @@ -0,0 +1,23 @@ +/** + * 统一处理消息 发送 避免找不到 + */ + +import ChatWs from '@/plugins/socket' // 聊天socket +import { sessionStore } from '@/utils/store' // electron-store 状态管理 + +export default () => { + const classcourse = sessionStore.get('curr.classcourse') // 课堂信息 + const timgroupid = classcourse?.timgroupid // 群组id + if (!ChatWs.ws) ChatWs.init() + // 下课消息 + const exitCourse = async() => { + if(!timgroupid) throw new Error('未获取到群组ID') + await updateClasscourse({ id: classcourse.id, status: 'closed' }) + return ChatWs.closedCourse(timgroupid) + } + return { + exitCourse, + classcourse, + groupid: timgroupid, + } +} \ No newline at end of file diff --git a/src/renderer/src/AixPPTist/src/api/index.ts b/src/renderer/src/AixPPTist/src/api/index.ts index 685c367..203ba3e 100644 --- a/src/renderer/src/AixPPTist/src/api/index.ts +++ b/src/renderer/src/AixPPTist/src/api/index.ts @@ -258,6 +258,7 @@ export class PPTApi { } export class Homework{ + static win: null // 作业弹窗 // 作业弹窗 static async showHomework(id: any) { let result = await getClassWorkList(id) @@ -265,7 +266,14 @@ export class Homework{   localStorage.setItem('teachClassWorkItem', JSON.stringify(result[0]));   toolStore.isTaskWin=true; // 设置打开批改窗口 //   emit('closeActive') -   createWindow('open-taskwin',{url:'/teachClassTask'}); + // 重复打开,先关闭弹窗 + // if (this.win) this.win?.close?.() + this.win = await createWindow('open-taskwin',{url:'/teachClassTask'}) +  return this.win; + } + static closeHomework() { + if (this.win) this.win?.close?.() + this.win = null } } export default PPTApi \ No newline at end of file diff --git a/src/renderer/src/AixPPTist/src/api/watcher.ts b/src/renderer/src/AixPPTist/src/api/watcher.ts index f5d91cb..d4cea21 100644 --- a/src/renderer/src/AixPPTist/src/api/watcher.ts +++ b/src/renderer/src/AixPPTist/src/api/watcher.ts @@ -122,4 +122,5 @@ export default () => { window.close() // 关闭窗口 }, 1000) } + } diff --git a/src/renderer/src/AixPPTist/src/views/Screen/BaseView.vue b/src/renderer/src/AixPPTist/src/views/Screen/BaseView.vue index ae2add1..c8ef0b3 100644 --- a/src/renderer/src/AixPPTist/src/views/Screen/BaseView.vue +++ b/src/renderer/src/AixPPTist/src/views/Screen/BaseView.vue @@ -52,6 +52,7 @@ + @@ -74,6 +75,7 @@ import WritingBoardTool from './WritingBoardTool.vue' import CountdownTimer from './CountdownTimer.vue' import upvoteVue from '@/views/tool/components/upvote.vue' // 点赞-子组件 import emitter from '@/utils/mitt'; +import Chat from '../../api/chat' // 聊天 const props = defineProps<{ changeViewMode: (mode: 'base' | 'presenter') => void @@ -103,6 +105,7 @@ const { const { slideWidth, slideHeight } = useSlideSize() const { exitScreening } = useScreening() const { fullscreenState, manualExitFullscreen } = useFullscreen() +const chat:any = Chat() // 聊天室 const rightToolsVisible = ref(false) const writingBoardToolVisible = ref(false) @@ -192,6 +195,14 @@ const contextmenus = (): ContextmenuItem[] => { }, ] } + +// 下课 +const exitCourse = async () => { + // console.log('下课', chat) + await chat.exitCourse() // 下课消息 + exitScreening() // 结束放映 +} + // 打开点赞或者疑问 1点赞 2疑问 emitter.on('upvoteTrigger', (type) => { upvoteRef.value?.trigger(type) diff --git a/src/renderer/src/AixPPTist/src/views/Screen/PresenterView.vue b/src/renderer/src/AixPPTist/src/views/Screen/PresenterView.vue index 4d2076d..aabc72a 100644 --- a/src/renderer/src/AixPPTist/src/views/Screen/PresenterView.vue +++ b/src/renderer/src/AixPPTist/src/views/Screen/PresenterView.vue @@ -12,6 +12,7 @@
结束放映
+
结束课堂
@@ -94,6 +95,7 @@ import ScreenSlideList from './ScreenSlideList.vue' import WritingBoardTool from './WritingBoardTool.vue' import CountdownTimer from './CountdownTimer.vue' import Divider from '../../components/Divider.vue' +import Chat from '../../api/chat' // 聊天 const props = defineProps<{ changeViewMode: (mode: 'base' | 'presenter') => void @@ -122,12 +124,20 @@ const { slideWidth, slideHeight } = useSlideSize(slideListWrapRef) const { exitScreening } = useScreening() const { slidesLoadLimit } = useLoadSlides() const { fullscreenState, manualExitFullscreen } = useFullscreen() +const chat:any = Chat() // 聊天室 const remarkFontSize = ref(16) const currentSlideRemark = computed(() => { return parseText2Paragraphs(currentSlide.value.remark || '无备注') }) +// 下课 +const exitCourse = async () => { + // console.log('下课', chat) + await chat.exitCourse() // 下课消息 + exitScreening() // 结束放映 +} + const handleMousewheelThumbnails = (e: WheelEvent) => { if (!thumbnailsRef.value) return thumbnailsRef.value.scrollBy(e.deltaY, 0) diff --git a/src/renderer/src/plugins/socket/index.js b/src/renderer/src/plugins/socket/index.js index 5e9870f..5d9cd6c 100644 --- a/src/renderer/src/plugins/socket/index.js +++ b/src/renderer/src/plugins/socket/index.js @@ -167,9 +167,6 @@ export class ChatWs { return new Promise((resolve, reject) => { this.sendMsg('closed', '下课', null, 'group', id) resolve() - // setTimeout(() => { - // this.close() // 关闭链接 - // }, 1000); }) } // 延时 ms 毫秒 diff --git a/src/renderer/src/utils/tool.js b/src/renderer/src/utils/tool.js index 02aeae2..9673f11 100644 --- a/src/renderer/src/utils/tool.js +++ b/src/renderer/src/utils/tool.js @@ -225,7 +225,7 @@ export const createWindow = async (type, data) => { .filter(k => typeof data[k] === 'function') .forEach(k => events[k] = data[k]) eventHandles(type, win, events) // 事件监听处理 - break + return win } default: break diff --git a/src/renderer/src/views/classTask/teachClassTask.vue b/src/renderer/src/views/classTask/teachClassTask.vue index 3db91ae..83b5ec9 100644 --- a/src/renderer/src/views/classTask/teachClassTask.vue +++ b/src/renderer/src/views/classTask/teachClassTask.vue @@ -163,8 +163,10 @@ 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 { Homework } from '@/AixPPTist/src/api/index' import MsgEnum from '@/plugins/imChat/msgEnum' // im 消息枚举 import ChatWs from '@/plugins/socket' // 聊天socket +import { set } from 'lodash' if (!ChatWs.ws) ChatWs.init() const { proxy } = getCurrentInstance() const emit = defineEmits(['cle-click']) @@ -719,14 +721,17 @@ const msgHandle = (msg) => { const { head, content, ...other } = msg switch(head) { case MsgEnum.HEADS.MSG_closed: // 下课: + Homework.win = null window.close() // 关闭窗口 break case MsgEnum.HEADS.MSG_finishHomework: // 跟新作业: + console.log('更新作业', head, content) const data = JSON.parse(localStorage.getItem('teachClassWorkItem')); openDialog(data, false); break case MsgEnum.HEADS.MSG_slideFlapping: // 切换页面 console.log('切换页面-关闭窗口') + Homework.win = null window.close() // 关闭窗口 break // case 'TIMAddRecvNewMsgCallback': // 收到新消息 data=[] @@ -769,7 +774,7 @@ onMounted(() => { console.log('socket监听消息') ChatWs.watch((msg, e) => { try { - msgHandle(JSON.parse(msg)) + msgHandle(JSON.parse(msg)?.msg) } catch (error) { console.error('socket 解析异常 ', error, e) msgHandle(msg) -- 2.44.0.windows.1 From 0d38a1209478e55ace242a736f166db21f0b45df Mon Sep 17 00:00:00 2001 From: zdg Date: Tue, 17 Dec 2024 17:34:47 +0800 Subject: [PATCH 2/3] ppt --- src/renderer/src/AixPPTist/src/api/chat.ts | 3 +- .../src/AixPPTist/src/api/classcourse.ts | 29 ++++++--- src/renderer/src/AixPPTist/src/api/watcher.ts | 7 ++- .../AixPPTist/src/views/Screen/BaseView.vue | 60 +++++++++++-------- .../src/views/Screen/PresenterView.vue | 19 ++++-- .../src/views/Screen/hooks/useExecPlay.ts | 22 +++++-- .../src/views/classManage/reserv-item-apt.vue | 6 +- 7 files changed, 95 insertions(+), 51 deletions(-) diff --git a/src/renderer/src/AixPPTist/src/api/chat.ts b/src/renderer/src/AixPPTist/src/api/chat.ts index 92a5806..6cf016e 100644 --- a/src/renderer/src/AixPPTist/src/api/chat.ts +++ b/src/renderer/src/AixPPTist/src/api/chat.ts @@ -4,6 +4,7 @@ import ChatWs from '@/plugins/socket' // 聊天socket import { sessionStore } from '@/utils/store' // electron-store 状态管理 +import * as API_classcourse from '@/api/teaching/classcourse' // 后端api export default () => { const classcourse = sessionStore.get('curr.classcourse') // 课堂信息 @@ -12,7 +13,7 @@ export default () => { // 下课消息 const exitCourse = async() => { if(!timgroupid) throw new Error('未获取到群组ID') - await updateClasscourse({ id: classcourse.id, status: 'closed' }) + await API_classcourse.updateClasscourse({ id: classcourse.id, status: 'closed' }) return ChatWs.closedCourse(timgroupid) } return { diff --git a/src/renderer/src/AixPPTist/src/api/classcourse.ts b/src/renderer/src/AixPPTist/src/api/classcourse.ts index e513f3c..7e7e3c3 100644 --- a/src/renderer/src/AixPPTist/src/api/classcourse.ts +++ b/src/renderer/src/AixPPTist/src/api/classcourse.ts @@ -7,13 +7,13 @@ import { sessionStore } from '@/utils/store' // electron-store 状态管理 import * as useStore from '../store' // pptist-状态管理 import ChatWs from '@/plugins/socket' // 聊天socket import msgUtils from '@/plugins/modal' // 消息工具 -import useExecPlay from '../views/Screen/hooks/useExecPlay' // 播放控制 +import emitter from '@/utils/mitt' //mitt 事件总线 +import { nextTick } from 'vue' const slidesStore = useStore.useSlidesStore() // 幻灯片-状态管理 const screenStore = useStore.useScreenStore() // 全屏-状态管理 const classcourseStore = useStore.useClasscourseStore() // 课堂信息-状态管理 const classcourse = sessionStore.get('curr.classcourse') // 课堂信息 -const execPlay = useExecPlay() // 播放控制 export class Classcourse { msgObj:ElMessageBox = null // 提示消息对象 @@ -23,10 +23,12 @@ export class Classcourse { constructor() { this.load() } + // 延时 + sleep = ms => new Promise(resolve => setTimeout(resolve, ms)) /** * @description 加载 */ - load() { + async load() { console.log('classcourse-load', classcourse) // 打开全屏 const isCourse = !!classcourse @@ -39,13 +41,22 @@ export class Classcourse { this.classcourse = classcourse // 课堂信息 this.id = classcourse.id // 课堂id // 如果课堂信息有paging,则更新当前页码 - const isPaging = !!classcourse.paging - if (isPaging) slidesStore.updateSlideIndex(classcourse.paging) + const { paging } = classcourse + const isPaging = !!paging || paging === 0 + if (isPaging) { + console.log('更新当前页码', paging) + await this.sleep(200) + emitter.emit('useExecPlay', {key:'turnSlideToIndex', paging}) + await this.sleep(1000) // 如果课堂信息有paging,则更新动画播放状态 - const isAnim = !!classcourse.cartoonTimes - if (isAnim) { // 动画播放 - for (let i = 0; i <= classcourse.cartoonTimes; i++) { - execPlay.runAnimation(true) // 异步执行动画 + const isAnim = !!classcourse.cartoonTimes + if (isAnim) { // 动画播放 + console.log('动画播放1', classcourse) + for (let i = 0; i < classcourse.cartoonTimes; i++) { + console.log('动画播放2', i) + // 异步执行动画 + emitter.emit('useExecPlay', {key:'execNext', isAsync:true}) + } } } // 课堂信息-状态管理 diff --git a/src/renderer/src/AixPPTist/src/api/watcher.ts b/src/renderer/src/AixPPTist/src/api/watcher.ts index d4cea21..ef9f65f 100644 --- a/src/renderer/src/AixPPTist/src/api/watcher.ts +++ b/src/renderer/src/AixPPTist/src/api/watcher.ts @@ -37,7 +37,8 @@ export default () => { // 监听幻灯片下标变化 watch(() => slidesStore.slideIndex, (newVal, oldVal) => { - PPTApi.updateWorkList() + if (!!Classcourse.id) return // 上课状态,不更新右侧作业列表 + PPTApi.updateWorkList() // 更新作业列表 }) // 消息监听ws @@ -91,7 +92,8 @@ export default () => { case MsgEnum.HEADS.MSG_slideFlapping: // 幻灯片翻页 const slideIndex = content?.current || 0 const type = content?.animation - if (type === 'Nextsteps') emitter.emit('useExecPlay', 'execNext') // 下一步 + // if (type === 'Nextsteps') emitter.emit('useExecPlay', 'execNext') // 下一步 + if (type === 'Nextsteps') emitter.emit('useExecPlay', {key:'execNext', isAsync:true}) // 下一步 else if (type === 'Previoustep') emitter.emit('useExecPlay', 'turnPrevSlide') // 上一步清空-动画 else slidesStore.updateSlideIndex(slideIndex) // 更新幻灯片下标 break @@ -122,5 +124,4 @@ export default () => { window.close() // 关闭窗口 }, 1000) } - } diff --git a/src/renderer/src/AixPPTist/src/views/Screen/BaseView.vue b/src/renderer/src/AixPPTist/src/views/Screen/BaseView.vue index c8ef0b3..fc4940a 100644 --- a/src/renderer/src/AixPPTist/src/views/Screen/BaseView.vue +++ b/src/renderer/src/AixPPTist/src/views/Screen/BaseView.vue @@ -52,7 +52,7 @@ - +
@@ -61,7 +61,7 @@