From b0fca4ad9bd04908ef093dcb7cbf29895cb11af5 Mon Sep 17 00:00:00 2001 From: zdg Date: Wed, 18 Dec 2024 15:59:45 +0800 Subject: [PATCH 1/5] =?UTF-8?q?ppt=E4=B8=8A=E8=AF=BE-=E5=85=A8=E5=B1=8F?= =?UTF-8?q?=E6=BC=94=E8=AE=B2=E8=80=85=20=E7=82=B9=E8=B5=9E=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/AixPPTist/src/api/classcourse.ts | 19 ++----- src/renderer/src/AixPPTist/src/api/upvote.ts | 33 ++++++++++++ src/renderer/src/AixPPTist/src/api/watcher.ts | 14 ++--- .../src/AixPPTist/src/store/classcourse.ts | 5 ++ .../src/AixPPTist/src/store/slides.ts | 7 ++- .../AixPPTist/src/views/Screen/BaseView.vue | 53 ++----------------- .../src/views/Screen/PresenterView.vue | 7 +-- .../src/views/Screen/hooks/useExecPlay.ts | 9 ++-- .../src/AixPPTist/src/views/Screen/index.vue | 8 +++ .../src/views/tool/components/upvote.vue | 2 + 10 files changed, 79 insertions(+), 78 deletions(-) create mode 100644 src/renderer/src/AixPPTist/src/api/upvote.ts diff --git a/src/renderer/src/AixPPTist/src/api/classcourse.ts b/src/renderer/src/AixPPTist/src/api/classcourse.ts index b41091e..21e7296 100644 --- a/src/renderer/src/AixPPTist/src/api/classcourse.ts +++ b/src/renderer/src/AixPPTist/src/api/classcourse.ts @@ -41,21 +41,12 @@ export class Classcourse { this.classcourse = classcourse // 课堂信息 this.id = classcourse.id // 课堂id // 如果课堂信息有paging,则更新当前页码 - const { paging } = classcourse + const { paging, cartoonTimes } = classcourse const isPaging = !!paging || paging === 0 - if (isPaging) { - 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++) { - // 异步执行动画 - emitter.emit('useExecPlay', {key:'execNext', isAsync:true}) - } - } - } + // 如果课堂信息有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/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 35d8454..cb67de2 100644 --- a/src/renderer/src/AixPPTist/src/api/watcher.ts +++ b/src/renderer/src/AixPPTist/src/api/watcher.ts @@ -13,6 +13,7 @@ import msgUtils from '@/plugins/modal' // 消息工具 import { Homework } from './index' // api-作业相关 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) // 更新幻灯片内容 @@ -98,9 +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') // 下一步 - if (type === 'Nextsteps') emitter.emit('useExecPlay', {key:'execNext', isAsync:true}) // 下一步 - 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: // 作业|活动-布置 @@ -111,10 +111,12 @@ export default () => { close() break case MsgEnum.HEADS.MSG_dz: // 点赞 - emitter.emit('upvoteTrigger', 1) + // emitter.emit('upvoteTrigger', 1) + hooksUpvote.trigger(1) break case MsgEnum.HEADS.MSG_yh: // 疑惑 - emitter.emit('upvoteTrigger', 2) + // 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 fc4940a..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" /> -
+
- -
- -
diff --git a/src/renderer/src/components/grid-pic/viewer-item.vue b/src/renderer/src/components/grid-pic/viewer-item.vue new file mode 100644 index 0000000..f62bbfc --- /dev/null +++ b/src/renderer/src/components/grid-pic/viewer-item.vue @@ -0,0 +1,59 @@ + + + diff --git a/src/renderer/src/main.js b/src/renderer/src/main.js index fbf0a59..ab4962c 100644 --- a/src/renderer/src/main.js +++ b/src/renderer/src/main.js @@ -17,14 +17,14 @@ import log from 'electron-log/renderer' // 渲染进程日志-文件记录 import customComponent from '@/components/common' // 自定义组件 import plugins from './plugins' // plugins插件 import useUserStore from '@/store/modules/user' - +import VueViewer from 'v-viewer' +import 'viewerjs/dist/viewer.css' if(process.env.NODE_ENV != 'development') { // 非开发环境,将日志打印到日志文件 Object.assign(console, log.functions) // 渲染进程日志-控制台替换 } const app = createApp(App) - //专为菁优网配置的请求转发 app.config.globalProperties.$requestGetJYW = (url,config)=>{ config.params = config.params?config.params:{} @@ -42,6 +42,7 @@ import Directive from '@/AixPPTist/src/plugins/directive' app.use(router) .use(store) + .use(VueViewer) .use(ElementPlus, { locale: zhLocale }) .use(customComponent) // 自定义组件 .use(plugins) diff --git a/src/renderer/src/router/index.js b/src/renderer/src/router/index.js index 470b3b9..8f982da 100644 --- a/src/renderer/src/router/index.js +++ b/src/renderer/src/router/index.js @@ -31,6 +31,11 @@ export const constantRoutes = [ component: () => import('@/AixPPTist/src/App.vue'), hidden: true }, + { + path: '/gridPic', + component: () => import('@/components/grid-pic/index.vue'), + hidden: true + }, { path: '/model', component: Layout, diff --git a/src/renderer/src/views/prepare/index.vue b/src/renderer/src/views/prepare/index.vue index c593d06..ca770aa 100644 --- a/src/renderer/src/views/prepare/index.vue +++ b/src/renderer/src/views/prepare/index.vue @@ -10,6 +10,7 @@ 新建文枢课件 AI一键生成 + 打开宫格 导入PPT @@ -341,6 +342,14 @@ export default { // } // }, methods: { + openGridPic() { + createWindow('open-win', { + url: '/gridPic', // 窗口关闭时,清除缓存 + option: { + maximizable: true + } + }) + }, // 延时 sleep(ms){return new Promise(resolve => setTimeout(resolve, ms))}, addAiPPT(item) { From 45abab7a4179ef8e3bbbb4069ea574856770ebf6 Mon Sep 17 00:00:00 2001 From: zdg Date: Thu, 19 Dec 2024 11:14:14 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E5=85=AC=E5=B1=8F=E4=B8=8A=E8=AF=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/src/AixPPTist/src/api/chat.ts | 7 ++ .../src/AixPPTist/src/api/classcourse.ts | 9 ++- .../src/views/Screen/hooks/useExecPlay.ts | 14 ++-- .../views/prepare/container/class-start.vue | 18 +++-- src/renderer/src/views/prepare/index.vue | 68 +++++++++++++------ 5 files changed, 83 insertions(+), 33 deletions(-) diff --git a/src/renderer/src/AixPPTist/src/api/chat.ts b/src/renderer/src/AixPPTist/src/api/chat.ts index 6cf016e..8557f27 100644 --- a/src/renderer/src/AixPPTist/src/api/chat.ts +++ b/src/renderer/src/AixPPTist/src/api/chat.ts @@ -8,8 +8,15 @@ import * as API_classcourse from '@/api/teaching/classcourse' // 后端api export default () => { const classcourse = sessionStore.get('curr.classcourse') // 课堂信息 + const courseId = classcourse?.id // 课堂id const timgroupid = classcourse?.timgroupid // 群组id if (!ChatWs.ws) ChatWs.init() + // 开课消息 + const startCourse = async() => { + // await API_classcourse.updateClasscourse({ id: classcourse.id, status: 'open' }) + ChatWs.sendMsg('open', {id: courseId}) + return Promise.resolve() + } // 下课消息 const exitCourse = async() => { if(!timgroupid) throw new Error('未获取到群组ID') diff --git a/src/renderer/src/AixPPTist/src/api/classcourse.ts b/src/renderer/src/AixPPTist/src/api/classcourse.ts index 21e7296..e93fb0f 100644 --- a/src/renderer/src/AixPPTist/src/api/classcourse.ts +++ b/src/renderer/src/AixPPTist/src/api/classcourse.ts @@ -14,6 +14,7 @@ const slidesStore = useStore.useSlidesStore() // 幻灯片-状态管理 const screenStore = useStore.useScreenStore() // 全屏-状态管理 const classcourseStore = useStore.useClasscourseStore() // 课堂信息-状态管理 const classcourse = sessionStore.get('curr.classcourse') // 课堂信息 +const isPublic = sessionStore.get('curr.isPublic') // 是否公屏开课 export class Classcourse { msgObj:ElMessageBox = null // 提示消息对象 @@ -36,8 +37,14 @@ export class Classcourse { // 如果课堂信息有值,则连接socket if (isCourse) { // 连接socket - if (!ChatWs.ws) ChatWs.init() ChatWs.id = classcourse.timgroupid // 群组id + if (!ChatWs.ws) { + ChatWs.init().then(_ => { + console.log('socket-加载成功') + isPublic && ChatWs.sendMsg('open', {id: classcourse.id}) + isPublic && console.log('socket-开课消息-已发送') + }) + } this.classcourse = classcourse // 课堂信息 this.id = classcourse.id // 课堂id // 如果课堂信息有paging,则更新当前页码 diff --git a/src/renderer/src/AixPPTist/src/views/Screen/hooks/useExecPlay.ts b/src/renderer/src/AixPPTist/src/views/Screen/hooks/useExecPlay.ts index 860e37a..3838c08 100644 --- a/src/renderer/src/AixPPTist/src/views/Screen/hooks/useExecPlay.ts +++ b/src/renderer/src/AixPPTist/src/views/Screen/hooks/useExecPlay.ts @@ -6,6 +6,8 @@ import { KEYS } from '../../../configs/hotkey' import { ANIMATION_CLASS_PREFIX } from '../../../configs/animation' import message from '../../../utils/message' import emitter from '@/utils/mitt'; +import ChatWs from '@/plugins/socket' // 聊天socket +import { MsgEnum } from '../../../api/types' // 消息枚举 export default () => { const slidesStore = useSlidesStore() @@ -178,8 +180,7 @@ export default () => { // 鼠标滚动翻页 const mousewheelListener = (e: WheelEvent) => { // console.log('mousewheel', e) - // 课堂信息存在时,不允许翻页 - if (!!classcourseStore.classcourse) e.preventDefault() + e.preventDefault() // 阻止默认事件 mousewheelListenerThrottle(e) } const mousewheelListenerThrottle = throttle(function(e: WheelEvent) { @@ -212,10 +213,15 @@ export default () => { // 向上翻页/向下翻页 const turning = (e, type) => { e.preventDefault() // 阻止默认事件 - // 课堂信息存在时,不允许翻页 - if (!!classcourseStore.classcourse) return if (type === 'prev') execPrev() else if (type === 'next') execNext() + // 发送sokcet消息 + const isSend = classcourseStore.classcourse && !!ChatWs.ws && ChatWs.ws.readyState === 1 + console.log('isSend', isSend, ChatWs.ws.readyState) + if (isSend) { // 有课堂信息,发送,没有就是编辑状态 + // const head = MsgEnum.HEADS.MSG_slideFlapping + // ChatWs.sendMsg(head, {type}) + } } // 快捷键翻页 const keydownListener = (e: KeyboardEvent) => { diff --git a/src/renderer/src/views/prepare/container/class-start.vue b/src/renderer/src/views/prepare/container/class-start.vue index c9c518b..774facc 100644 --- a/src/renderer/src/views/prepare/container/class-start.vue +++ b/src/renderer/src/views/prepare/container/class-start.vue @@ -62,6 +62,7 @@
开始新的课堂,需要点击先创建课堂,才能显示手机二维码
开始新的课堂,需要点击先创建课堂
创建课堂 + 公屏上课
@@ -146,7 +147,7 @@ const open = async (id, classObj) => { await getAptInfo(id) // 获取班级列表 getClassList() - console.log('classObj', classObj) + // console.log('classObj', classObj) // 继续上课 if (!!classObj) { dt.ctCourse = classObj @@ -245,8 +246,8 @@ const getClasscourseList = async type => { } } } -// 创建课程 -const createClasscourse = async () => { +// 创建课程 isPublic 公屏上课 +const createClasscourse = async (isPublic = false) => { const { classid } = classForm.form if (!classid) { ElMessage.warning('请选择班级') @@ -255,8 +256,8 @@ const createClasscourse = async () => { dt.loading = true const { entpcourseid, evalid, id, coursetitle } = myClassActive.value // 课件对象 const curDate = commUtil.getDateNow('yyyy-MM-dd') - const params = { - id: 0, coursetype: '', courseverid: 0, coursedesc: '', status: '', + const params = { // 公屏上课直接 status = open + id: 0, coursetype: '', courseverid: 0, coursedesc: '', status: isPublic?'open':'', teacherid: userStore.id, entpcoursefileid: id, classid, entpcourseid, evalid, coursetitle, plandate: curDate, opendate: curDate @@ -274,7 +275,7 @@ const createClasscourse = async () => { setTimeout(async() => { msgEl.close() const res = await Http_Classcourse.getClasscourse(teacherForm.form.classcourseid) - openPublicScreen(res.data) + openPublicScreen(res.data, isPublic) }, 2000); }, 1000); } @@ -355,7 +356,7 @@ const getQrUrl = async() => { } // 打开公屏 -const openPublicScreen = (classcourse) => { +const openPublicScreen = (classcourse, isPublic) => { console.log('打开公屏', classcourse) if (!dt.ctCourse) { // 新开课需要发送消息-继续上课不需要直接打开 // 发送app端待开课消息 @@ -366,11 +367,14 @@ const openPublicScreen = (classcourse) => { const resource = toRaw(myClassActive.value) sessionStore.set('curr.resource', resource) // 缓存当前资源信息 sessionStore.set('curr.classcourse', classcourse) // 缓存当前当前上课 + // 公屏开课 + sessionStore.set('curr.isPublic', isPublic) // 缓存是否公屏开课 createWindow('open-win', { url: '/pptist', // 窗口关闭时,清除缓存 close: () => { sessionStore.set('curr.resource', null) // 清除缓存 sessionStore.set('curr.classcourse', null) // 清除缓存 + sessionStore.set('curr.isPublic', null) // 清除缓存 } }) visible.value = false // 关闭弹窗 diff --git a/src/renderer/src/views/prepare/index.vue b/src/renderer/src/views/prepare/index.vue index c593d06..3ab235a 100644 --- a/src/renderer/src/views/prepare/index.vue +++ b/src/renderer/src/views/prepare/index.vue @@ -367,7 +367,8 @@ export default { this.$refs.calssRef.open(item.fileId, classObj) } if(item.fileFlag === 'aippt') { - this.$refs.calssRef.open(item.fileId, classObj) + if (!!classObj) this.changeClass('continue', classObj) // 继续上课 + else this.$refs.calssRef.open(item.fileId, classObj) // 新开课 } }, // 继续上课-apt @@ -375,7 +376,18 @@ export default { switch(type) { case 'continue': { // 继续上课 const aptFileId = row.entpcoursefileid - this.$refs.calssRef.open(aptFileId, row) + const res = await getEntpcoursefile(aptFileId) + if (res.code == 200) { + const resource = res.data + if (resource.filetype != 'aippt') this.$refs.calssRef.open(aptFileId, row) + else { + const msgEl = ElMessage.warning({message:'正在打开公屏,请稍后...',duration: 0}) + setTimeout(()=>{ + msgEl.close() + this.openPublicScreen('class', resource, row) // 打开公屏-窗口 + }, 2000) + } + } else ElMessage.error(res.msg||'获取课件信息失败') break } case 'close': { // 关闭上课 @@ -428,16 +440,7 @@ export default { if (row.fileFlag === 'aippt' && !!row.fileId) { const res = await getEntpcoursefile(row.fileId) if (res && res.code === 200) { - sessionStore.set('curr.resource', res.data) // 缓存当前资源信息 - sessionStore.set('curr.smarttalk', row) // 缓存当前文件smarttalk - createWindow('open-win', { - url: '/pptist', // 窗口关闭时,清除缓存 - close: () => { - sessionStore.set('curr.resource', null) // 清除缓存 - sessionStore.set('curr.smarttalk', null) // 清除缓存 - this.asyncAllFile() // 刷新资源列表 - } - }) + this.openPublicScreen('edit', res.data, row) // 打开公屏-窗口 } else { ElMessage.warning(res.msg||'文件获取异常!') } @@ -462,21 +465,44 @@ export default { msgEl.close() // 关闭提示 const resource = res?.data||{} const classcourse = row - sessionStore.set('curr.resource', resource) // 缓存当前资源信息 - sessionStore.set('curr.classcourse', classcourse) // 缓存当前当前上课 - createWindow('open-win', { - url: '/pptist', // 窗口关闭时,清除缓存 - close: () => { - sessionStore.set('curr.resource', null) // 清除缓存 - sessionStore.set('curr.classcourse', null) // 清除缓存 - } - }) + this.openPublicScreen('class',resource, classcourse) // 打开公屏-窗口 + // sessionStore.set('curr.resource', resource) // 缓存当前资源信息 + // sessionStore.set('curr.classcourse', classcourse) // 缓存当前当前上课 + // createWindow('open-win', { + // url: '/pptist', // 窗口关闭时,清除缓存 + // close: () => { + // sessionStore.set('curr.resource', null) // 清除缓存 + // sessionStore.set('curr.classcourse', null) // 清除缓存 + // } + // }) break } default: break } }, + /** + * description 打开公屏 + * @param {string} type 类型 edit 打开 class 上课 + * @param {object} resource 资源信息 + * @param {object} currData 当前数据 type: edit/class 备课信息 | 课堂信息 + */ + openPublicScreen(type, resource, currData) { + sessionStore.set('curr.resource', resource) // 缓存当前资源信息 + if (type=='edit') sessionStore.set('curr.smarttalk', currData) // 缓存当前文件smarttalk + else sessionStore.set('curr.classcourse', currData) // 缓存当前当前上课 + createWindow('open-win', { + url: '/pptist', // 窗口关闭时,清除缓存 + close: () => { + sessionStore.set('curr.resource', null) // 清除缓存 + if (type=='edit') { + sessionStore.set('curr.smarttalk', null) // 清除缓存 + this.asyncAllFile() // 刷新资源列表 + } else sessionStore.set('curr.classcourse', null) // 清除缓存 + } + }) + }, + closeChange() { // 上课弹窗被关闭-触发 // console.log('关闭上课弹窗') // this.activeClass = null From dfc10aebbe2063cca61d2adae59737591bbae054 Mon Sep 17 00:00:00 2001 From: zdg Date: Thu, 19 Dec 2024 16:48:43 +0800 Subject: [PATCH 5/5] =?UTF-8?q?pptlist=E5=85=AC=E5=B1=8F=E4=B8=8A=E8=AF=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/src/AixPPTist/src/api/chat.ts | 29 ++++++++-- .../src/AixPPTist/src/api/classcourse.ts | 5 +- src/renderer/src/AixPPTist/src/api/types.ts | 2 + src/renderer/src/AixPPTist/src/api/watcher.ts | 9 ++-- .../src/views/Screen/hooks/useExecPlay.ts | 50 +++++++++-------- src/renderer/src/api/teaching/classcourse.js | 8 +++ src/renderer/src/directive/scroll.js | 26 +++++++++ src/renderer/src/plugins/imChat/msgEnum.js | 2 + .../src/views/classManage/classReserv.vue | 54 ++++++++++++++----- .../views/prepare/container/class-start.vue | 4 +- src/renderer/src/views/prepare/index.vue | 19 +++---- 11 files changed, 149 insertions(+), 59 deletions(-) create mode 100644 src/renderer/src/directive/scroll.js diff --git a/src/renderer/src/AixPPTist/src/api/chat.ts b/src/renderer/src/AixPPTist/src/api/chat.ts index 8557f27..1fd11fb 100644 --- a/src/renderer/src/AixPPTist/src/api/chat.ts +++ b/src/renderer/src/AixPPTist/src/api/chat.ts @@ -4,12 +4,16 @@ import ChatWs from '@/plugins/socket' // 聊天socket import { sessionStore } from '@/utils/store' // electron-store 状态管理 +import { useClasscourseStore } from '../store' import * as API_classcourse from '@/api/teaching/classcourse' // 后端api +import { MsgEnum } from './types' +// import msgUtils from '@/plugins/modal' // 消息工具 export default () => { const classcourse = sessionStore.get('curr.classcourse') // 课堂信息 const courseId = classcourse?.id // 课堂id const timgroupid = classcourse?.timgroupid // 群组id + const classcourseStore = useClasscourseStore() // 课堂信息-状态管理 if (!ChatWs.ws) ChatWs.init() // 开课消息 const startCourse = async() => { @@ -20,12 +24,31 @@ export default () => { // 下课消息 const exitCourse = async() => { if(!timgroupid) throw new Error('未获取到群组ID') - await API_classcourse.updateClasscourse({ id: classcourse.id, status: 'closed' }) + await API_classcourse.updateClasscourse({ id: courseId, status: 'closed' }) return ChatWs.closedCourse(timgroupid) } + // 翻页消息 + const slideFlapping = (msg:object) => { + return new Promise(async (resolve, reject) => { + const isWs = !!ChatWs.ws && ChatWs.ws.readyState === 1 // 是否有socket连接 + if(!timgroupid) return reject('未获取到群组ID') + else if(!isWs) return reject('信异常,请重试!') + const {current: paging, animation: cartoonTimes} = msg || {} + const head = MsgEnum.HEADS.MSG_slideFlapping + ChatWs.sendMsg(head, msg) // 发送消息 + API_classcourse.setPaging({ id: courseId, paging, cartoonTimes}) + // 更新本地缓存 + sessionStore.set('curr.classcourse.paging', paging) + sessionStore.set('curr.classcourse.cartoonTimes', cartoonTimes) + classcourseStore.classcourse.paging = paging + classcourseStore.classcourse.cartoonTimes = cartoonTimes + return resolve(true) + }) + } return { - exitCourse, - classcourse, groupid: timgroupid, + classcourse, + exitCourse, + slideFlapping, } } \ 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 e93fb0f..c92a6b6 100644 --- a/src/renderer/src/AixPPTist/src/api/classcourse.ts +++ b/src/renderer/src/AixPPTist/src/api/classcourse.ts @@ -40,9 +40,8 @@ export class Classcourse { ChatWs.id = classcourse.timgroupid // 群组id if (!ChatWs.ws) { ChatWs.init().then(_ => { - console.log('socket-加载成功') isPublic && ChatWs.sendMsg('open', {id: classcourse.id}) - isPublic && console.log('socket-开课消息-已发送') + // isPublic && console.log('socket-开课消息-已发送') }) } this.classcourse = classcourse // 课堂信息 @@ -53,7 +52,7 @@ export class Classcourse { // 如果课堂信息有paging,则更新动画播放状态 const isAnim = !!cartoonTimes || cartoonTimes === 0 if (isPaging) slidesStore.updateSlideIndex(paging) - if (isAnim) slidesStore.updateAnimationIndex(cartoonTimes+1) + if (isAnim) slidesStore.updateAnimationIndex(cartoonTimes) // 课堂信息-状态管理 classcourseStore.setClasscourse(classcourse) // 待上课提示 diff --git a/src/renderer/src/AixPPTist/src/api/types.ts b/src/renderer/src/AixPPTist/src/api/types.ts index e762748..90dc894 100644 --- a/src/renderer/src/AixPPTist/src/api/types.ts +++ b/src/renderer/src/AixPPTist/src/api/types.ts @@ -124,6 +124,8 @@ export class MsgEnum { MSG_classlecturePagesrc : 'classlecturePagesrc', /** @desc: 课堂作业|活动 */ MSG_homework : 'HOMEWORK', + /** @desc: 公屏 - 课堂作业|活动 */ + MSG_pushSreen_work : 'pushSreen-work', /** @desc: 点赞 */ MSG_dz : 'dz', /** @desc: 疑惑 */ diff --git a/src/renderer/src/AixPPTist/src/api/watcher.ts b/src/renderer/src/AixPPTist/src/api/watcher.ts index 220ed53..e64e4a8 100644 --- a/src/renderer/src/AixPPTist/src/api/watcher.ts +++ b/src/renderer/src/AixPPTist/src/api/watcher.ts @@ -23,7 +23,7 @@ export default () => { const classcourseStore = store.useClasscourseStore() // 课堂信息-状态管理 const resource = sessionStore.get('curr.resource') // apt 资源 const smarttalk = sessionStore.get('curr.smarttalk') // 备课资源 - const { execNext, turnPrevSlide } = useExecPlay() + const { execNext, turnPrevSlide } = useExecPlay(false) // 不加载钩子 // 监听幻灯片内容变化 watch(() => slidesStore.slides, (newVal, oldVal) => { PPTApi.updateSlides(newVal, oldVal) // 更新幻灯片内容 @@ -103,9 +103,10 @@ export default () => { else if (type === 'Previoustep') turnPrevSlide() // 上一步清空-动画 else slidesStore.updateSlideIndex(slideIndex) // 更新幻灯片下标 break - case MsgEnum.HEADS.MSG_homework: // 作业|活动-布置 - if (!content.classWorkId) return - Homework.showHomework(content.classWorkId) + // case MsgEnum.HEADS.MSG_homework: // 作业|活动-布置 不处理 + case MsgEnum.HEADS.MSG_pushSreen_work: // 打开-作业|活动 + if (!content.id) return + Homework.showHomework(content.id) break case MsgEnum.HEADS.MSG_closed: // 下课: close() diff --git a/src/renderer/src/AixPPTist/src/views/Screen/hooks/useExecPlay.ts b/src/renderer/src/AixPPTist/src/views/Screen/hooks/useExecPlay.ts index 3838c08..98a12e3 100644 --- a/src/renderer/src/AixPPTist/src/views/Screen/hooks/useExecPlay.ts +++ b/src/renderer/src/AixPPTist/src/views/Screen/hooks/useExecPlay.ts @@ -6,10 +6,13 @@ import { KEYS } from '../../../configs/hotkey' import { ANIMATION_CLASS_PREFIX } from '../../../configs/animation' import message from '../../../utils/message' import emitter from '@/utils/mitt'; -import ChatWs from '@/plugins/socket' // 聊天socket -import { MsgEnum } from '../../../api/types' // 消息枚举 +import Chat from '../../../api/chat' // 聊天封装 +// import ChatWs from '@/plugins/socket' // 聊天socket +// import { MsgEnum } from '../../../api/types' // 消息枚举 -export default () => { +export default (isLoader?: boolean = true) => { + // isLoader 是否执行 onMounted, onUnmounted + const chatApi = Chat() const slidesStore = useSlidesStore() const classcourseStore = useClasscourseStore() // 课堂信息-状态管理 const { slides, slideIndex, formatedAnimations, animationIndex } = storeToRefs(slidesStore) @@ -73,14 +76,15 @@ export default () => { elRef.addEventListener('animationend', handleAnimationEnd, { once: true }) } } - - onMounted(() => { - const firstAnimations = formatedAnimations.value[0] - if (firstAnimations && firstAnimations.animations.length) { - const autoExecFirstAnimations = firstAnimations.animations.every(item => item.trigger === 'auto' || item.trigger === 'meantime') - if (autoExecFirstAnimations) runAnimation() - } - }) + if (isLoader) { // 加载相关钩子 + onMounted(() => { + const firstAnimations = formatedAnimations.value[0] + if (firstAnimations && firstAnimations.animations.length) { + const autoExecFirstAnimations = firstAnimations.animations.every(item => item.trigger === 'auto' || item.trigger === 'meantime') + if (autoExecFirstAnimations) runAnimation() + } + }) + } // 撤销元素动画,除了将索引前移外,还需要清除动画状态 const revokeAnimation = () => { @@ -144,7 +148,6 @@ export default () => { inAnimation.value = false } const execNext = (isAsync: boolean) => { - console.log('execNext', isAsync) if (formatedAnimations.value.length && animationIndex.value < formatedAnimations.value.length) { runAnimation(isAsync) } @@ -211,16 +214,16 @@ export default () => { } } // 向上翻页/向下翻页 - const turning = (e, type) => { + const turning = async (e, type) => { e.preventDefault() // 阻止默认事件 if (type === 'prev') execPrev() else if (type === 'next') execNext() - // 发送sokcet消息 - const isSend = classcourseStore.classcourse && !!ChatWs.ws && ChatWs.ws.readyState === 1 - console.log('isSend', isSend, ChatWs.ws.readyState) - if (isSend) { // 有课堂信息,发送,没有就是编辑状态 - // const head = MsgEnum.HEADS.MSG_slideFlapping - // ChatWs.sendMsg(head, {type}) + if (classcourseStore.classcourse) { // 上课中 + const current = slideIndex.value + const animation = animationIndex.value + const animationSteps = type == 'next'?'Nextsteps':'Previoustep' + const msg = { current, animation, animationSteps} + chatApi.slideFlapping(msg) } } // 快捷键翻页 @@ -236,10 +239,11 @@ export default () => { key === KEYS.PAGEDOWN ) turning(e, 'next') } - - onMounted(() => {document.addEventListener('keydown', keydownListener)}) - onUnmounted(() => {document.removeEventListener('keydown', keydownListener)}) - + if (isLoader) { // 加载相关钩子 + onMounted(() => {document.addEventListener('keydown', keydownListener)}) + onUnmounted(() => {document.removeEventListener('keydown', keydownListener)}) + } + // 切换到上一张/上一张幻灯片(无视元素的入场动画) const turnPrevSlide = () => { slidesStore.updateSlideIndex(slideIndex.value - 1) diff --git a/src/renderer/src/api/teaching/classcourse.js b/src/renderer/src/api/teaching/classcourse.js index d312f85..d227b2d 100644 --- a/src/renderer/src/api/teaching/classcourse.js +++ b/src/renderer/src/api/teaching/classcourse.js @@ -95,3 +95,11 @@ export function getCourseTeachingMsg(id) { }) } +export function setPaging(data) { + return request({ + url: '/education/classcourse/record/paging', + method: 'post', + data + }) +} + diff --git a/src/renderer/src/directive/scroll.js b/src/renderer/src/directive/scroll.js new file mode 100644 index 0000000..83821e3 --- /dev/null +++ b/src/renderer/src/directive/scroll.js @@ -0,0 +1,26 @@ +/** + * 无限滚动 + */ +import { nextTick } from 'vue' +const mountedHook = async (el, binding) => { + console.log(el, binding) + const value = binding.value + if (typeof value !== 'function') return console.error('v-scroll must be a function') + await nextTick() +} +export default { + // Hooks for Vue3 + mounted(el, binding) { + mountedHook(el, binding) + }, + // Hooks for Vue2 + inserted(el, binding) { + mountedHook(el, binding) + }, + + update(el, binding){ + }, + updated(el, binding){ + + }, +} \ No newline at end of file diff --git a/src/renderer/src/plugins/imChat/msgEnum.js b/src/renderer/src/plugins/imChat/msgEnum.js index 803aea9..708e043 100644 --- a/src/renderer/src/plugins/imChat/msgEnum.js +++ b/src/renderer/src/plugins/imChat/msgEnum.js @@ -98,6 +98,8 @@ export class MsgEnum { MSG_classlecturePagesrc : 'classlecturePagesrc', /** @desc: 课堂作业|活动 */ MSG_homework : 'HOMEWORK', + /** @desc: 公屏 - 课堂作业|活动 */ + MSG_pushSreen_work : 'pushSreen-work', /** @desc: 点赞 */ MSG_dz : 'dz', /** @desc: 疑惑 */ diff --git a/src/renderer/src/views/classManage/classReserv.vue b/src/renderer/src/views/classManage/classReserv.vue index ccb539c..827cd3a 100644 --- a/src/renderer/src/views/classManage/classReserv.vue +++ b/src/renderer/src/views/classManage/classReserv.vue @@ -3,16 +3,16 @@ -
+
+ 到底了,没了