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..6cf016e --- /dev/null +++ b/src/renderer/src/AixPPTist/src/api/chat.ts @@ -0,0 +1,24 @@ +/** + * 统一处理消息 发送 避免找不到 + */ + +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') // 课堂信息 + const timgroupid = classcourse?.timgroupid // 群组id + if (!ChatWs.ws) ChatWs.init() + // 下课消息 + const exitCourse = async() => { + if(!timgroupid) throw new Error('未获取到群组ID') + await API_classcourse.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/classcourse.ts b/src/renderer/src/AixPPTist/src/api/classcourse.ts index e513f3c..21e7296 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,15 +41,12 @@ export class Classcourse { this.classcourse = classcourse // 课堂信息 this.id = classcourse.id // 课堂id // 如果课堂信息有paging,则更新当前页码 - const isPaging = !!classcourse.paging - if (isPaging) slidesStore.updateSlideIndex(classcourse.paging) - // 如果课堂信息有paging,则更新动画播放状态 - const isAnim = !!classcourse.cartoonTimes - if (isAnim) { // 动画播放 - for (let i = 0; i <= classcourse.cartoonTimes; i++) { - execPlay.runAnimation(true) // 异步执行动画 - } - } + const { paging, cartoonTimes } = classcourse + const isPaging = !!paging || paging === 0 + // 如果课堂信息有paging,则更新动画播放状态 + const isAnim = !!cartoonTimes || cartoonTimes === 0 + if (isPaging) slidesStore.updateSlideIndex(paging) + if (isAnim) slidesStore.updateAnimationIndex(cartoonTimes+1) // 课堂信息-状态管理 classcourseStore.setClasscourse(classcourse) // 待上课提示 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/upvote.ts b/src/renderer/src/AixPPTist/src/api/upvote.ts new file mode 100644 index 0000000..4e84407 --- /dev/null +++ b/src/renderer/src/AixPPTist/src/api/upvote.ts @@ -0,0 +1,33 @@ +/** + * 点赞组件-相关 + */ +export default class Upvote { + instance: any = null // 自身实例 + upvoteRef: any = null // 点赞组件 + constructor(elRef?: any) { + if(!!elRef) this.upvoteRef = elRef // 点赞组件 + if (!Upvote.Instance) { + Upvote.Instance = this + } + return Upvote.Instance + } + + // 初始化 + init(elRef) { + if(!!elRef) this.upvoteRef = elRef // 点赞组件 + return this + } + // 打开点赞或者疑问 1点赞 2疑问 + trigger(type) { + this.upvoteRef?.value?.trigger?.(type) + return this + } + // 静态方法-初始化 + static init(elRef) { + return new Upvote(elRef) + } + // 静态方法-打开点赞或者疑问 1点赞 2疑问 + static trigger(type) { + return new Upvote().trigger(type) + } +} \ 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 236c0e8..220ed53 100644 --- a/src/renderer/src/AixPPTist/src/api/watcher.ts +++ b/src/renderer/src/AixPPTist/src/api/watcher.ts @@ -11,8 +11,9 @@ import ChatWs from '@/plugins/socket' // 聊天socket import Classcourse from './classcourse' // 课程相关 import msgUtils from '@/plugins/modal' // 消息工具 import { Homework } from './index' // api-作业相关 -import emitter from '@/utils/mitt' //mitt 事件总线 +// import emitter from '@/utils/mitt' //mitt 事件总线 import useExecPlay from '../views/Screen/hooks/useExecPlay' // 播放控制 +import hooksUpvote from './upvote' // 点赞-工具 /** * @description 监听器 @@ -22,7 +23,7 @@ export default () => { const classcourseStore = store.useClasscourseStore() // 课堂信息-状态管理 const resource = sessionStore.get('curr.resource') // apt 资源 const smarttalk = sessionStore.get('curr.smarttalk') // 备课资源 - const execPlay = useExecPlay() // 播放控制 + const { execNext, turnPrevSlide } = useExecPlay() // 监听幻灯片内容变化 watch(() => slidesStore.slides, (newVal, oldVal) => { PPTApi.updateSlides(newVal, oldVal) // 更新幻灯片内容 @@ -36,7 +37,8 @@ export default () => { // 监听幻灯片下标变化 watch(() => slidesStore.slideIndex, (newVal, oldVal) => { - PPTApi.updateWorkList() + if (!!Classcourse.id) return // 上课状态,不更新右侧作业列表 + PPTApi.updateWorkList() // 更新作业列表 }) // 监听幻灯片下画布尺寸比例变化 watch(() => slidesStore.viewportRatio, (newVal, oldVal) => { @@ -97,8 +99,8 @@ export default () => { case MsgEnum.HEADS.MSG_slideFlapping: // 幻灯片翻页 const slideIndex = content?.current || 0 const type = content?.animation - if (type === 'Nextsteps') emitter.emit('useExecPlay', 'execNext') // 下一步 - else if (type === 'Previoustep') emitter.emit('useExecPlay', 'turnPrevSlide') // 上一步清空-动画 + if (type === 'Nextsteps') execNext(true) // 下一步-异步动画 + else if (type === 'Previoustep') turnPrevSlide() // 上一步清空-动画 else slidesStore.updateSlideIndex(slideIndex) // 更新幻灯片下标 break case MsgEnum.HEADS.MSG_homework: // 作业|活动-布置 @@ -109,10 +111,10 @@ export default () => { close() break case MsgEnum.HEADS.MSG_dz: // 点赞 - emitter.emit('upvoteTrigger', 1) + hooksUpvote.trigger(1) break case MsgEnum.HEADS.MSG_yh: // 疑惑 - emitter.emit('upvoteTrigger', 2) + hooksUpvote.trigger(2) break case MsgEnum.HEADS.MSG_0010: // 备用 break diff --git a/src/renderer/src/AixPPTist/src/store/classcourse.ts b/src/renderer/src/AixPPTist/src/store/classcourse.ts index bd77fbd..5d83314 100644 --- a/src/renderer/src/AixPPTist/src/store/classcourse.ts +++ b/src/renderer/src/AixPPTist/src/store/classcourse.ts @@ -3,16 +3,21 @@ import type { Classcourse } from '../api/types' export interface ClasscourseState { classcourse: Classcourse | any, // 课堂信息 + isEmit: boolean, // 是否加载监听事件(动画播放) } export const useClasscourseStore = defineStore('classcourse', { state: (): ClasscourseState => ({ classcourse: null, // 课堂信息 + isEmit: false, // 是否加载监听事件(动画播放) }), actions: { setClasscourse(classcourse: Classcourse) { this.classcourse = classcourse }, + setIsEmit(isEmit: boolean) { + this.isEmit = isEmit + }, }, }) \ No newline at end of file diff --git a/src/renderer/src/AixPPTist/src/store/slides.ts b/src/renderer/src/AixPPTist/src/store/slides.ts index d7a3bae..f3a23fa 100644 --- a/src/renderer/src/AixPPTist/src/store/slides.ts +++ b/src/renderer/src/AixPPTist/src/store/slides.ts @@ -33,7 +33,8 @@ export interface SlidesState { slides: Slide[] slideIndex: number viewportSize: number - viewportRatio: number + viewportRatio: number, + animationIndex: number, // 不是从0开始 workList:Object[], workItem:Object[], } @@ -46,6 +47,7 @@ export const useSlidesStore = defineStore('slides', { slideIndex: 0, // 当前页面索引 viewportSize: 1000, // 可视区域宽度基数 viewportRatio: 0.5625, // 可视区域比例,默认16:9 + animationIndex: 0, // 不是从0开始 workList:[],// 活动的列表 workItem:[],// 获取到的所有pptlist }), @@ -206,6 +208,9 @@ export const useSlidesStore = defineStore('slides', { updateSlideIndex(index: number) { this.slideIndex = index }, + updateAnimationIndex(index: number) { + this.animationIndex = index + }, addElement(element: PPTElement | PPTElement[]) { const elements = Array.isArray(element) ? element : [element] diff --git a/src/renderer/src/AixPPTist/src/views/Screen/BaseView.vue b/src/renderer/src/AixPPTist/src/views/Screen/BaseView.vue index ae2add1..8e7acf0 100644 --- a/src/renderer/src/AixPPTist/src/views/Screen/BaseView.vue +++ b/src/renderer/src/AixPPTist/src/views/Screen/BaseView.vue @@ -30,14 +30,10 @@ @close="timerlVisible = false" /> -
+
- -
- -
+
@@ -309,6 +278,9 @@ emitter.on('useExecPlay', (data: string|any) => { & + .tool-btn { margin-left: 15px; } + &.close{ + color: #d14424; + } } .page-number { font-size: 13px; diff --git a/src/renderer/src/AixPPTist/src/views/Screen/PresenterView.vue b/src/renderer/src/AixPPTist/src/views/Screen/PresenterView.vue index 4d2076d..a747a9c 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 @@
结束放映
+
结束课堂
@@ -55,7 +56,7 @@ :class="{ 'active': index === slideIndex }" v-for="(slide, index) in slides" :key="slide.id" - @click="turnSlideToIndex(index)" + @click="turnSlideTo(index, $event)" >
@@ -77,9 +78,9 @@